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 | * LanguageTest |
||
6 | * |
||
7 | * @since 2.2.0 |
||
8 | * |
||
9 | * @package Redaxscript |
||
10 | * @category Tests |
||
11 | * @author Henry Ruhs |
||
12 | * |
||
13 | * @covers Redaxscript\Language |
||
14 | */ |
||
15 | |||
16 | class LanguageTest extends TestCaseAbstract |
||
17 | { |
||
18 | /** |
||
19 | * testInit |
||
20 | * |
||
21 | * @since 3.0.0 |
||
22 | */ |
||
23 | |||
24 | public function testInit() |
||
25 | { |
||
26 | /* setup */ |
||
27 | |||
28 | $this->_language->init('de'); |
||
29 | $this->_language->init('en'); |
||
30 | |||
31 | /* actual */ |
||
32 | |||
33 | $actual = $this->_language; |
||
34 | |||
35 | /* compare */ |
||
36 | |||
37 | $this->assertInstanceOf('Redaxscript\Language', $actual); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * testGetAndSet |
||
42 | * |
||
43 | * @since 2.4.0 |
||
44 | */ |
||
45 | |||
46 | public function testGetAndSet() |
||
47 | { |
||
48 | /* setup */ |
||
49 | |||
50 | $this->_language->set('testKey', 'testValue'); |
||
51 | |||
52 | /* actual */ |
||
53 | |||
54 | $actual = $this->_language->get('testKey'); |
||
55 | |||
56 | /* compare */ |
||
57 | |||
58 | $this->assertEquals('testValue', $actual); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * testGetIndex |
||
63 | * |
||
64 | * @since 2.2.0 |
||
65 | */ |
||
66 | |||
67 | public function testGetIndex() |
||
68 | { |
||
69 | /* actual */ |
||
70 | |||
71 | $actual = $this->_language->get('name', '_package'); |
||
72 | |||
73 | /* compare */ |
||
74 | |||
75 | $this->assertEquals('Redaxscript', $actual); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * testGetAll |
||
80 | * |
||
81 | * @since 2.2.0 |
||
82 | */ |
||
83 | |||
84 | public function testGetAll() |
||
85 | { |
||
86 | /* actual */ |
||
87 | |||
88 | $actualArray = $this->_language->get(); |
||
89 | |||
90 | /* compare */ |
||
91 | |||
92 | $this->assertArrayHasKey('home', $actualArray); |
||
0 ignored issues
–
show
|
|||
93 | } |
||
94 | |||
95 | /** |
||
96 | * testGetInvalid |
||
97 | * |
||
98 | * @since 2.2.0 |
||
99 | */ |
||
100 | |||
101 | public function testGetInvalid() |
||
102 | { |
||
103 | /* actual */ |
||
104 | |||
105 | $actual = $this->_language->get('invalidKey'); |
||
106 | |||
107 | /* compare */ |
||
108 | |||
109 | $this->assertNull($actual); |
||
110 | } |
||
111 | } |
||
112 |
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.