Changeset 419
- Timestamp:
- 03/23/07 17:07:45 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/stubFrontController.php
r399 r419 7 7 * @subpackage websites 8 8 */ 9 stubClassLoader::load('net.stubbles.ioc.injection.injection', 9 stubClassLoader::load('net.stubbles.events.events', 10 'net.stubbles.ioc.injection.injection', 10 11 'net.stubbles.ipo.interceptors.stubInterceptorInitializer', 11 12 'net.stubbles.ipo.request.stubRequest', … … 25 26 class stubFrontController extends stubBaseObject 26 27 { 28 /** 29 * name of event triggered when session is created 30 */ 31 const SESSION_EVENT_NAME = 'onSessionCreated'; 27 32 /** 28 33 * list of interceptors to call at startup … … 67 72 */ 68 73 protected $response; 74 /** 75 * the event dispatcher to use 76 * 77 * @var stubEventDispatcher 78 */ 79 protected $dispatcher = null; 69 80 70 81 /** … … 85 96 $this->resolver = $processorResolverFactory->getResolver(); 86 97 $this->createInjectionMap(); 98 } 99 100 /** 101 * sets the event dispatcher to use 102 * 103 * @param stubEventDispatcher $dispatcher 104 */ 105 public function setEventDispatcher(stubEventDispatcher $dispatcher) 106 { 107 $this->dispatcher = $dispatcher; 87 108 } 88 109 … … 118 139 119 140 $this->injectionMap->addInjection('stubSession', $this->session); 141 if (null == $this->dispatcher) { 142 $this->dispatcher = stubEventDispatcher::getInstance(); 143 } 144 $this->dispatcher->trigger(self::SESSION_EVENT_NAME, $this->session, array(), true); 120 145 121 146 $this->response = new stubBaseResponse(); trunk/src/test/php/net/stubbles/websites/stubFrontControllerInjectionMapTestCase.php
r399 r419 16 16 Mock::generate('stubRegistryInitializer'); 17 17 Mock::generate('stubXJConfFacade'); 18 Mock::generate('stubEventListener'); 18 19 require_once dirname(__FILE__) . '/TeststubFrontController.php'; 19 20 class TeststubSessionName extends stubAbstractSession … … 77 78 stubRegistry::setConfig('net.stubbles.ipo.request.class', null); 78 79 stubRegistry::setConfig('net.stubbles.ipo.session.class', null); 80 $dispatcher = stubEventDispatcher::getInstance(); 81 $mockEventListener = new MockstubEventListener(); 82 $mockEventListener->expectOnce('handleEvent'); 83 $mockEventListener->expectOnce('autoremove'); 84 $mockEventListener->setReturnValue('autoremove', true); 85 $dispatcher->clearQueuedEvents(); 86 $dispatcher->register($mockEventListener, stubFrontController::SESSION_EVENT_NAME); 79 87 $injectionMap = $this->frontController->getInjectionMap(); 80 88 $this->assertTrue($injectionMap->getInjection('stubRequest') instanceof stubWebRequest); 81 89 $this->assertTrue($injectionMap->getInjection('stubSession') instanceof stubPHPSession); 82 90 $this->assertTrue($injectionMap->getInjection('stubResponse') instanceof stubBaseResponse); 91 $dispatcher->remove($mockEventListener, stubFrontController::SESSION_EVENT_NAME); 83 92 } 84 93 … … 89 98 { 90 99 stubRegistry::setConfig('net.stubbles.ipo.session.class', 'TeststubSessionName'); 100 $dispatcher = stubEventDispatcher::getInstance(__CLASS__); 101 $this->frontController->setEventDispatcher($dispatcher); 102 $mockEventListener = new MockstubEventListener(); 103 $mockEventListener->expectOnce('handleEvent'); 104 $mockEventListener->expectOnce('autoremove'); 105 $mockEventListener->setReturnValue('autoremove', true); 106 $dispatcher->clearQueuedEvents(); 107 $dispatcher->register($mockEventListener, stubFrontController::SESSION_EVENT_NAME); 91 108 $injectionMap = $this->frontController->getInjectionMap(); 92 109 $this->assertTrue($injectionMap->getInjection('stubRequest') instanceof MockstubRequest); 93 110 $this->assertTrue($injectionMap->getInjection('stubSession') instanceof TeststubSessionName); 94 111 $this->assertEqual($injectionMap->getInjection('stubSession')->getSessionName(), 'SID'); 112 $dispatcher->remove($mockEventListener, stubFrontController::SESSION_EVENT_NAME); 113 stubEventDispatcher::destroyInstance(__CLASS__); 95 114 } 96 115
