-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPCuSessionHandlerTest.php
More file actions
62 lines (51 loc) · 1.61 KB
/
Copy pathAPCuSessionHandlerTest.php
File metadata and controls
62 lines (51 loc) · 1.61 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Detain\SessionSamuraiTest;
use PHPUnit\Framework\TestCase;
use Detain\SessionSamurai\APCuSessionHandler;
/**
* @requires extension apcu
*/
class APCuSessionHandlerTest extends TestCase
{
private APCuSessionHandler $handler;
public function setUp(): void
{
$this->handler = new APCuSessionHandler();
}
public function testConstructor()
{
$this->assertInstanceOf(\SessionHandlerInterface::class, $this->handler);
$this->assertInstanceOf(\SessionIdInterface::class, $this->handler);
$this->assertInstanceOf(\SessionUpdateTimestampHandlerInterface::class, $this->handler);
}
public function testOpen()
{
$this->assertTrue($this->handler->open(__DIR__, 'test'));
}
public function testClose()
{
$this->assertTrue($this->handler->close());
}
public function testReadMissing()
{
$this->assertSame('', $this->handler->read('nonexistent_key_' . bin2hex(random_bytes(8))));
}
public function testWriteRead()
{
$string = '{"foo": "bar"}';
$key = 'test_apcu_' . bin2hex(random_bytes(4));
$this->assertTrue($this->handler->write($key, $string));
$this->assertSame($string, $this->handler->read($key));
}
public function testDestroy()
{
$key = 'test_apcu_' . bin2hex(random_bytes(4));
$this->handler->write($key, 'testvalue');
$this->assertTrue($this->handler->destroy($key));
$this->assertSame('', $this->handler->read($key));
}
public function testGc()
{
$this->assertNotFalse($this->handler->gc(0));
}
}