first commit
This commit is contained in:
40
tests/Shared/SessionManagerEdgeCasesTest.php
Normal file
40
tests/Shared/SessionManagerEdgeCasesTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Shared;
|
||||
|
||||
use App\Shared\Http\SessionManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SessionManagerEdgeCasesTest extends TestCase
|
||||
{
|
||||
private SessionManager $manager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$_SESSION = [];
|
||||
$this->manager = new SessionManager();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$_SESSION = [];
|
||||
}
|
||||
|
||||
public function testGetUserIdReturnsNullForEmptyString(): void
|
||||
{
|
||||
$_SESSION['user_id'] = '';
|
||||
|
||||
self::assertNull($this->manager->getUserId());
|
||||
self::assertFalse($this->manager->isAuthenticated());
|
||||
}
|
||||
|
||||
public function testSetUserUsesDefaultRoleUser(): void
|
||||
{
|
||||
$this->manager->setUser(12, 'julien');
|
||||
|
||||
self::assertSame('user', $_SESSION['role']);
|
||||
self::assertFalse($this->manager->isAdmin());
|
||||
self::assertFalse($this->manager->isEditor());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user