Changeset 254

Show
Ignore:
Timestamp:
02/10/07 17:29:40 (2 years ago)
Author:
mikey
Message:

added net.stubbles.reflection.stubReflectionObject::getObjectInstance()

Files:

Legend:

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

    r253 r254  
    3232     * instance of the reflected class 
    3333     * 
     34     * @var  object 
     35     */ 
     36    protected $classObject; 
     37    /** 
     38     * docblock comment for this class 
     39     * 
    3440     * @var  string 
    3541     */ 
    36     protected $classObject; 
    37     /** 
    38      * docblock comment for this class 
    39      * 
    40      * @var  string 
    41      */ 
    4242    protected $docComment; 
    4343     
     
    4545     * constructor 
    4646     * 
    47      * @param string  $classObject  instance of class to reflect 
     47     * @param object  $classObject  instance of class to reflect 
    4848     */ 
    4949    public function __construct($classObject) 
     
    136136     
    137137    /** 
     138     * returns the instance of the class with with this reflection instance was created 
     139     * 
     140     * @return  object 
     141     */ 
     142    public function getObjectInstance() 
     143    { 
     144        return $this->classObject; 
     145    } 
     146     
     147    /** 
    138148     * returns the constructor or null if none exists 
    139149     *  
  • trunk/src/test/php/net/stubbles/reflection/stubReflectionObjectTestCase.php

    r98 r254  
    2929     */ 
    3030    protected $stubRefClass2; 
     31    /** 
     32     * the first reflected object 
     33     * 
     34     * @var  stubTestWithMethodsAndProperties 
     35     */ 
     36    protected $reflectedObject1; 
     37    /** 
     38     * the second reflected object 
     39     * 
     40     * @var  stubTestWithOutMethodsAndProperties 
     41     */ 
     42    protected $reflectedObject2; 
    3143     
    3244    /** 
     
    3547    public function setUp() 
    3648    { 
    37         $this->stubRefClass1 = new stubReflectionObject(new stubTestWithMethodsAndProperties()); 
    38         $this->stubRefClass2 = new stubReflectionObject(new stubTestWithOutMethodsAndProperties()); 
     49        $this->reflectedObject1 = new stubTestWithMethodsAndProperties(); 
     50        $this->stubRefClass1    = new stubReflectionObject($this->reflectedObject1); 
     51        $this->reflectedObject2 = new stubTestWithOutMethodsAndProperties(); 
     52        $this->stubRefClass2    = new stubReflectionObject($this->reflectedObject2); 
    3953    } 
    4054     
     
    6276        $this->assertTrue((string) $this->stubRefClass1, "reflection.stubReflectionObject[stubTestWithMethodsAndProperties] {\n}\n"); 
    6377        $this->assertTrue((string) $this->stubRefClass2, "reflection.stubReflectionObject[stubTestWithOutMethodsAndProperties] {\n}\n"); 
     78    } 
     79     
     80    /** 
     81     * test that the original object instance is returned 
     82     */ 
     83    public function testGetObjectInstance() 
     84    { 
     85        $reflectedObject1 = $this->stubRefClass1->getObjectInstance(); 
     86        $this->assertReference($reflectedObject1, $this->reflectedObject1); 
     87        $reflectedObject2 = $this->stubRefClass2->getObjectInstance(); 
     88        $this->assertReference($reflectedObject2, $this->reflectedObject2); 
    6489    } 
    6590