Changeset 376
- Timestamp:
- 03/14/07 10:36:27 (1 year ago)
- Files:
-
- trunk/src/main/php/net/stubbles/ipo/session/stubAbstractSession.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/ipo/session/stubPHPSession.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/ipo/session/stubAbstractSessionTestCase.php (modified) (2 diffs)
- trunk/src/test/php/net/stubbles/ipo/session/stubPHPSessionTestCase.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/ipo/session/stubAbstractSession.php
r374 r376 150 150 } 151 151 152 /** 153 * resets the session and deletes all session data 154 * 155 * @return int 156 */ 157 public function reset() 158 { 159 $valueKeys = $this->getValueKeys(); 160 $count = 0; 161 foreach ($valueKeys as $valueKey) { 162 if (stubSession::NEXT_TOKEN == $valueKey || stubSession::FINGERPRINT == $valueKey) { 163 continue; 164 } 165 166 if (stubSession::START_TIME == $valueKey) { 167 $this->putValue(stubSession::START_TIME, time()); 168 continue; 169 } 170 171 $count += (int) $this->doRemoveValue($valueKey); 172 } 173 174 return $count; 175 } 176 152 177 /** 153 178 * returns a value associated with the key or the default value trunk/src/main/php/net/stubbles/ipo/session/stubPHPSession.php
r374 r376 80 80 @session_start(); 81 81 } 82 83 /** 84 * resets the session and deletes all session data 85 * 86 * @return int 87 */ 88 public function reset() 89 { 90 $nextToken = $_SESSION[stubSession::NEXT_TOKEN]; 91 $_SESSION = array(stubSession::START_TIME => time(), 92 stubSession::FINGERPRINT => $this->getFingerprint(), 93 stubSession::NEXT_TOKEN => $nextToken 94 ); 95 } 96 82 97 83 /** 98 84 * stores a value associated with the key trunk/src/test/php/net/stubbles/ipo/session/stubAbstractSessionTestCase.php
r374 r376 36 36 public function regenerateID() { $this->id = 'foo'; } 37 37 38 public function invalidate() { $this->reset(); } 39 40 public function reset() { $this->data = array(); } 38 public function invalidate() { $this->data = array(); } 41 39 42 40 public function putValue($key, $value) { $this->data[$key] = $value; } … … 182 180 $this->assertNotEqual($this->session->getCurrentToken(),'dummy'); 183 181 } 182 183 /** 184 * test that resetting the session removes all stored values but does not 185 * make the session invalid 186 */ 187 public function testReset() 188 { 189 $this->session->putValue('foo', 'baz'); 190 $nextToken = $this->session->getNextToken(); 191 $this->assertEqual($this->session->reset(), 1); 192 $this->assertTrue($this->session->isValid()); 193 $this->assertEqual($this->session->getNextToken(), $nextToken); 194 $this->assertFalse($this->session->hasValue('foo')); 195 } 184 196 } 185 197 ?> trunk/src/test/php/net/stubbles/ipo/session/stubPHPSessionTestCase.php
r374 r376 66 66 $this->assertFalse($this->session->isValid()); 67 67 } 68 69 /** 70 * test that resetting the session removes all stored values but does not 71 * make the session invalid 72 */ 73 public function testReset() 74 { 75 $this->session->putValue('foo', 'baz'); 76 $nextToken = $this->session->getNextToken(); 77 $this->session->reset(); 78 $this->assertTrue($this->session->isValid()); 79 $this->assertEqual($this->session->getNextToken(), $nextToken); 80 $this->assertFalse($this->session->hasValue('foo')); 81 } 82 68 83 69 /** 84 70 * test getting a value from session
