Permalink
Browse files

Fix clear(). Add test cases.

  • Loading branch information...
dereuromark committed Jan 28, 2015
1 parent 35e0dc2 commit 611889235a001b9dc22f3dc8921c20f27f86f545
@@ -374,7 +374,7 @@ public static function userAgent($userAgent = null) {
*
* @param string|null $name The name of the session variable (or a path as sent to Set.extract)
* @return mixed The value of the session variable, null if session not available,
* session not started, or provided name not found in the session.
* session not started, or provided name not found in the session, false on failure.
*/
public static function read($name = null) {
if (empty($name) && $name !== null) {
@@ -478,11 +478,14 @@ public static function destroy() {
* @return void
*/
public static function clear($renew = true) {
$_SESSION = null;
if ($renew) {
self::$id = null;
self::renew();
if (!$renew) {
$_SESSION = array();
return;
}
$_SESSION = null;
self::$id = null;
self::renew();
}
/**
@@ -413,6 +413,14 @@ public function testClear() {
TestCakeSession::clear(false);
$this->assertFalse(TestCakeSession::check('Delete.me'));
$this->assertFalse(TestCakeSession::check('Delete'));
TestCakeSession::write('Some.string', 'value');
TestCakeSession::clear(false);
$this->assertNull(TestCakeSession::read('Some'));
TestCakeSession::write('Some.string.array', array('values'));
TestCakeSession::clear(false);
$this->assertFalse(TestCakeSession::read());
}
/**

0 comments on commit 6118892

Please sign in to comment.