Adding CakeSession::clear() which is primarily useful when testing, and offers an alternative to using CakeSession::destroy()

This commit is contained in:
mark_story 2010-09-29 23:01:23 -04:00
parent 597058bab5
commit 72a1c959a1
2 changed files with 15 additions and 4 deletions

View file

@ -471,6 +471,15 @@ class CakeSession {
if (self::started()) {
session_destroy();
}
self::clear();
}
/**
* Clears the session, the session id, and renew's the session.
*
* @return void
*/
public static function clear() {
$_SESSION = null;
self::$id = null;
self::start();

View file

@ -99,10 +99,9 @@ class CakeSessionTest extends CakeTestCase {
*/
function teardown() {
if (TestCakeSession::started()) {
TestCakeSession::destroy();
TestCakeSession::clear();
}
unset($_SESSION);
@session_destroy();
parent::teardown();
}
@ -112,7 +111,6 @@ class CakeSessionTest extends CakeTestCase {
* @return void
*/
function testSessionConfigIniSetting() {
session_destroy();
$_SESSION = null;
Configure::write('Session', array(
@ -708,6 +706,11 @@ class CakeSessionTest extends CakeTestCase {
TestCakeSession::destroy();
$this->assertNull(TestCakeSession::read('SessionTestCase'));
Configure::write('Session', array(
'defaults' => 'php'
));
TestCakeSession::init();
}
/**
@ -722,7 +725,6 @@ class CakeSessionTest extends CakeTestCase {
$timeoutSeconds = Configure::read('Session.timeout') * 60;
session_destroy();
TestCakeSession::destroy();
TestCakeSession::write('Test', 'some value');