mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Adding CakeSession::clear() which is primarily useful when testing, and offers an alternative to using CakeSession::destroy()
This commit is contained in:
parent
597058bab5
commit
72a1c959a1
2 changed files with 15 additions and 4 deletions
|
@ -471,6 +471,15 @@ class CakeSession {
|
||||||
if (self::started()) {
|
if (self::started()) {
|
||||||
session_destroy();
|
session_destroy();
|
||||||
}
|
}
|
||||||
|
self::clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the session, the session id, and renew's the session.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function clear() {
|
||||||
$_SESSION = null;
|
$_SESSION = null;
|
||||||
self::$id = null;
|
self::$id = null;
|
||||||
self::start();
|
self::start();
|
||||||
|
|
|
@ -99,10 +99,9 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function teardown() {
|
function teardown() {
|
||||||
if (TestCakeSession::started()) {
|
if (TestCakeSession::started()) {
|
||||||
TestCakeSession::destroy();
|
TestCakeSession::clear();
|
||||||
}
|
}
|
||||||
unset($_SESSION);
|
unset($_SESSION);
|
||||||
@session_destroy();
|
|
||||||
parent::teardown();
|
parent::teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +111,6 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testSessionConfigIniSetting() {
|
function testSessionConfigIniSetting() {
|
||||||
session_destroy();
|
|
||||||
$_SESSION = null;
|
$_SESSION = null;
|
||||||
|
|
||||||
Configure::write('Session', array(
|
Configure::write('Session', array(
|
||||||
|
@ -708,6 +706,11 @@ class CakeSessionTest extends CakeTestCase {
|
||||||
|
|
||||||
TestCakeSession::destroy();
|
TestCakeSession::destroy();
|
||||||
$this->assertNull(TestCakeSession::read('SessionTestCase'));
|
$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;
|
$timeoutSeconds = Configure::read('Session.timeout') * 60;
|
||||||
|
|
||||||
session_destroy();
|
|
||||||
TestCakeSession::destroy();
|
TestCakeSession::destroy();
|
||||||
TestCakeSession::write('Test', 'some value');
|
TestCakeSession::write('Test', 'some value');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue