-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpCacheSessionHandlerTest.php
More file actions
79 lines (64 loc) · 1.92 KB
/
Copy pathOpCacheSessionHandlerTest.php
File metadata and controls
79 lines (64 loc) · 1.92 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Detain\SessionSamuraiTest;
use PHPUnit\Framework\TestCase;
use Detain\SessionSamurai\OpCacheSessionHandler;
// include your OPCache Session Handler here
class OpCacheSessionHandlerTest extends TestCase
{
/**
* @var OPCacheSessionHandler
*/
protected $handler;
public function setUp(): void
{
$this->handler = new OpCacheSessionHandler();
}
public function testSessionOpen()
{
$this->assertTrue($this->handler->open('test', 'test'));
}
public function testSessionClose()
{
$this->assertTrue($this->handler->close());
}
public function testRead()
{
$this->assertEquals('', $this->handler->read('test'));
}
public function testWrite()
{
$data = json_encode(['data' => 'hello world']);
$this->assertTrue($this->handler->write('test', $data));
$read = $this->handler->read('test');
$this->assertEquals($data, $read);
}
public function testDestroy()
{
$this->assertTrue($this->handler->destroy('test'));
}
public function testGc()
{
$this->assertNotFalse($this->handler->gc(100));
}
// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
public function testCreate_sid()
{
$sid = $this->handler->create_sid();
$this->assertIsString($sid);
}
public function testValidateId()
{
$sid = $this->handler->create_sid();
$this->handler->write($sid, 'data');
$this->assertTrue($this->handler->validateId($sid));
$this->assertFalse($this->handler->validateId('nonexistentsession'));
$this->handler->destroy($sid);
}
public function testUpdateTimestamp()
{
$sid = $this->handler->create_sid();
$this->handler->write($sid, 'data');
$this->assertTrue($this->handler->updateTimestamp($sid, 'data'));
$this->handler->destroy($sid);
}
}