mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing some infinite loop issues in the test cases for CakeSession.
This commit is contained in:
parent
b3febb483e
commit
6ff7ad68c9
2 changed files with 16 additions and 21 deletions
|
@ -490,9 +490,11 @@ class CakeSession {
|
|||
* @return void
|
||||
*/
|
||||
public static function destroy() {
|
||||
if (self::started()) {
|
||||
session_destroy();
|
||||
}
|
||||
$_SESSION = null;
|
||||
self::$id = null;
|
||||
self::init(self::$path);
|
||||
self::start();
|
||||
self::renew();
|
||||
}
|
||||
|
@ -698,6 +700,7 @@ class CakeSession {
|
|||
if (self::read('Config')) {
|
||||
$sessionConfig = Configure::read('Session');
|
||||
$checkAgent = isset($sessionConfig['checkAgent']) && $sessionConfig['checkAgent'] === true;
|
||||
|
||||
if (
|
||||
($checkAgent && self::$_userAgent == self::read('Config.userAgent')) &&
|
||||
self::$time <= self::read('Config.time')
|
||||
|
|
|
@ -87,9 +87,7 @@ class CakeSessionTest extends CakeTestCase {
|
|||
'cookieTimeout' => 120,
|
||||
'ini' => array(),
|
||||
));
|
||||
|
||||
TestCakeSession::init();
|
||||
TestCakeSession::destroy();
|
||||
TestCakeSession::$watchKeys = array();
|
||||
}
|
||||
|
||||
|
@ -101,6 +99,9 @@ class CakeSessionTest extends CakeTestCase {
|
|||
*/
|
||||
function teardown() {
|
||||
parent::teardown();
|
||||
if (TestCakeSession::started()) {
|
||||
CakeSession::destroy();
|
||||
}
|
||||
unset($_SESSION);
|
||||
@session_destroy();
|
||||
}
|
||||
|
@ -111,11 +112,12 @@ class CakeSessionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testSessionConfigIniSetting() {
|
||||
$_SESSION = null;
|
||||
session_destroy();
|
||||
$_SESSION = null;
|
||||
|
||||
Configure::write('Session', array(
|
||||
'cookie' => 'test_suite',
|
||||
'checkAgent' => false,
|
||||
'timeout' => 86400,
|
||||
'ini' => array(
|
||||
'session.referer_check' => 'example.com',
|
||||
|
@ -535,11 +537,10 @@ class CakeSessionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testReadAndWriteWithCakeStorage() {
|
||||
session_write_close();
|
||||
Configure::write('Session.defaults', 'cake');
|
||||
|
||||
TestCakeSession::init();
|
||||
TestCakeSession::destroy();
|
||||
TestCakeSession::start();
|
||||
|
||||
TestCakeSession::write('SessionTestCase', 0);
|
||||
$this->assertEqual(TestCakeSession::read('SessionTestCase'), 0);
|
||||
|
@ -618,7 +619,6 @@ class CakeSessionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testReadAndWriteWithCacheStorage() {
|
||||
session_write_close();
|
||||
Configure::write('Session.defaults', 'cache');
|
||||
|
||||
TestCakeSession::init();
|
||||
|
@ -654,7 +654,6 @@ class CakeSessionTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testReadAndWriteWithCustomCacheConfig() {
|
||||
session_write_close();
|
||||
Configure::write('Session.defaults', 'cache');
|
||||
Configure::write('Session.handler.config', 'session_test');
|
||||
|
||||
|
@ -664,19 +663,13 @@ class CakeSessionTest extends CakeTestCase {
|
|||
));
|
||||
|
||||
TestCakeSession::init();
|
||||
TestCakeSession::destroy();
|
||||
TestCakeSession::start();
|
||||
|
||||
TestCakeSession::write('SessionTestCase', 'Some value');
|
||||
$this->assertEquals('Some value', TestCakeSession::read('SessionTestCase'));
|
||||
$id = TestCakeSession::id();
|
||||
|
||||
session_write_close();
|
||||
|
||||
$this->assertContains('Some value', Cache::read(TestCakeSession::id(), 'session_test'));
|
||||
$this->assertFalse(Cache::read(TestCakeSession::id(), 'default'));
|
||||
|
||||
TestCakeSession::destroy();
|
||||
Cache::delete(TestCakeSession::id(), 'session_test');
|
||||
Cache::drop('session_test');
|
||||
Cache::delete($id, 'session_test');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -692,7 +685,7 @@ class CakeSessionTest extends CakeTestCase {
|
|||
Configure::write('Session.handler.database', 'test_suite');
|
||||
|
||||
TestCakeSession::init();
|
||||
TestCakeSession::destroy();
|
||||
TestCakeSession::start();
|
||||
|
||||
TestCakeSession::write('SessionTestCase', 0);
|
||||
$this->assertEqual(TestCakeSession::read('SessionTestCase'), 0);
|
||||
|
@ -715,7 +708,6 @@ class CakeSessionTest extends CakeTestCase {
|
|||
|
||||
TestCakeSession::destroy();
|
||||
$this->assertNull(TestCakeSession::read('SessionTestCase'));
|
||||
session_write_close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue