Skip to content

Commit 0e094e7

Browse files
committed
Tests/FinallyTest: 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 making the data type in the docblock more specific.
1 parent 075ab2c commit 0e094e7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/Core/Tokenizer/FinallyTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public function testFinallyKeyword($testMarker)
4141
*
4242
* @see testFinallyKeyword()
4343
*
44-
* @return array
44+
* @return array<string, array<string>>
4545
*/
4646
public static function dataFinallyKeyword()
4747
{
4848
return [
49-
['/* testTryCatchFinally */'],
50-
['/* testTryFinallyCatch */'],
51-
['/* testTryFinally */'],
49+
'finally after try and catch' => ['/* testTryCatchFinally */'],
50+
'finally between try and catch' => ['/* testTryFinallyCatch */'],
51+
'finally after try, no catch' => ['/* testTryFinally */'],
5252
];
5353

5454
}//end dataFinallyKeyword()
@@ -80,14 +80,14 @@ public function testFinallyNonKeyword($testMarker)
8080
*
8181
* @see testFinallyNonKeyword()
8282
*
83-
* @return array
83+
* @return array<string, array<string>>
8484
*/
8585
public static function dataFinallyNonKeyword()
8686
{
8787
return [
88-
['/* testFinallyUsedAsClassConstantName */'],
89-
['/* testFinallyUsedAsMethodName */'],
90-
['/* testFinallyUsedAsPropertyName */'],
88+
'finally used as class constant name' => ['/* testFinallyUsedAsClassConstantName */'],
89+
'finally used as method name' => ['/* testFinallyUsedAsMethodName */'],
90+
'finally used as property name' => ['/* testFinallyUsedAsPropertyName */'],
9191
];
9292

9393
}//end dataFinallyNonKeyword()

0 commit comments

Comments
 (0)