SiteWeaver_CMS/tests/unit/Core/SessionServiceTest.php

48 lines
1 KiB
PHP
Raw Normal View History

<?php
/**
* File: tests/unit/Core/SessionServiceTest.php
*
* Author: Funky Waddle
* Date: 2026-09-12
*
* Purpose:
* Unit tests for SessionService.
*/
declare(strict_types=1);
namespace Tests\unit\Core;
use SiteWeaver\Core\Services\SessionService;
use PHPUnit\Framework\TestCase;
final class SessionServiceTest extends TestCase
{
private SessionService $session;
protected function setUp(): void
{
$this->session = new SessionService();
$this->session->start();
}
protected function tearDown(): void
{
$this->session->destroy();
}
public function testSetGetRemoveDestroy(): void
{
// set value
$this->session->set('foo', 'bar');
$this->assertSame('bar', $this->session->get('foo'));
// remove key
$this->session->remove('foo');
$this->assertNull($this->session->get('foo'));
// destroy session
$this->session->set('baz', 'qux');
$this->session->destroy();
$this->assertEmpty($_SESSION);
}
}