Changeset 272
- Timestamp:
- 02/16/07 12:59:42 (1 year ago)
- Files:
-
- trunk/docroot/index.php (modified) (1 diff)
- trunk/docroot/xml.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/session/stubBaseSession.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/ipo/session/stubBaseSessionTestCase.php (modified) (4 diffs)
- trunk/src/test/php/net/stubbles/ipo/session/stubPHPSessionTestCase.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docroot/index.php
r263 r272 11 11 { 12 12 $request = stubBaseRequest::getInstance('Web'); 13 $session = stubBaseSession::getInstance('PHP','stubSID');13 $session = new stubPHPSession('stubSID'); 14 14 $processor = new stubMemphisPageProcessor($request, $session); 15 15 $processor->process()->getResponse()->send(); trunk/docroot/xml.php
r270 r272 20 20 } 21 21 $request = stubBaseRequest::getInstance('Web'); 22 $session = stubBaseSession::getInstance('PHP','stubSID');22 $session = new stubPHPSession('stubSID'); 23 23 $processor = new stubXMLProcessor($request, $session); 24 24 $postInterceptor = new stubXMLPagePostInterceptor(); trunk/src/main/php/net/stubbles/ipo/session/stubBaseSession.php
r153 r272 46 46 * @param string $sessionName name of the session 47 47 */ 48 p rotectedfinal function __construct($sessionName)48 public final function __construct($sessionName) 49 49 { 50 50 $this->doConstruct($sessionName); … … 83 83 */ 84 84 protected abstract function getFingerprint(); 85 86 /** 87 * returns the required instance 88 * 89 * @param string $type 90 * @param string $sessionName name of the session 91 * @return stubBaseSession 92 * @throws stubSessionException 93 */ 94 public static function getInstance($type, $sessionName) 95 { 96 if (null !== self::$instance) { 97 return self::$instance; 98 } 99 100 $className = 'stub' . $type . 'Session'; 101 if (class_exists($className) == false) { 102 throw new stubSessionException('Unknown session type ' . $type); 103 } 104 105 self::$instance = new $className($sessionName); 106 return self::$instance; 107 } 108 85 109 86 /** 110 87 * cloning is forbidden … … 114 91 protected final function __clone() 115 92 { 116 throw new stubSessionException(' Session is in an invalid state.');93 throw new stubSessionException('Cloning the session is somewhat... useless.'); 117 94 } 118 95 trunk/src/test/php/net/stubbles/ipo/session/stubBaseSessionTestCase.php
r153 r272 12 12 protected $id = 'test'; 13 13 protected $data = array(); 14 15 public function destroy() { parent::$instance = null; }16 14 17 15 protected function doConstruct($sessionName) … … 71 69 public function setUp() 72 70 { 73 // bugfix for simpletest: tearDown() not called if an expected session 74 // was thrown within a test method 75 if (is_object($this->session) == true) { 76 $this->session->destroy(); 77 } 78 $this->session = stubBaseSession::getInstance('Test', ''); 71 $this->session = new stubTestSession(''); 79 72 } 80 81 /** 82 * clear test environment 83 */ 84 public function tearDown() 85 { 86 $this->session->destroy(); 87 } 88 73 89 74 /** 90 75 * test with default values … … 100 85 $nextToken = $this->session->getNextToken(); 101 86 102 $session = stubBaseSession::getInstance('Test', ''); 103 $this->assertReference($this->session, $session); 104 $this->assertTrue($session->isNew()); 105 $session->destroy(); 106 107 $this->session->destroy(); 108 $this->session = stubBaseSession::getInstance('Test', $startTime . '|foobarbaz|' . $nextToken); 87 $this->session = new stubTestSession($startTime . '|foobarbaz|' . $nextToken); 109 88 $this->assertEqual($this->session->getStartTime(), $startTime); 110 89 $this->assertFalse($this->session->isNew()); … … 196 175 public function testSessionHijacking() 197 176 { 198 $this->session->destroy();199 177 // original session started at 50 with fingerprint blub 200 $this->session = stubBaseSession::getInstance('Test','50|blub|dummy');178 $this->session = new stubTestSession('50|blub|dummy'); 201 179 $this->assertTrue($this->session->isNew()); 202 180 $this->assertNotEqual($this->session->getStartTime(), 50); trunk/src/test/php/net/stubbles/ipo/session/stubPHPSessionTestCase.php
r157 r272 8 8 */ 9 9 stubClassLoader::load('net.stubbles.ipo.session.stubPHPSession'); 10 class stubTestPHPSession extends stubPHPSession11 {12 public function destroy() { $this->invalidate(); parent::$instance = null; }13 }14 10 /** 15 11 * Tests for net.stubbles.ipo.session.stubPHPSession … … 38 34 public function setUp() 39 35 { 40 // bugfix for simpletest: tearDown() not called if an expected session41 // was thrown within a test method42 if (is_object($this->session) == true) {43 $this->session->destroy();44 }45 46 36 if (isset($_SERVER['HTTP_USER_AGENT']) == false) { 47 37 $_SERVER['HTTP_USER_AGENT'] = 'dummy for preventing E_NOTICE in cli mode.'; … … 49 39 } 50 40 51 $this->session = stubBaseSession::getInstance('TestPHP', 'test'); 41 $_SESSION = array(); 42 $this->session = new stubPHPSession('test'); 52 43 } 53 44 … … 57 48 public function tearDown() 58 49 { 59 $this->session->destroy();60 50 if (true == $this->userAgentSet) { 61 51 unset($_SERVER['HTTP_USER_AGENT']);
