Started working on Cache testing

This commit is contained in:
Florian Bouillon 2019-04-18 00:44:00 +02:00
parent 1207b91536
commit 5120088706

View File

@ -0,0 +1,89 @@
<?php
use PHPUnit\Framework\TestCase;
use AdminPanel\Cache\SessionCache;
final class SessionCacheTest extends TestCase
{
private $session;
public function __construct()
{
parent::__construct();
$this->session = new SessionCache();
}
public function testCacheCanStart()
{
$this->assertEquals(
session_status(),
PHP_SESSION_ACTIVE
);
}
public function testCanSet()
{
$this->assertEquals(
true,
$this->session->set("key", "value")
);
}
public function testCanGet()
{
$this->assertTrue(
$this->session->set("key", "value")
);
$this->assertEquals(
'value',
$this->session->get('key')
);
}
public function testCanDelete()
{
$this->assertTrue(
$this->session->set("key", "value")
);
$this->assertTrue(
$this->session->delete('key')
);
$this->assertNull(
$this->session->get('key')
);
}
public function testCanSetGetMultiple()
{
$this->assertTrue(
$this->session->setMultiple(array(
"key1" => "value",
"key2" => "value"
))
);
$result = $this->session->getMultiple(array(
"key1",
"key2"
));
$this->assertEquals(
"value",
$result["key1"]
);
$this->assertEquals(
"value",
$result["key2"]
);
$this->assertTrue(
$this->session->deleteMultiple(array(
"key1",
"key2"
))
);
}
}