Changeset 1390

Show
Ignore:
Timestamp:
02/29/08 19:23:26 (5 months ago)
Author:
mikey
Message:

implemented enhancement #125 part1: stubBindingScopes::$SESSION

Files:

Legend:

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

    r1362 r1390  
    11<?php 
    22/** 
    3  * All built-in scopes 
     3 * All built-in scopes. 
    44 * 
    55 * @author      Stephan Schmidt <schst@stubbles.net> 
     
    77 * @subpackage  ioc 
    88 */ 
    9 stubClassLoader::load('net::stubbles::ioc::stubBindingScopeSingleton'); 
     9stubClassLoader::load('net::stubbles::ioc::stubBindingScopeSession', 
     10                      'net::stubbles::ioc::stubBindingScopeSingleton' 
     11); 
    1012/** 
    11  * All built-in scopes 
     13 * All built-in scopes. 
    1214 * 
    1315 * @package     stubbles 
     
    1719{ 
    1820    /** 
    19      * Scope for singleton objects 
     21     * scope for singleton objects 
    2022     * 
    21      * @var  string 
     23     * @var  stubBindingScopeSingleton 
    2224     */ 
    23     public static $SINGLETON = null; 
     25    public static $SINGLETON; 
     26    /** 
     27     * scope for session resources 
     28     * 
     29     * @var  stubBindingScopeSession 
     30     */ 
     31    public static $SESSION; 
    2432 
    2533    /** 
    26      * Initialize all built-in scopes 
     34     * initialize all built-in scopes 
    2735     */ 
    2836    // @codeCoverageIgnoreStart 
     
    3038    { 
    3139        self::$SINGLETON = new stubBindingScopeSingleton(); 
     40        self::$SESSION   = new stubBindingScopeSession(); 
    3241    } 
    3342    // @codeCoverageIgnoreEnd 
    34  
    3543} 
    3644?> 
  • trunk/src/main/php/net/stubbles/ioc/stubIOCPreInterceptor.php

    r1232 r1390  
    3838        $binder->bind('stubSession')->toInstance($session); 
    3939        $binder->bind('stubResponse')->toInstance($response); 
     40        stubBindingScopes::$SESSION->setSession($session); 
    4041    } 
    4142} 
  • trunk/src/test/php/net/stubbles/ioc/IOCTestSuite.php

    r1371 r1390  
    3636        $suite->addTestFile($dir . '/stubInjectorNamedTestCase.php'); 
    3737        $suite->addTestFile($dir . '/stubInjectorProviderTestCase.php'); 
     38        $suite->addTestFile($dir . '/stubInjectorSessionTestCase.php'); 
    3839        $suite->addTestFile($dir . '/stubInjectorSingletonTestCase.php'); 
    3940        $suite->addTestFile($dir . '/stubIOCPreInterceptorTestCase.php'); 
  • trunk/src/test/php/net/stubbles/ioc/stubIOCPreInterceptorTestCase.php

    r1235 r1390  
    88 */ 
    99stubClassLoader::load('net::stubbles::ioc::stubIOCPreInterceptor'); 
     10/** 
     11 * extended session binding scope for the test 
     12 * 
     13 * @package     stubbles 
     14 * @subpackage  ioc_test 
     15 */ 
     16class 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} 
    1028/** 
    1129 * Test for net::stubbles::ioc::stubIOCPreInterceptor. 
     
    4058     */ 
    4159    protected $mockResponse; 
     60    /** 
     61     * saved session scope 
     62     * 
     63     * @var  stubBindingScopeSession 
     64     */ 
     65    protected $sessionScope; 
    4266 
    4367    /** 
     
    5175        $this->mockResponse      = $this->getMock('stubResponse'); 
    5276        stubRegistry::remove(stubBinder::REGISTRY_KEY); 
     77        $this->sessionScope = stubBindingScopes::$SESSION; 
     78        stubBindingScopes::$SESSION = new TeststubBindingScopeSession(); 
    5379    } 
    5480 
     
    5985    { 
    6086        stubRegistry::remove(stubBinder::REGISTRY_KEY); 
     87        stubBindingScopes::$SESSION = $this->sessionScope; 
    6188    } 
    6289 
     
    7198        $injector = $binder->getInjector(); 
    7299        $request  = $injector->getInstance('stubRequest'); 
    73         $this->identicalTo($this->mockRequest, $request); 
     100        $this->assertSame($this->mockRequest, $request); 
    74101        $session  = $injector->getInstance('stubSession'); 
    75         $this->identicalTo($this->mockSession, $session); 
     102        $this->assertSame($this->mockSession, $session); 
    76103        $response = $injector->getInstance('stubResponse'); 
    77         $this->identicalTo($this->mockResponse, $response); 
     104        $this->assertSame($this->mockResponse, $response); 
     105        $this->assertSame($this->mockSession, stubBindingScopes::$SESSION->returnSession()); 
    78106    } 
    79107}