Changeset 374
- Timestamp:
- 03/13/07 17:23:44 (1 year ago)
- Files:
-
- trunk/docroot/index.php (modified) (2 diffs)
- trunk/docroot/xml.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/session/stubAbstractSession.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/ipo/session/stubPHPSession.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/websites/stubFrontController.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/session/stubAbstractSessionTestCase.php (modified) (5 diffs)
- trunk/src/test/php/net/stubbles/ipo/session/stubPHPSessionTestCase.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/websites/stubFrontControllerInjectionMapTestCase.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docroot/index.php
r286 r374 5 5 'net.stubbles.websites.stubXJConfPageFactory', 6 6 'net.stubbles.ipo.request.stubWebRequest', 7 'net.stubbles.ipo.session.stubPHPSession' 7 'net.stubbles.ipo.session.stubPHPSession', 8 'net.stubbles.ipo.response.stubResponse' 8 9 ); 9 10 class Bootstrap … … 12 13 { 13 14 $request = new stubWebRequest(); 14 $session = new stubPHPSession( 'stubSID');15 $session = new stubPHPSession($request, 'stubSID'); 15 16 $pageFactory = new stubXJConfPageFactory(stubXJConfLoader::getInstance()); 16 $processor = new stubMemphisProcessor($request, $session, $pageFactory);17 $processor = new stubMemphisProcessor($request, $session, new stubBaseResponse(), $pageFactory); 17 18 $processor->process()->getResponse()->send(); 18 19 } trunk/docroot/xml.php
r348 r374 24 24 { 25 25 $request = new stubWebRequest(); 26 $session = new stubPHPSession( 'stubSID');26 $session = new stubPHPSession($request, 'stubSID'); 27 27 $response = new stubBaseResponse(); 28 28 $preInterceptor = new stubXMLPreInterceptor(); trunk/src/main/php/net/stubbles/ipo/session/stubAbstractSession.php
r291 r374 7 7 * @subpackage ipo_session 8 8 */ 9 stubClassLoader::load('net.stubbles.ipo.session.stubSession'); 9 stubClassLoader::load('net.stubbles.ipo.session.stubSession', 10 'net.stubbles.ipo.request.stubRequest' 11 ); 10 12 /** 11 13 * Base class for session implementations. … … 38 40 * constructor 39 41 * 40 * @param string $sessionName name of the session 41 */ 42 public final function __construct($sessionName) 43 { 44 $this->doConstruct($sessionName); 42 * @param stubRequest $request request instance 43 * @param string $sessionName name of the session 44 */ 45 public final function __construct(stubRequest $request, $sessionName) 46 { 47 $this->doConstruct($request, $sessionName); 45 48 46 49 if ($this->hasValue(stubSession::START_TIME) == false || $this->doGetValue(stubSession::FINGERPRINT) != $this->getFingerprint()) { … … 67 70 * template method for child classes to do the real construction 68 71 * 69 * @param string $sessionName name of the session 70 */ 71 protected abstract function doConstruct($sessionName); 72 * @param stubRequest $request request instance 73 * @param string $sessionName name of the session 74 */ 75 protected abstract function doConstruct(stubRequest $request, $sessionName); 72 76 73 77 /** trunk/src/main/php/net/stubbles/ipo/session/stubPHPSession.php
r291 r374 7 7 * @subpackage ipo_session 8 8 */ 9 stubClassLoader::load('net.stubbles.ipo.session.stubAbstractSession'); 9 stubClassLoader::load('net.stubbles.ipo.session.stubAbstractSession', 10 'net.stubbles.ipo.request.filters.stubMD5Filter' 11 ); 10 12 /** 11 13 * Session class using default PHP sessions. … … 21 23 { 22 24 /** 25 * the request instance 26 * 27 * @var stubRequest 28 */ 29 protected $request; 30 31 /** 23 32 * template method for child classes to do the real construction 24 33 * 25 * @param string $sessionName name of the session 34 * @param stubRequest $request request instance 35 * @param string $sessionName name of the session 26 36 */ 27 protected function doConstruct( $sessionName)37 protected function doConstruct(stubRequest $request, $sessionName) 28 38 { 39 $this->request = $request; 29 40 session_name($sessionName); 30 41 @session_start(); … … 35 46 * 36 47 * @return string 37 * @todo no direct access to $_SERVER38 48 * @todo configureable hidden salt 39 49 */ 40 50 protected function getFingerprint() 41 51 { 42 return md5($_SERVER['HTTP_USER_AGENT'] . 'foo');52 return $this->request->getFilteredValue(new stubMD5Filter('', 'foo'), 'HTTP_USER_AGENT', stubRequest::SOURCE_HEADER); 43 53 } 44 54 trunk/src/main/php/net/stubbles/websites/stubFrontController.php
r359 r374 114 114 } 115 115 116 $this->session = new $className( stubRegistry::getConfig('net.stubbles.ipo.session.name', 'SID'));116 $this->session = new $className($this->request, stubRegistry::getConfig('net.stubbles.ipo.session.name', 'SID')); 117 117 if (($this->session instanceof stubSession) == false) { 118 118 throw new stubException('Configured session class is not an instance of stubSession.'); trunk/src/test/php/net/stubbles/ipo/session/stubAbstractSessionTestCase.php
r291 r374 8 8 */ 9 9 stubClassLoader::load('net.stubbles.ipo.session.stubAbstractSession'); 10 Mock::generate('stubRequest'); 10 11 class stubTestSession extends stubAbstractSession 11 12 { … … 13 14 protected $data = array(); 14 15 15 protected function doConstruct( $sessionName)16 protected function doConstruct(stubRequest $request, $sessionName) 16 17 { 17 18 if (strlen($sessionName) > 1) { … … 69 70 public function setUp() 70 71 { 71 $this->session = new stubTestSession( '');72 $this->session = new stubTestSession(new MockstubRequest(), ''); 72 73 } 73 74 … … 85 86 $nextToken = $this->session->getNextToken(); 86 87 87 $this->session = new stubTestSession( $startTime . '|foobarbaz|' . $nextToken);88 $this->session = new stubTestSession(new MockstubRequest(), $startTime . '|foobarbaz|' . $nextToken); 88 89 $this->assertEqual($this->session->getStartTime(), $startTime); 89 90 $this->assertFalse($this->session->isNew()); … … 176 177 { 177 178 // original session started at 50 with fingerprint blub 178 $this->session = new stubTestSession( '50|blub|dummy');179 $this->session = new stubTestSession(new MockstubRequest(), '50|blub|dummy'); 179 180 $this->assertTrue($this->session->isNew()); 180 181 $this->assertNotEqual($this->session->getStartTime(), 50); trunk/src/test/php/net/stubbles/ipo/session/stubPHPSessionTestCase.php
r272 r374 8 8 */ 9 9 stubClassLoader::load('net.stubbles.ipo.session.stubPHPSession'); 10 Mock::generate('stubRequest'); 10 11 /** 11 12 * Tests for net.stubbles.ipo.session.stubPHPSession … … 23 24 protected $session; 24 25 /** 25 * switch whether user agent has been that by test26 * mocked request instance 26 27 * 27 * @var bool28 * @var SimpleMock 28 29 */ 29 protected $ userAgentSet = false;30 protected $mockStubRequest; 30 31 31 32 /** … … 34 35 public function setUp() 35 36 { 36 if (isset($_SERVER['HTTP_USER_AGENT']) == false) { 37 $_SERVER['HTTP_USER_AGENT'] = 'dummy for preventing E_NOTICE in cli mode.'; 38 $this->userAgentSet = true; 39 } 40 37 $this->mockStubRequest = new MockStubRequest(); 38 $this->mockStubRequest->setReturnValue('getFilteredValue', 'foobarbaz'); 41 39 $_SESSION = array(); 42 $this->session = new stubPHPSession( 'test');40 $this->session = new stubPHPSession($this->mockStubRequest, 'test'); 43 41 } 44 45 /** 46 * clear test environment 47 */ 48 public function tearDown() 49 { 50 if (true == $this->userAgentSet) { 51 unset($_SERVER['HTTP_USER_AGENT']); 52 $this->userAgentSet = false; 53 } 54 } 55 42 56 43 /** 57 44 * test that regenerating the id gives a new id for the session trunk/src/test/php/net/stubbles/websites/stubFrontControllerInjectionMapTestCase.php
r344 r374 7 7 * @subpackage websites_test 8 8 */ 9 stubClassLoader::load('net.stubbles.websites.stubFrontController'); 9 stubClassLoader::load('net.stubbles.websites.stubFrontController', 10 'net.stubbles.ipo.session.stubAbstractSession' 11 ); 10 12 Mock::generate('stubRequest'); 11 13 Mock::generate('stubSession'); … … 16 18 protected $sessionName; 17 19 18 protected function doConstruct( $sessionName)20 protected function doConstruct(stubRequest $request, $sessionName) 19 21 { 20 22 $this->sessionName = $sessionName; … … 51 53 */ 52 54 protected $frontController; 53 /**54 * switch whether user agent has been that by test55 *56 * @var bool57 */58 protected $userAgentSet = false;59 55 60 56 /** … … 64 60 { 65 61 $this->frontController = new TeststubFrontController(); 66 if (isset($_SERVER['HTTP_USER_AGENT']) == false) {67 $_SERVER['HTTP_USER_AGENT'] = 'dummy for preventing E_NOTICE in cli mode.';68 $this->userAgentSet = true;69 }70 71 62 stubRegistry::setConfig('net.stubbles.ipo.request.class', 'MockstubRequest'); 72 63 stubRegistry::setConfig('net.stubbles.ipo.session.class', 'MockstubSession'); 73 64 } 74 75 /** 76 * clear test environment 77 */ 78 public function tearDown() 79 { 80 if (true == $this->userAgentSet) { 81 unset($_SERVER['HTTP_USER_AGENT']); 82 $this->userAgentSet = false; 83 } 84 } 85 65 86 66 /** 87 67 * assure that properties are set and retrieved correct
