Changeset 1314

Show
Ignore:
Timestamp:
01/31/08 08:58:20 (5 months ago)
Author:
mikey
Message:

backlash for refactoring #118: convert star test

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/star/build.xml

    r1210 r1314  
    55  <property name="pkg.name" value="star-${version}"/> 
    66  <property name="build.src.dir" value="${build.base.dir}/${pkg.name}"/> 
    7   <taskDef name="mySimpletest" classname="MySimpleTestTask" classpath="${stubbles.base.dir}/src/test" /> 
    87 
    98  <target name="main" if="version" depends="test,build"/> 
     
    5958 
    6059  <target name="test" description="run test suite"> 
    61     <mySimpletest testfile="&quot;${stubbles.base.dir}/src/test/php/org/stubbles/star/run.php&quot;" exit="true" /> 
     60    <exec passthru="true" command="phpunit src_test_php_org_stubbles_star_starTestSuite"/> 
    6261  </target> 
    6362</project> 
  • trunk/src/test/php/org/stubbles/star/StarFileTestCase.php

    r1210 r1314  
    1414 * @subpackage  star_test 
    1515 */ 
    16 class StarFileTestCase extends UnitTestCase 
     16class StarFileTestCase extends PHPUnit_Framework_TestCase 
    1717{ 
    1818    /** 
     
    3434     */ 
    3535    protected $dirname; 
    36      
     36 
    3737    /** 
    3838     * set up test environment 
     
    4444        $this->starFile = new StarFile($this->filename, $this->dirname); 
    4545    } 
    46      
     46 
    4747    /** 
    4848     * assure that values are returned as expected 
     49     * 
     50     * @test 
    4951     */ 
    50     public function testValues() 
     52    public function values() 
    5153    { 
    52         $this->assertEqual($this->starFile->getName(), $this->filename); 
    53         $this->assertEqual($this->starFile->getBaseName(), 'bar.baz'); 
    54         $this->assertEqual($this->starFile->getExtension(), 'baz'); 
    55         $this->assertEqual($this->starFile->getPath(), $this->dirname . DIRECTORY_SEPARATOR . 'foo'); 
    56         $this->assertEqual($this->starFile->getPathWithBaseRemoved(), 'foo'); 
     54        $this->assertEquals($this->filename, $this->starFile->getName()); 
     55        $this->assertEquals('bar.baz', $this->starFile->getBaseName()); 
     56        $this->assertEquals('baz', $this->starFile->getExtension()); 
     57        $this->assertEquals($this->dirname . DIRECTORY_SEPARATOR . 'foo', $this->starFile->getPath()); 
     58        $this->assertEquals('foo', $this->starFile->getPathWithBaseRemoved()); 
    5759    } 
    58      
     60 
    5961    /** 
    6062     * assure that the setExtension() method works correct 
     63     * 
     64     * @test 
    6165     */ 
    62     public function testSetExtension() 
     66    public function setExtension() 
    6367    { 
    6468        $this->starFile->setExtension('baz'); 
    65         $this->assertEqual($this->starFile->getExtension(), 'baz'); 
    66         $this->assertEqual($this->starFile->getName(), $this->filename); 
    67         $this->assertEqual($this->starFile->getPathWithBaseRemoved(), 'foo'); 
     69        $this->assertEquals('baz', $this->starFile->getExtension()); 
     70        $this->assertEquals($this->filename, $this->starFile->getName()); 
     71        $this->assertEquals('foo', $this->starFile->getPathWithBaseRemoved()); 
    6872         
    6973        $this->starFile->setExtension('foo'); 
    70         $this->assertEqual($this->starFile->getExtension(), 'foo'); 
    71         $this->assertEqual($this->starFile->getName(), substr($this->filename, 0, -3) . 'foo'); 
    72         $this->assertEqual($this->starFile->getPathWithBaseRemoved(), 'foo'); 
     74        $this->assertEquals('foo', $this->starFile->getExtension()); 
     75        $this->assertEquals(substr($this->filename, 0, -3) . 'foo', $this->starFile->getName()); 
     76        $this->assertEquals('foo', $this->starFile->getPathWithBaseRemoved()); 
    7377         
    7478        $this->starFile->setExtension('bar'); 
    75         $this->assertEqual($this->starFile->getExtension(), 'bar'); 
    76         $this->assertEqual($this->starFile->getName(), substr($this->filename, 0, -3) . 'bar'); 
    77         $this->assertEqual($this->starFile->getPathWithBaseRemoved(), 'foo'); 
     79        $this->assertEquals('bar', $this->starFile->getExtension()); 
     80        $this->assertEquals(substr($this->filename, 0, -3) . 'bar', $this->starFile->getName()); 
     81        $this->assertEquals('foo', $this->starFile->getPathWithBaseRemoved()); 
    7882         
    7983        $this->starFile->setExtension('baz'); 
    80         $this->assertEqual($this->starFile->getExtension(), 'baz'); 
    81         $this->assertEqual($this->starFile->getName(), $this->filename); 
    82         $this->assertEqual($this->starFile->getPathWithBaseRemoved(), 'foo'); 
     84        $this->assertEquals('baz', $this->starFile->getExtension()); 
     85        $this->assertEquals($this->filename, $this->starFile->getName()); 
     86        $this->assertEquals('foo', $this->starFile->getPathWithBaseRemoved()); 
    8387    } 
    8488} 
  • trunk/src/test/php/org/stubbles/star/starTestSuite.php

    r124 r1314  
    11<?php 
    22/** 
    3  * Test suite for all classes of net.stubbles.star. 
     3 * Test suite for all classes of org::stubbles::star. 
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     
    77 * @subpackage  test 
    88 */ 
     9if (defined('PHPUnit_MAIN_METHOD') === false) { 
     10    define('PHPUnit_MAIN_METHOD', 'src_test_php_org_stubbles_star_starTestSuite::main'); 
     11} 
     12 
     13define('TEST_SRC_PATH', dirname(__FILE__)); 
     14require_once TEST_SRC_PATH . '/../../../../../../config/php/config.php'; 
     15require_once TEST_SRC_PATH . '/../../../../../main/php/net/stubbles/stubClassLoader.php'; 
     16require_once stubConfig::getSourcePath() . '/php/net/stubbles/stubClassLoader.php'; 
     17require_once 'PHPUnit/Framework.php'; 
     18require_once 'PHPUnit/TextUI/TestRunner.php'; 
    919/** 
    10  * Test suite for all classes of net.stubbles.star. 
     20 * Test suite for all classes of org::stubbles::star. 
    1121 * 
    1222 * @package     stubbles 
    1323 * @subpackage  test 
    1424 */ 
    15 class starTestSuite extends TestSuite 
     25class src_test_php_org_stubbles_star_starTestSuite extends PHPUnit_Framework_TestSuite 
    1626{ 
    1727    /** 
    18      * constructor 
     28     * runs this test suite 
    1929     */ 
    20     public function __construct() 
     30    public static function main() 
    2131    { 
    22         $dir = dirname(__FILE__); 
    23         $this->TestSuite('Test suite for all classes of net.stubbles.star'); 
    24         $this->addTestFile($dir . '/StarFileTestCase.php'); 
     32        PHPUnit_TextUI_TestRunner::run(self::suite()); 
     33    } 
     34 
     35    /** 
     36     * returns the test suite to be run 
     37     * 
     38     * @return  PHPUnit_Framework_TestSuite 
     39     */ 
     40    public static function suite() 
     41    { 
     42        $suite = new self(); 
     43        $suite->addTestFile(dirname(__FILE__) . '/StarFileTestCase.php'); 
     44        return $suite; 
    2545    } 
    2646} 
     47 
     48if (PHPUnit_MAIN_METHOD === 'src_test_php_org_stubbles_star_starTestSuite::main') { 
     49    src_test_php_org_stubbles_star_starTestSuite::main(); 
     50} 
    2751?>