X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Fsecurity%2FSessionManagerTest.php;h=d9db775efc59fd2a4b9b8e4accbba69788f6534e;hb=af290059d10319e76d1e7d78b592cab99c26d91a;hp=f264505eaefa81159e7cf1af14fb01b22b60f027;hpb=893f5159c64e5bcff505c8367e6dc22cc2a7b14d;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/security/SessionManagerTest.php b/tests/security/SessionManagerTest.php index f264505e..d9db775e 100644 --- a/tests/security/SessionManagerTest.php +++ b/tests/security/SessionManagerTest.php @@ -269,4 +269,61 @@ class SessionManagerTest extends TestCase $this->session['ip'] = 'ip_id_one'; $this->assertTrue($this->sessionManager->hasClientIpChanged('ip_id_two')); } + + /** + * Test creating an entry in the session array + */ + public function testSetSessionParameterCreate(): void + { + $this->sessionManager->setSessionParameter('abc', 'def'); + + static::assertSame('def', $this->session['abc']); + } + + /** + * Test updating an entry in the session array + */ + public function testSetSessionParameterUpdate(): void + { + $this->session['abc'] = 'ghi'; + + $this->sessionManager->setSessionParameter('abc', 'def'); + + static::assertSame('def', $this->session['abc']); + } + + /** + * Test updating an entry in the session array with null value + */ + public function testSetSessionParameterUpdateNull(): void + { + $this->session['abc'] = 'ghi'; + + $this->sessionManager->setSessionParameter('abc', null); + + static::assertArrayHasKey('abc', $this->session); + static::assertNull($this->session['abc']); + } + + /** + * Test deleting an existing entry in the session array + */ + public function testDeleteSessionParameter(): void + { + $this->session['abc'] = 'def'; + + $this->sessionManager->deleteSessionParameter('abc'); + + static::assertArrayNotHasKey('abc', $this->session); + } + + /** + * Test deleting a non existent entry in the session array + */ + public function testDeleteSessionParameterNotExisting(): void + { + $this->sessionManager->deleteSessionParameter('abc'); + + static::assertArrayNotHasKey('abc', $this->session); + } }