mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +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()) {
|
||||
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();
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue