You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
62 lines
1.5 KiB
<?php declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use BradyMcD\TAATP\Session\Base as BaseSession;
|
|
|
|
/** @SuppressWarnings(PHPMD.ShortVariable)*/
|
|
final class SessionTest extends TestCase
|
|
{
|
|
private static $session;
|
|
|
|
private static $k1;
|
|
private static $v1;
|
|
private static $v2;
|
|
|
|
public static function setUpBeforeClass(): void
|
|
{
|
|
self::$session = new BaseSession();
|
|
|
|
self::$k1 = 'testKey';
|
|
self::$v1 = 'some important data';
|
|
self::$v2 = 'some other more or less important data';
|
|
}
|
|
|
|
public function testSessionIsLive(): void
|
|
{
|
|
$this->assertTrue(self::$session->live());
|
|
}
|
|
|
|
public function testValueOneStored(): void
|
|
{
|
|
self::$session->store(self::$k1, self::$v1);
|
|
|
|
$this->assertSame(self::$session->get(self::$k1), self::$v1);
|
|
}
|
|
|
|
public function testValueOneRetrieved(): void
|
|
{
|
|
$this->assertSame(self::$session->get(self::$k1), self::$v1);
|
|
}
|
|
|
|
public function testTryStoreDoesntOverwrite(): void
|
|
{
|
|
$this->assertFalse(self::$session->tryStore(self::$k1, self::$v2));
|
|
|
|
$this->assertSame(self::$session->get(self::$k1), self::$v1);
|
|
}
|
|
|
|
public function testStoreOverwrites(): void
|
|
{
|
|
self::$session->store(self::$k1, self::$v2);
|
|
|
|
$this->assertSame(self::$session->get(self::$k1), self::$v2);
|
|
}
|
|
|
|
public function testGetNonexistentValue(): void
|
|
{
|
|
$this->assertNull(self::$session->get('undefined'));
|
|
}
|
|
}
|
|
?>
|