These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Tests; |
||
3 | |||
4 | /** |
||
5 | * RegistryTest |
||
6 | * |
||
7 | * @since 2.1.0 |
||
8 | * |
||
9 | * @package Redaxscript |
||
10 | * @category Tests |
||
11 | * @author Henry Ruhs |
||
12 | * @author Gary Aylward |
||
13 | * |
||
14 | * @covers Redaxscript\Registry |
||
15 | */ |
||
16 | |||
17 | class RegistryTest extends TestCaseAbstract |
||
18 | { |
||
19 | /** |
||
20 | * testInit |
||
21 | * |
||
22 | * @since 3.0.0 |
||
23 | */ |
||
24 | |||
25 | public function testInit() |
||
26 | { |
||
27 | /* setup */ |
||
28 | |||
29 | $this->_registry->init(); |
||
30 | |||
31 | /* actual */ |
||
32 | |||
33 | $actual = $this->_registry; |
||
34 | |||
35 | /* compare */ |
||
36 | |||
37 | $this->assertInstanceOf('Redaxscript\Registry', $actual); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * testGetAndSet |
||
42 | * |
||
43 | * @since 2.1.0 |
||
44 | */ |
||
45 | |||
46 | public function testGetAndSet() |
||
47 | { |
||
48 | /* setup */ |
||
49 | |||
50 | $this->_registry->set('testKey', 'testValue'); |
||
51 | |||
52 | /* actual */ |
||
53 | |||
54 | $actual = $this->_registry->get('testKey'); |
||
55 | |||
56 | /* compare */ |
||
57 | |||
58 | $this->assertEquals('testValue', $actual); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * testGetAll |
||
63 | * |
||
64 | * @since 2.2.0 |
||
65 | */ |
||
66 | |||
67 | public function testGetAll() |
||
68 | { |
||
69 | /* setup */ |
||
70 | |||
71 | $this->_registry->set('testAll', 'testAll'); |
||
72 | |||
73 | /* actual */ |
||
74 | |||
75 | $actualArray = $this->_registry->get(); |
||
76 | |||
77 | /* compare */ |
||
78 | |||
79 | $this->assertArrayHasKey('testAll', $actualArray); |
||
0 ignored issues
–
show
|
|||
80 | } |
||
81 | |||
82 | /** |
||
83 | * testGetInvalid |
||
84 | * |
||
85 | * @since 2.1.0 |
||
86 | */ |
||
87 | |||
88 | public function testGetInvalid() |
||
89 | { |
||
90 | /* actual */ |
||
91 | |||
92 | $actual = $this->_registry->get('invalidKey'); |
||
93 | |||
94 | /* compare */ |
||
95 | |||
96 | $this->assertNull($actual); |
||
97 | } |
||
98 | } |
||
99 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.