Skip to content

Commit

Permalink
test: added tests for Session class (#3202)
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Nov 2, 2024
1 parent bfb3d3d commit 40d24b2
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/phpMyFAQ/Auth/EntraId/SessionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace phpMyFAQ\Auth\EntraId;

use phpMyFAQ\Configuration;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Session\Session as SymfonySession;

class SessionTest extends TestCase
{
private Configuration $configurationMock;
private SymfonySession $sessionMock;
private Session $session;

protected function setUp(): void
{
$this->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
);
}
}

0 comments on commit 40d24b2

Please sign in to comment.