Changeset 1394

Show
Ignore:
Timestamp:
03/03/08 14:25:14 (6 months ago)
Author:
mikey
Message:

fixed defect #134: stubClassBinding::to() should throw an exception

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/ioc/stubClassBinding.php

    r1371 r1394  
    88 */ 
    99stubClassLoader::load('net::stubbles::ioc::exceptions::stubBindingException', 
     10                      'net::stubbles::ioc::stubBinding', 
     11                      'net::stubbles::ioc::stubBindingScope', 
    1012                      'net::stubbles::ioc::stubDefaultInjectionProvider', 
     13                      'net::stubbles::ioc::stubInjectionProvider', 
     14                      'net::stubbles::ioc::stubValueInjectionProvider', 
     15                      'net::stubbles::lang::exceptions::stubIllegalArgumentException', 
     16                      'net::stubbles::reflection::stubBaseReflectionClass', 
    1117                      'net::stubbles::reflection::stubReflectionClass' 
    1218); 
     
    8086     * @param   stubBaseReflectionClass|string  $impl 
    8187     * @return  stubBinding 
     88     * @throws  stubIllegalArgumentException 
    8289     */ 
    8390    public function to($impl) 
    8491    { 
     92        if (is_string($impl) === false && ($impl instanceof stubBaseReflectionClass) === false) { 
     93            throw new stubIllegalArgumentException('$impl must be a string or an instance of net::stubbles::reflection::stubBaseReflectionClass'); 
     94        } 
     95         
    8596        $this->impl = $impl; 
    8697        return $this; 
  • trunk/src/test/php/net/stubbles/ioc/stubInjectorBasicTestCase.php

    r1371 r1394  
    379379        $this->assertType('stubInjectorTestCase_Tire', $vehicle->tire); 
    380380        $this->assertType('stubInjectorTestCase_Goodyear', $vehicle->tire); 
     381    } 
     382 
     383    /** 
     384     * test bindings to an invalid type 
     385     * 
     386     * @test 
     387     * @expectedException  stubIllegalArgumentException 
     388     */ 
     389    public function setterInjectionWithInvalidArgument() 
     390    { 
     391        $binder = new stubBinder(); 
     392        $binder->bind('stubInjectorTestCase_Vehicle')->to(313); 
    381393    } 
    382394 
     
    422434    } 
    423435 
    424  
    425436    /** 
    426437     * test setter injections