CodeView

PHPUnit test harness for Komodo

KoHarnessDefaultsTest.php

<?php
 
    /**
     * @author  Michael Heim
     * @link    http://www.zeilenwechsel.de/
     * @version 1.0.0
     * @license http://www.zeilenwechsel.de/it/code/browse/komodo-phpunit-harness/prod/license.txt
     */
 
    require_once( dirname( dirname( dirname( __file__ ) ) ) . '/prod/Utils/Loader.php' );
    PHPUnitXt_Utils_Loader::load( 'PHPUnitXt_Ko_PrinterOptions' );
 
 
    class PHPUnitXt_Ko_PrinterOptionsTest extends PHPUnit_Framework_TestCase {
 
        public function testGetOptionNames_WithOpposites_ListIsComplete () {
 
            $ko_options = new PHPUnitXt_Ko_PrinterOptions();
 
            $retrieved = $ko_options->get_option_names();
            $expected =  $this->get_option_names();
 
            sort( $retrieved );
            sort( $expected );
 
            $this->assertEquals( $expected, $retrieved );
 
        }
 
        public function testGetOptionNames_WithoutOpposites_ListIsComplete () {
 
            $ko_options = new PHPUnitXt_Ko_PrinterOptions();
 
            $retrieved = $ko_options->get_option_names( false );
            $expected =  $this->get_option_names( false );
 
            sort( $retrieved );
            sort( $expected );
 
            $this->assertEquals( $expected, $retrieved );
 
        }
 
        /**
         * @dataProvider provideOptionNames
         */
        public function testSetAndGet_IsRetrievedAsSet ( $option ) {
 
            $ko_options = new PHPUnitXt_Ko_PrinterOptions();
 
            $ko_options->set( $option );
            $retrieved = $ko_options->get( $option );
 
            $this->assertTrue( $retrieved, "Failed for option $option." );
 
            $ko_options->set( $option, false );
            $retrieved = $ko_options->get( $option );
 
            $this->assertFalse( $retrieved, "Failed for option $option." );
 
            $ko_options->set( $option );
            $retrieved = $ko_options->get( $option );
 
            $this->assertTrue( $retrieved, "Failed for option $option." );
 
        }
 
 
        public function provideOptionNames () {
 
            $all_opts = $this->get_option_names();
 
            foreach ( $all_opts as $option ) {
                $option_provider[] = array( $option );
            }
 
            return $option_provider;
 
        }
 
        /**
         * Returns an array of all defined options.
         *
         * @param bool      $include_opposites    include the names of complementary, opposite options in the array
         * @return array
         */
        public function get_option_names ( $include_opposites = true ) {
 
            $primary_options = array( 
                'as-text',
                'show-class',
                'show-passed',
                'in-groups',
                'force-new-harness',
                'show-summary'
            );
 
            $opposite_options = array( 
                'as-name',
                'hide-class',
                'hide-passed',
                'in-sequence',
                'hide-summary'
            );
 
            return ( $include_opposites ? array_merge( $primary_options, $opposite_options ) : $primary_options );
 
        }
 
    }
 
?>