Changeset 697

Show
Ignore:
Timestamp:
05/31/07 22:48:08 (1 year ago)
Author:
mikey
Message:

fixed unit tests: used wrong assertions
fixed toString() bugs detected by using correct assertion
whitespace fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/reflection/stubReflectionParameter.php

    r253 r697  
    3030     */ 
    3131    protected $paramName; 
    32      
     32 
    3333    /** 
    3434     * constructor 
     
    4343        parent::__construct($functionName, $paramName); 
    4444    } 
    45      
     45 
    4646    /** 
    4747     * checks whether a value is equal to the class 
     
    6868        return ($compareClass->getName() == $class->getName() && $compare->functionName == $this->functionName && $compare->paramName == $this->paramName); 
    6969    } 
    70      
     70 
    7171    /** 
    7272     * returns a string representation of the class 
     
    8686    public function __toString() 
    8787    { 
    88         $class = $this->getDeclaringClass(); 
    89         if (null == $class) { 
     88        if (is_array($this->functionName) == false) { 
    9089            return 'net.stubbles.reflection.stubReflectionParameter[' . $this->functionName . '(): Argument ' . $this->paramName . "] {\n}\n"; 
    9190        } 
    9291         
    93         return 'net.stubbles.reflection.stubReflectionParameter[' . $class->getName() . '::' . $this->functionName . '(): Argument ' . $this->paramName . "] {\n}\n"; 
     92        return 'net.stubbles.reflection.stubReflectionParameter[' . $this->functionName[0] . '::' . $this->functionName[1] . '(): Argument ' . $this->paramName . "] {\n}\n"; 
    9493    } 
    95      
     94 
    9695    /** 
    9796     * returns the function that declares this parameter 
     
    108107        return $stubRefFunction; 
    109108    }*/ 
    110      
     109 
    111110    /** 
    112111     * returns the class that declares this parameter 
     
    124123        return $stubRefClass; 
    125124    } 
    126      
     125 
    127126    /** 
    128127     * returns the type (class) hint for this parameter 
  • trunk/src/test/php/net/stubbles/reflection/stubReflectionClassTestCase.php

    r408 r697  
    3030     */ 
    3131    protected $stubRefClass2; 
    32      
     32 
    3333    /** 
    3434     * set up the test environment 
     
    3939        $this->stubRefClass2 = new stubReflectionClass('stubTestWithOutMethodsAndProperties'); 
    4040    } 
    41      
     41 
    4242    /** 
    4343     * assure that instances of stubReflectionClass for the same class are equal 
     
    5555        $this->assertFalse($this->stubRefClass2->equals($stubRefClass)); 
    5656    } 
    57      
     57 
    5858    /** 
    5959     * test behaviour if casted to string 
     
    6161    public function testToString() 
    6262    { 
    63         $this->assertTrue((string) $this->stubRefClass1, "reflection.stubReflectionClass[stubTestWithMethodsAndProperties] {\n}\n"); 
    64         $this->assertTrue((string) $this->stubRefClass2, "reflection.stubReflectionClass[stubTestWithOutMethodsAndProperties] {\n}\n"); 
     63        $this->assertEqual((string) $this->stubRefClass1, "net.stubbles.reflection.stubReflectionClass[stubTestWithMethodsAndProperties] {\n}\n"); 
     64        $this->assertEqual((string) $this->stubRefClass2, "net.stubbles.reflection.stubReflectionClass[stubTestWithOutMethodsAndProperties] {\n}\n"); 
    6565    } 
    66      
     66 
    6767    /** 
    6868     * test the full qualified class name 
     
    7373        $this->assertEqual($this->stubRefClass2->getFullQualifiedClassName(), 'stubTestWithOutMethodsAndProperties'); 
    7474    } 
    75      
     75 
    7676    /** 
    7777     * test that getting the constructor method works correct 
     
    8585        $this->assertNull($this->stubRefClass2->getConstructor()); 
    8686    } 
    87      
     87 
    8888    /** 
    8989     * test that getting the specified method works correct 
     
    9898        $this->assertNull($stubRefMethod); 
    9999    } 
    100      
     100 
    101101    /** 
    102102     * test that getting the methods works correct 
     
    113113        $this->assertEqual(count($stubRefMethods), 0); 
    114114    } 
    115      
     115 
    116116    /** 
    117117     * test that getting the specified property works correct 
     
    126126        $this->assertNull($stubRefProperty); 
    127127    } 
    128      
     128 
    129129    /** 
    130130     * test that getting the properties works as expected 
     
    141141        $this->assertEqual(count($stubRefMethods), 0); 
    142142    } 
    143      
     143 
    144144    /** 
    145145     * test that getting the interfaces works correct 
     
    157157        $this->assertEqual(count($stubRefClasses), 0); 
    158158    } 
    159      
     159 
    160160    /** 
    161161     * test that getting the parent class works correct 
     
    169169        $this->assertNull($this->stubRefClass2->getParentClass()); 
    170170    } 
    171      
     171 
    172172    /** 
    173173     * test that getting the extension works correct 
     
    179179        $this->assertIsA($refClass->getExtension(), 'stubReflectionExtension'); 
    180180    } 
    181      
     181 
    182182    /** 
    183183     * test that class loading works as expected 
  • trunk/src/test/php/net/stubbles/reflection/stubReflectionExtensionTestCase.php

    r98 r697  
    2222     */ 
    2323    protected $stubRefExtension; 
    24      
     24 
    2525    /** 
    2626     * set up the test environment 
     
    3232        $this->stubRefExtension = new stubReflectionExtension('date'); 
    3333    } 
    34      
     34 
    3535    /** 
    3636     * assure that instances of stubReflectionExtension for the same class are equal 
     
    4747        $this->assertFalse($stubRefExtension2->equals($this->stubRefExtension)); 
    4848    } 
    49      
     49 
    5050    /** 
    5151     * test behaviour if casted to string 
     
    5353    public function testToString() 
    5454    { 
    55         $this->assertTrue((string) $this->stubRefExtension, "reflection.stubRefExtension[date] {\n}\n"); 
     55        $this->assertEqual((string) $this->stubRefExtension, "net.stubbles.reflection.stubReflectionExtension[date] {\n}\n"); 
    5656    } 
    5757 
  • trunk/src/test/php/net/stubbles/reflection/stubReflectionFunctionTestCase.php

    r155 r697  
    3030     */ 
    3131    protected $stubRefFunction2; 
    32      
     32 
    3333    /** 
    3434     * set up the test environment 
     
    3939        $this->stubRefFunction2 = new stubReflectionFunction('stubTestWithOutParams'); 
    4040    } 
    41      
     41 
    4242    /** 
    4343     * assure that instances of stubReflectionClass for the same class are equal 
     
    5555        $this->assertFalse($this->stubRefFunction2->equals($stubRefFunction)); 
    5656    } 
    57      
     57 
    5858    /** 
    5959     * test behaviour if casted to string 
     
    6161    public function testToString() 
    6262    { 
    63         $this->assertTrue((string) $this->stubRefFunction1, "reflection.stubReflectionFunction[stubTestWithParams()] {\n}\n"); 
    64         $this->assertTrue((string) $this->stubRefFunction2, "reflection.stubReflectionFunction[stubTestWithOutParams()] {\n}\n"); 
     63        $this->assertEqual((string) $this->stubRefFunction1, "net.stubbles.reflection.stubReflectionFunction[stubTestWithParams()] {\n}\n"); 
     64        $this->assertEqual((string) $this->stubRefFunction2, "net.stubbles.reflection.stubReflectionFunction[stubTestWithOutParams()] {\n}\n"); 
    6565    } 
    6666 
  • trunk/src/test/php/net/stubbles/reflection/stubReflectionMethodTestCase.php

    r98 r697  
    6565     */ 
    6666    protected $stubRefMethod5; 
    67      
     67 
    6868    /** 
    6969     * set up the test environment 
     
    7777        $this->stubRefMethod5 = new stubReflectionMethod('stubTest2', 'methodWithParams2'); 
    7878    } 
    79      
     79 
    8080    /** 
    8181     * assure that instances of stubReflectionClass for the same class are equal 
     
    117117        $this->assertFalse($this->stubRefMethod5->equals($stubRefMethod)); 
    118118    } 
    119      
     119 
    120120    /** 
    121121     * test behaviour if casted to string 
     
    123123    public function testToString() 
    124124    { 
    125         $this->assertTrue((string) $this->stubRefMethod1, "reflection.stubReflectionClass[stubTest::methodWithoutParams()] {\n}\n"); 
    126         $this->assertTrue((string) $this->stubRefMethod2, "reflection.stubReflectionClass[stubTest::methodWithParams()] {\n}\n"); 
    127         $this->assertTrue((string) $this->stubRefMethod3, "reflection.stubReflectionClass[stubTest2::methodWithoutParams()] {\n}\n"); 
    128         $this->assertTrue((string) $this->stubRefMethod4, "reflection.stubReflectionClass[stubTest2::methodWithParams()] {\n}\n"); 
    129         $this->assertTrue((string) $this->stubRefMethod5, "reflection.stubReflectionClass[stubTest2::methodWithParams2()] {\n}\n"); 
     125        $this->assertEqual((string) $this->stubRefMethod1, "net.stubbles.reflection.stubReflectionMethod[stubTest::methodWithoutParams()] {\n}\n"); 
     126        $this->assertEqual((string) $this->stubRefMethod2, "net.stubbles.reflection.stubReflectionMethod[stubTest::methodWithParams()] {\n}\n"); 
     127        $this->assertEqual((string) $this->stubRefMethod3, "net.stubbles.reflection.stubReflectionMethod[stubTest2::methodWithoutParams()] {\n}\n"); 
     128        $this->assertEqual((string) $this->stubRefMethod4, "net.stubbles.reflection.stubReflectionMethod[stubTest2::methodWithParams()] {\n}\n"); 
     129        $this->assertEqual((string) $this->stubRefMethod5, "net.stubbles.reflection.stubReflectionMethod[stubTest2::methodWithParams2()] {\n}\n"); 
    130130    } 
    131      
     131 
    132132    /** 
    133133     * test that getting the declaring class works correct 
     
    155155        $this->assertEqual($stubRefClass->getName(), 'stubTest2'); 
    156156    } 
    157      
     157 
    158158    /** 
    159159     * test that getting the parameters works correct 
  • trunk/src/test/php/net/stubbles/reflection/stubReflectionObjectTestCase.php

    r255 r697  
    4141     */ 
    4242    protected $reflectedObject2; 
    43      
     43 
    4444    /** 
    4545     * set up the test environment 
     
    5252        $this->stubRefClass2    = new stubReflectionObject($this->reflectedObject2); 
    5353    } 
    54      
     54 
    5555    /** 
    5656     * assure that instances of stubReflectionClass for the same class are equal 
     
    6868        $this->assertFalse($this->stubRefClass2->equals($stubRefClass)); 
    6969    } 
    70      
     70 
    7171    /** 
    7272     * test behaviour if casted to string 
     
    7474    public function testToString() 
    7575    { 
    76         $this->assertTrue((string) $this->stubRefClass1, "reflection.stubReflectionObject[stubTestWithMethodsAndProperties] {\n}\n"); 
    77         $this->assertTrue((string) $this->stubRefClass2, "reflection.stubReflectionObject[stubTestWithOutMethodsAndProperties] {\n}\n"); 
    78     } 
    79      
     76        $this->assertEqual((string) $this->stubRefClass1, "net.stubbles.reflection.stubReflectionObject[stubTestWithMethodsAndProperties] {\n}\n"); 
     77        $this->assertEqual((string) $this->stubRefClass2, "net.stubbles.reflection.stubReflectionObject[stubTestWithOutMethodsAndProperties] {\n}\n"); 
     78    } 
     79 
    8080    /** 
    8181     * test the full qualified class name 
     
    8686        $this->assertEqual($this->stubRefClass2->getFullQualifiedClassName(), 'stubTestWithOutMethodsAndProperties'); 
    8787    } 
    88      
     88 
    8989    /** 
    9090     * test that the original object instance is returned 
     
    9797        $this->assertReference($reflectedObject2, $this->reflectedObject2); 
    9898    } 
    99      
     99 
    100100    /** 
    101101     * test that getting the constructor method works correct 
     
    109109        $this->assertNull($this->stubRefClass2->getConstructor()); 
    110110    } 
    111      
     111 
    112112    /** 
    113113     * test that getting the specified method works correct 
     
    122122        $this->assertNull($stubRefMethod); 
    123123    } 
    124      
     124 
    125125    /** 
    126126     * test that getting the methods works correct 
     
    137137        $this->assertEqual(count($stubRefMethods), 0); 
    138138    } 
    139      
     139 
    140140    /** 
    141141     * test that getting the specified property works correct 
     
    150150        $this->assertNull($stubRefProperty); 
    151151    } 
    152      
     152 
    153153    /** 
    154154     * test that getting the properties works as expected 
     
    165165        $this->assertEqual(count($stubRefMethods), 0); 
    166166    } 
    167      
     167 
    168168    /** 
    169169     * test that getting the interfaces works correct 
     
    181181        $this->assertEqual(count($stubRefClasses), 0); 
    182182    } 
    183      
     183 
    184184    /** 
    185185     * test that getting the parent class works correct 
     
    193193        $this->assertNull($this->stubRefClass2->getParentClass()); 
    194194    } 
    195      
     195 
    196196    /** 
    197197     * test that getting the extension works correct 
  • trunk/src/test/php/net/stubbles/reflection/stubReflectionParameterTestCase.php

    r98 r697  
    6969     */ 
    7070    protected $stubRefParamMethod4; 
    71      
     71 
    7272    /** 
    7373     * create the test environment 
     
    8181        $this->stubRefParamMethod4  = new stubReflectionParameter(array('stubParamTest2', 'paramTest3'), 'param2'); 
    8282    } 
    83      
     83 
    8484    /** 
    8585     * assure that instances of stubReflectionClass for the same class are equal 
     
    127127        $this->assertFalse($this->stubRefParamMethod4->equals($stubRefParamMethod)); 
    128128    } 
    129      
     129 
    130130    /** 
    131131     * test behaviour if casted to string 
     
    133133    public function testToString() 
    134134    { 
    135         $this->assertTrue((string) $this->stubRefParamFunction, "reflection.stubReflectionParameter[stubtest_function(): Argument param] {\n}\n"); 
    136         $this->assertTrue((string) $this->stubRefParamMethod1, "reflection.stubReflectionParameter[stubParamTest::paramTest(): Argument param] {\n}\n"); 
    137         $this->assertTrue((string) $this->stubRefParamMethod2, "reflection.stubReflectionParameter[stubParamTest2::paramTest(): Argument param] {\n}\n"); 
    138         $this->assertTrue((string) $this->stubRefParamMethod3, "reflection.stubReflectionParameter[stubParamTest2::paramTest2(): Argument param2] {\n}\n"); 
    139         $this->assertTrue((string) $this->stubRefParamMethod4, "reflection.stubReflectionParameter[stubParamTest2::paramTest3(): Argument param2] {\n}\n"); 
     135        $this->assertEqual((string) $this->stubRefParamFunction, "net.stubbles.reflection.stubReflectionParameter[stubtest_function(): Argument param] {\n}\n"); 
     136        $this->assertEqual((string) $this->stubRefParamMethod1, "net.stubbles.reflection.stubReflectionParameter[stubParamTest::paramTest(): Argument param] {\n}\n"); 
     137        $this->assertEqual((string) $this->stubRefParamMethod2, "net.stubbles.reflection.stubReflectionParameter[stubParamTest2::paramTest(): Argument param] {\n}\n"); 
     138        $this->assertEqual((string) $this->stubRefParamMethod3, "net.stubbles.reflection.stubReflectionParameter[stubParamTest2::paramTest2(): Argument param2] {\n}\n"); 
     139        $this->assertEqual((string) $this->stubRefParamMethod4, "net.stubbles.reflection.stubReflectionParameter[stubParamTest2::paramTest3(): Argument param2] {\n}\n"); 
    140140    } 
    141      
     141 
    142142    /** 
    143143     * test that getting the functions works correct 
     
    159159        $this->assertEqual($refClass->getName(), 'stubParamTest2'); 
    160160    } 
    161      
     161 
    162162    /** 
    163163     * test that getting the type (class) hints works correct 
  • trunk/src/test/php/net/stubbles/reflection/stubReflectionPropertyTestCase.php

    r98 r697  
    2727     */ 
    2828    protected $stubRefProperty; 
    29      
     29 
    3030    /** 
    3131     * set up the test environment 
     
    3535        $this->stubRefProperty = new stubReflectionProperty('stubTestProperty', 'property'); 
    3636    } 
    37      
     37 
    3838    /** 
    3939     * assure that instances of stubReflectionExtension for the same class are equal 
     
    5050        $this->assertFalse($stubRefProperty2->equals($this->stubRefProperty)); 
    5151    } 
    52      
     52 
    5353    /** 
    5454     * test behaviour if casted to string 
     
    5656    public function testToString() 
    5757    { 
    58         $this->assertTrue((string) $this->stubRefProperty, "reflection.stubRefExtension[stubTestProperty::property] {\n}\n"); 
     58        $this->assertEqual((string) $this->stubRefProperty, "net.stubbles.reflection.stubReflectionProperty[stubTestProperty::property] {\n}\n"); 
    5959    } 
    6060