|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OpCacheGUITest\Unit\Storage; |
|
4
|
|
|
|
|
5
|
|
|
use OpCacheGUI\Storage\InvalidKeyException; |
|
6
|
|
|
use OpCacheGUI\Storage\KeyValuePair; |
|
7
|
|
|
use OpCacheGUI\Storage\Regeneratable; |
|
8
|
|
|
use OpCacheGUI\Storage\Session; |
|
9
|
|
|
use PHPUnit\Framework\TestCase; |
|
10
|
|
|
|
|
11
|
|
|
class SessionTest extends TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
*/ |
|
15
|
|
|
public function testCorrectInterfaceKeyValuePair() |
|
16
|
|
|
{ |
|
17
|
|
|
$session = new Session(); |
|
18
|
|
|
|
|
19
|
|
|
$this->assertInstanceOf(KeyValuePair::class, $session); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testCorrectInterfaceRegeneratable() |
|
25
|
|
|
{ |
|
26
|
|
|
$session = new Session(); |
|
27
|
|
|
|
|
28
|
|
|
$this->assertInstanceOf(Regeneratable::class, $session); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @covers OpCacheGUI\Storage\Session::set |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testSet() |
|
35
|
|
|
{ |
|
36
|
|
|
$session = new Session(); |
|
37
|
|
|
|
|
38
|
|
|
$this->assertNull($session->set('key', 'value')); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @covers OpCacheGUI\Storage\Session::set |
|
43
|
|
|
* @covers OpCacheGUI\Storage\Session::isKeyValid |
|
44
|
|
|
* @covers OpCacheGUI\Storage\Session::get |
|
45
|
|
|
*/ |
|
46
|
|
|
public function testGetValid() |
|
47
|
|
|
{ |
|
48
|
|
|
$session = new Session(); |
|
49
|
|
|
$session->set('key', 'value'); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertSame('value', $session->get('key')); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @covers OpCacheGUI\Storage\Session::set |
|
56
|
|
|
* @covers OpCacheGUI\Storage\Session::isKeyValid |
|
57
|
|
|
* @covers OpCacheGUI\Storage\Session::get |
|
58
|
|
|
*/ |
|
59
|
|
|
public function testGetInvalid() |
|
60
|
|
|
{ |
|
61
|
|
|
$session = new Session(); |
|
62
|
|
|
$this->expectException(InvalidKeyException::class); |
|
63
|
|
|
|
|
64
|
|
|
$session->get('key'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @covers OpCacheGUI\Storage\Session::isKeyValid |
|
69
|
|
|
*/ |
|
70
|
|
|
public function testIsKeyValidFail() |
|
71
|
|
|
{ |
|
72
|
|
|
$session = new Session(); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertFalse(false, $session->isKeyValid('unknownkey')); |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @covers OpCacheGUI\Storage\Session::set |
|
79
|
|
|
* @covers OpCacheGUI\Storage\Session::isKeyValid |
|
80
|
|
|
*/ |
|
81
|
|
|
public function testIsKeyValidSuccess() |
|
82
|
|
|
{ |
|
83
|
|
|
$session = new Session(); |
|
84
|
|
|
$session->set('key', 'value'); |
|
85
|
|
|
|
|
86
|
|
|
$this->assertTrue($session->isKeyValid('key')); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: