Skip to content

Commit a902981

Browse files
committed
Tests/AnonClassParenthesisOwnerTest: use named data sets
With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes minor data set array normalization. Includes making the data types in the docblocks more specific.
1 parent 90e70f4 commit a902981

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tests/Core/Tokenizer/AnonClassParenthesisOwnerTest.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,17 @@ public function testAnonClassNoParenthesesNextOpenClose($testMarker)
7070
* @see testAnonClassNoParentheses()
7171
* @see testAnonClassNoParenthesesNextOpenClose()
7272
*
73-
* @return array
73+
* @return array<string, array<string, string>>
7474
*/
7575
public static function dataAnonClassNoParentheses()
7676
{
7777
return [
78-
['/* testNoParentheses */'],
79-
['/* testNoParenthesesAndEmptyTokens */'],
78+
'plain' => [
79+
'testMarker' => '/* testNoParentheses */',
80+
],
81+
'declaration contains comments and extra whitespace' => [
82+
'testMarker' => '/* testNoParenthesesAndEmptyTokens */',
83+
],
8084
];
8185

8286
}//end dataAnonClassNoParentheses()
@@ -129,13 +133,17 @@ public function testAnonClassWithParentheses($testMarker)
129133
*
130134
* @see testAnonClassWithParentheses()
131135
*
132-
* @return array
136+
* @return array<string, array<string, string>>
133137
*/
134138
public static function dataAnonClassWithParentheses()
135139
{
136140
return [
137-
['/* testWithParentheses */'],
138-
['/* testWithParenthesesAndEmptyTokens */'],
141+
'plain' => [
142+
'testMarker' => '/* testWithParentheses */',
143+
],
144+
'declaration contains comments and extra whitespace' => [
145+
'testMarker' => '/* testWithParenthesesAndEmptyTokens */',
146+
],
139147
];
140148

141149
}//end dataAnonClassWithParentheses()

0 commit comments

Comments
 (0)