Changeset 1005

Show
Ignore:
Timestamp:
11/08/07 20:06:36 (1 year ago)
Author:
schst
Message:

Added test cases for implicit bindings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/test/php/net/stubbles/ioc/stubInjectorBasicTestCase.php

    r1004 r1005  
    1919} 
    2020 
     21class stubInjectorTestCase_ImplicitDependency { 
     22    protected $goodyear; 
     23 
     24    /** 
     25     * @Inject 
     26     */ 
     27    public function __construct(stubInjectorTestCase_Goodyear $goodyear) { 
     28        $this->goodyear = $goodyear; 
     29    } 
     30 
     31    public function getGoodyear() { 
     32        return $this->goodyear; 
     33    } 
     34} 
     35 
     36 
    2137interface stubInjectorTestCase_Vehicle { 
    2238    public function moveForward(); 
     
    230246        $this->assertNull($vehicle->roof); 
    231247    } 
     248 
     249    /** 
     250     * test implicit bindings 
     251     */ 
     252    public function testImplicitBinding() 
     253    { 
     254        $binder = new stubBinder(); 
     255        $injector = $binder->getInjector(); 
     256 
     257        $goodyear = $injector->getInstance('stubInjectorTestCase_Goodyear'); 
     258        $this->assertIsA($goodyear, 'stubInjectorTestCase_Goodyear'); 
     259    } 
     260 
     261    /** 
     262     * test implicit bindings as a dependency 
     263     */ 
     264    public function testImplicitBindingAsDependency() 
     265    { 
     266        $binder = new stubBinder(); 
     267        $injector = $binder->getInjector(); 
     268 
     269        $obj = $injector->getInstance('stubInjectorTestCase_ImplicitDependency'); 
     270        $this->assertIsA($obj, 'stubInjectorTestCase_ImplicitDependency'); 
     271        $this->assertIsA($obj->getGoodyear(), 'stubInjectorTestCase_Goodyear'); 
     272    } 
    232273} 
    233274?>