Changeset 1390
- Timestamp:
- 02/29/08 19:23:26 (5 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ioc/stubBindingScopeSession.php (added)
- trunk/src/main/php/net/stubbles/ioc/stubBindingScopes.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/ioc/stubIOCPreInterceptor.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/IOCTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ioc/stubIOCPreInterceptorTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/ioc/stubInjectorSessionTestCase.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ioc/stubBindingScopes.php
r1362 r1390 1 1 <?php 2 2 /** 3 * All built-in scopes 3 * All built-in scopes. 4 4 * 5 5 * @author Stephan Schmidt <schst@stubbles.net> … … 7 7 * @subpackage ioc 8 8 */ 9 stubClassLoader::load('net::stubbles::ioc::stubBindingScopeSingleton'); 9 stubClassLoader::load('net::stubbles::ioc::stubBindingScopeSession', 10 'net::stubbles::ioc::stubBindingScopeSingleton' 11 ); 10 12 /** 11 * All built-in scopes 13 * All built-in scopes. 12 14 * 13 15 * @package stubbles … … 17 19 { 18 20 /** 19 * Scope for singleton objects21 * scope for singleton objects 20 22 * 21 * @var st ring23 * @var stubBindingScopeSingleton 22 24 */ 23 public static $SINGLETON = null; 25 public static $SINGLETON; 26 /** 27 * scope for session resources 28 * 29 * @var stubBindingScopeSession 30 */ 31 public static $SESSION; 24 32 25 33 /** 26 * Initialize all built-in scopes34 * initialize all built-in scopes 27 35 */ 28 36 // @codeCoverageIgnoreStart … … 30 38 { 31 39 self::$SINGLETON = new stubBindingScopeSingleton(); 40 self::$SESSION = new stubBindingScopeSession(); 32 41 } 33 42 // @codeCoverageIgnoreEnd 34 35 43 } 36 44 ?> trunk/src/main/php/net/stubbles/ioc/stubIOCPreInterceptor.php
r1232 r1390 38 38 $binder->bind('stubSession')->toInstance($session); 39 39 $binder->bind('stubResponse')->toInstance($response); 40 stubBindingScopes::$SESSION->setSession($session); 40 41 } 41 42 } trunk/src/test/php/net/stubbles/ioc/IOCTestSuite.php
r1371 r1390 36 36 $suite->addTestFile($dir . '/stubInjectorNamedTestCase.php'); 37 37 $suite->addTestFile($dir . '/stubInjectorProviderTestCase.php'); 38 $suite->addTestFile($dir . '/stubInjectorSessionTestCase.php'); 38 39 $suite->addTestFile($dir . '/stubInjectorSingletonTestCase.php'); 39 40 $suite->addTestFile($dir . '/stubIOCPreInterceptorTestCase.php'); trunk/src/test/php/net/stubbles/ioc/stubIOCPreInterceptorTestCase.php
r1235 r1390 8 8 */ 9 9 stubClassLoader::load('net::stubbles::ioc::stubIOCPreInterceptor'); 10 /** 11 * extended session binding scope for the test 12 * 13 * @package stubbles 14 * @subpackage ioc_test 15 */ 16 class TeststubBindingScopeSession extends stubBindingScopeSession 17 { 18 /** 19 * returns the session instance 20 * 21 * @return stubSession 22 */ 23 public function returnSession() 24 { 25 return $this->session; 26 } 27 } 10 28 /** 11 29 * Test for net::stubbles::ioc::stubIOCPreInterceptor. … … 40 58 */ 41 59 protected $mockResponse; 60 /** 61 * saved session scope 62 * 63 * @var stubBindingScopeSession 64 */ 65 protected $sessionScope; 42 66 43 67 /** … … 51 75 $this->mockResponse = $this->getMock('stubResponse'); 52 76 stubRegistry::remove(stubBinder::REGISTRY_KEY); 77 $this->sessionScope = stubBindingScopes::$SESSION; 78 stubBindingScopes::$SESSION = new TeststubBindingScopeSession(); 53 79 } 54 80 … … 59 85 { 60 86 stubRegistry::remove(stubBinder::REGISTRY_KEY); 87 stubBindingScopes::$SESSION = $this->sessionScope; 61 88 } 62 89 … … 71 98 $injector = $binder->getInjector(); 72 99 $request = $injector->getInstance('stubRequest'); 73 $this-> identicalTo($this->mockRequest, $request);100 $this->assertSame($this->mockRequest, $request); 74 101 $session = $injector->getInstance('stubSession'); 75 $this-> identicalTo($this->mockSession, $session);102 $this->assertSame($this->mockSession, $session); 76 103 $response = $injector->getInstance('stubResponse'); 77 $this->identicalTo($this->mockResponse, $response); 104 $this->assertSame($this->mockResponse, $response); 105 $this->assertSame($this->mockSession, stubBindingScopes::$SESSION->returnSession()); 78 106 } 79 107 }
