-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathArrayCacheTest.php
More file actions
42 lines (35 loc) · 1.06 KB
/
ArrayCacheTest.php
File metadata and controls
42 lines (35 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
use Openapi\Cache\ArrayCache;
use PHPUnit\Framework\TestCase;
final class ArrayCacheTest extends TestCase
{
private ArrayCache $cache;
protected function setUp(): void
{
$this->cache = new ArrayCache();
}
public function testCacheImplementation(): void
{
$this->cache->save('key1', 'value1', 3600);
$this->assertEquals('value1', $this->cache->get('key1'));
}
public function testCacheExpiration(): void
{
$this->cache->save('key2', 'value2', -1);
$this->assertNull($this->cache->get('key2'));
}
public function testCacheDelete(): void
{
$this->cache->save('key3', 'value3', 3600);
$this->cache->delete('key3');
$this->assertNull($this->cache->get('key3'));
}
public function testCacheClear(): void
{
$this->cache->save('key4', 'value4', 3600);
$this->cache->save('key5', 'value5', 3600);
$this->cache->clear();
$this->assertNull($this->cache->get('key4'));
$this->assertNull($this->cache->get('key5'));
}
}