-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,9 @@ class ExistsDestroyCest | |
public function sessionManagerExistsDestroy(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Session\Manager - exists()/destroy()'); | ||
$store = $_SESSION ?? []; | ||
$_SESSION = []; | ||
|
||
$manager = new Manager(); | ||
$files = $this->getSessionStream(); | ||
$manager->setAdapter($files); | ||
|
@@ -46,6 +49,8 @@ public function sessionManagerExistsDestroy(IntegrationTester $I) | |
|
||
$actual = $manager->exists(); | ||
$I->assertFalse($actual); | ||
|
||
$_SESSION = $store; | ||
} | ||
|
||
/** | ||
|
@@ -60,6 +65,9 @@ public function sessionManagerExistsDestroy(IntegrationTester $I) | |
public function sessionManagerDestroySuperGlobal(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Session\Manager - destroy() - clean $_SESSION'); | ||
$store = $_SESSION ?? []; | ||
$_SESSION = []; | ||
|
||
$manager = new Manager(); | ||
$files = $this->getSessionStream(); | ||
$manager->setAdapter($files); | ||
|
@@ -71,13 +79,57 @@ public function sessionManagerDestroySuperGlobal(IntegrationTester $I) | |
$I->assertTrue($actual); | ||
|
||
$manager->set('test1', __METHOD__); | ||
$I->assertArrayHasKey('#test1', $_SESSION); | ||
$I->assertContains(__METHOD__, $_SESSION['#test1']); | ||
$I->assertArrayHasKey('test1', $_SESSION); | ||
$I->assertContains(__METHOD__, $_SESSION['test1']); | ||
|
||
$manager->destroy(); | ||
$I->assertArrayNotHasKey('#test1', $_SESSION); | ||
$I->assertArrayNotHasKey('test1', $_SESSION); | ||
|
||
$actual = $manager->exists(); | ||
$I->assertFalse($actual); | ||
|
||
$_SESSION = $store; | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Session\Manager :: destroy() - clean $_SESSION with uniquid | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2020-01-06 | ||
*/ | ||
public function sessionManagerDestroySuperGlobalUniquid(IntegrationTester $I) | ||
{ | ||
$I->wantToTest('Session\Manager - destroy() - clean $_SESSION with uniquid'); | ||
|
||
$store = $_SESSION ?? []; | ||
$_SESSION = []; | ||
|
||
$manager = new Manager(); | ||
$files = $this->getSessionStream(); | ||
$manager->setAdapter($files); | ||
$manager->setOptions( | ||
[ | ||
'uniqueId' => 'aaa' | ||
] | ||
); | ||
|
||
$actual = $manager->start(); | ||
$I->assertTrue($actual); | ||
|
||
$actual = $manager->exists(); | ||
$I->assertTrue($actual); | ||
|
||
$manager->set('test1', __METHOD__); | ||
|
||
$I->assertArrayHasKey('aaa#test1', $_SESSION); | ||
$I->assertContains(__METHOD__, $_SESSION['aaa#test1']); | ||
|
||
$manager->destroy(); | ||
$I->assertArrayNotHasKey('aaa#test1', $_SESSION); | ||
|
||
$actual = $manager->exists(); | ||
$I->assertFalse($actual); | ||
|
||
$_SESSION = $store; | ||
} | ||
} |