25
25
class ParserTest extends TestCase
26
26
{
27
27
/** @var Parser */
28
- protected $ parser ;
28
+ protected Parser $ parser ;
29
29
30
30
/**
31
31
* {@inheritdoc}
@@ -43,14 +43,20 @@ public function setUp(): void
43
43
*
44
44
* @param array $params
45
45
* @param array $expected
46
+ *
47
+ * @return void
46
48
*/
47
49
public function shouldParseCliCommand (array $ params , array $ expected ): void
48
50
{
49
51
$ actual = $ this ->parser ->parse ($ params ['command ' ]);
50
52
$ this ->assertSame ($ expected , $ actual );
51
53
}
52
54
53
- /** @test */
55
+ /**
56
+ * @test
57
+ *
58
+ * @return void
59
+ */
54
60
public function shouldParseCommandFromTheServer (): void
55
61
{
56
62
$ _SERVER ['argv ' ] = ['script.php ' , 'arg1 ' , 'arg2 ' , 'arg3 ' ];
@@ -66,6 +72,8 @@ public function shouldParseCommandFromTheServer(): void
66
72
*
67
73
* @param array $params
68
74
* @param bool $expected
75
+ *
76
+ * @return void
69
77
*/
70
78
public function shouldTransformParamsToBool (array $ params , bool $ expected ): void
71
79
{
@@ -94,7 +102,9 @@ public function testGetParsedCommandsShouldReturnEmptyArrayOnNewObject(): void
94
102
* @dataProvider parseProvider
95
103
*
96
104
* @param array $params
97
- * @param array $expect
105
+ * @param array $expected
106
+ *
107
+ * @return void
98
108
*/
99
109
public function testGetParsedCommandsShouldReturnParsedCommand (
100
110
array $ params ,
@@ -131,12 +141,11 @@ public function testGetParsedCommandsShouldReturnParsedCommand(
131
141
* @dataProvider parseProvider
132
142
*
133
143
* @param array $params
134
- * @param array $expect
144
+ *
145
+ * @return void
135
146
*/
136
- public function testGetReturnsBoundDefaultValueIfNotSet (
137
- array $ params ,
138
- array $ expect
139
- ): void {
147
+ public function testGetReturnsBoundDefaultValueIfNotSet (array $ params ): void
148
+ {
140
149
$ expectedDefaultValues = [
141
150
123 ,
142
151
"test " ,
@@ -145,12 +154,12 @@ public function testGetReturnsBoundDefaultValueIfNotSet(
145
154
new stdClass (),
146
155
];
147
156
148
- $ nonExistingParameterKey = "non-existing-parameter-key " ;
157
+ $ nonExistingKey = "non-existing-parameter-key " ;
149
158
150
- foreach ($ expectedDefaultValues as $ expectedDefaultValue ) {
151
- $ actual = $ this ->parser ->get ($ nonExistingParameterKey , $ expectedDefaultValue );
159
+ foreach ($ expectedDefaultValues as $ expected ) {
160
+ $ actual = $ this ->parser ->get ($ nonExistingKey , $ expected );
152
161
$ this ->assertSame (
153
- $ expectedDefaultValue ,
162
+ $ expected ,
154
163
$ actual ,
155
164
"Should return the provided default value,
156
165
if the queried parameter doesn't exist in an empty/fresh object. "
@@ -159,10 +168,10 @@ public function testGetReturnsBoundDefaultValueIfNotSet(
159
168
160
169
$ this ->parser ->parse ($ params ["command " ]);
161
170
162
- foreach ($ expectedDefaultValues as $ expectedDefaultValue ) {
163
- $ actual = $ this ->parser ->get ($ nonExistingParameterKey , $ expectedDefaultValue );
171
+ foreach ($ expectedDefaultValues as $ expected ) {
172
+ $ actual = $ this ->parser ->get ($ nonExistingKey , $ expected );
164
173
$ this ->assertSame (
165
- $ expectedDefaultValue ,
174
+ $ expected ,
166
175
$ actual ,
167
176
"Should return null,
168
177
if the queried parameter doesn't exist in a populated/parsed object. "
@@ -175,20 +184,21 @@ public function testGetReturnsBoundDefaultValueIfNotSet(
175
184
* @dataProvider parseProvider
176
185
*
177
186
* @param array $params
178
- * @param array $expect
187
+ *
188
+ * @return void
179
189
*/
180
190
public function testGetReturnsNullIfParamDoesNotExist (array $ params ): void
181
191
{
182
- $ nonExistingParameterKey = "non-existing-parameter-key " ;
183
- $ actual = $ this ->parser ->get ($ nonExistingParameterKey );
192
+ $ nonExistingKey = "non-existing-parameter-key " ;
193
+ $ actual = $ this ->parser ->get ($ nonExistingKey );
184
194
$ this ->assertNull (
185
195
$ actual ,
186
196
"Should return null,
187
197
if the queried parameter doesn't exist in an empty/fresh object. "
188
198
);
189
199
190
200
$ this ->parser ->parse ($ params ["command " ]);
191
- $ actual = $ this ->parser ->get ($ nonExistingParameterKey );
201
+ $ actual = $ this ->parser ->get ($ nonExistingKey );
192
202
$ this ->assertNull (
193
203
$ actual ,
194
204
"Should return null,
@@ -202,9 +212,13 @@ public function testGetReturnsNullIfParamDoesNotExist(array $params): void
202
212
*
203
213
* @param array $params
204
214
* @param array $expected
215
+ *
216
+ * @return void
205
217
*/
206
- public function testGetReturnsValueIfParamDoesExist (array $ params , array $ expected )
207
- {
218
+ public function testGetReturnsValueIfParamDoesExist (
219
+ array $ params ,
220
+ array $ expected
221
+ ): void {
208
222
$ this ->parser ->parse ($ params ["command " ]);
209
223
foreach ($ expected as $ parameterKey => $ expectedValue ) {
210
224
$ actual = $ this ->parser ->get ($ parameterKey );
0 commit comments