From 40d24b26ee638a5b02593bd7fd293332db5743a6 Mon Sep 17 00:00:00 2001 From: Thorsten Rinne Date: Sat, 2 Nov 2024 18:10:08 +0100 Subject: [PATCH] test: added tests for Session class (#3202) --- tests/phpMyFAQ/Auth/EntraId/SessionTest.php | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/phpMyFAQ/Auth/EntraId/SessionTest.php diff --git a/tests/phpMyFAQ/Auth/EntraId/SessionTest.php b/tests/phpMyFAQ/Auth/EntraId/SessionTest.php new file mode 100644 index 0000000000..2f6ab4d5b7 --- /dev/null +++ b/tests/phpMyFAQ/Auth/EntraId/SessionTest.php @@ -0,0 +1,48 @@ +configurationMock = $this->createMock(Configuration::class); + $this->sessionMock = $this->createMock(SymfonySession::class); + $this->session = new Session($this->configurationMock, $this->sessionMock); + } + + public function testCreateCurrentSessionKey(): void + { + $this->session->createCurrentSessionKey(); + $this->assertNotNull($this->session->getCurrentSessionKey()); + } + + public function testGetCurrentSessionKey(): void + { + $this->session->createCurrentSessionKey(); + $this->assertEquals($this->session->getCurrentSessionKey(), $this->session->getCurrentSessionKey()); + } + + public function testSetCurrentSessionKey(): void + { + $this->session->setCurrentSessionKey(); + $this->assertNotNull($this->session->getCurrentSessionKey()); + } + + public function testUuid(): void + { + $uuid = $this->session->uuid(); + $this->assertMatchesRegularExpression( + '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', + $uuid + ); + } +}