Changeset 884

Show
Ignore:
Timestamp:
08/27/07 12:19:30 (1 year ago)
Author:
mikey
Message:

use binder from registry instead of creating an own one

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/service/jsonrpc/stubJsonRpcProcessor.php

    r852 r884  
    301301            throw new stubException('Invalid amount of parameters passed.'); 
    302302        } 
    303         $binder   = new stubBinder(); 
    304         $binder->bind('stubSession')->toInstance($this->session); 
    305         $instance     = $binder->getInjector()->getInstance($class->getName()); 
     303         
     304        $binder = stubRegistry::get('net.stubbles.ioc.stubBinder'); 
     305        if (($binder instanceof stubBinder) === false) { 
     306            throw new stubException('No instance of net.stubbles.ioc.stubBinder in registry.'); 
     307        } 
     308         
     309        $instance = $binder->getInjector()->getInstance($class->getName()); 
    306310        return $method->invokeArgs($instance, $params); 
    307311    } 
  • trunk/src/test/php/net/stubbles/service/jsonrpc/stubJsonRpcProcessorTestCase.php

    r793 r884  
    121121                                 ) 
    122122        ); 
     123        stubRegistry::set('net.stubbles.ioc.stubBinder', new stubBinder()); 
     124    } 
     125 
     126    /** 
     127     * clear test environment 
     128     */ 
     129    public function tearDown() 
     130    { 
     131        stubRegistry::remove('net.stubbles.ioc.stubBinder'); 
    123132    } 
    124133 
     
    235244        $this->proc->processPostRequest(); 
    236245    } 
     246 
     247    /** 
     248     * assure that missing binder triggers an exception 
     249     */ 
     250    public function testWithoutBinderInRegistry() 
     251    { 
     252        stubRegistry::remove('net.stubbles.ioc.stubBinder'); 
     253        $this->mockRequest->setReturnValue('getValidatedRawData', '{"method":"Test.add","params":["2","2"],"id":"1"}'); 
     254        $this->mockResponse->expect('write', array('{"id":"1","result":null,"error":"No instance of net.stubbles.ioc.stubBinder in registry."}')); 
     255        $this->proc->processPostRequest(); 
     256    } 
    237257} 
    238258?>