Skip to content

Commit 477b13f

Browse files
committed
Tests/TypeIntersectionTest: 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 140ce8f commit 477b13f

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

tests/Core/Tokenizer/TypeIntersectionTest.php

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,28 @@ public function testBitwiseAnd($testMarker)
4242
*
4343
* @see testBitwiseAnd()
4444
*
45-
* @return array
45+
* @return array<string, array<string>>
4646
*/
4747
public static function dataBitwiseAnd()
4848
{
4949
return [
50-
['/* testBitwiseAnd1 */'],
51-
['/* testBitwiseAnd2 */'],
52-
['/* testBitwiseAndPropertyDefaultValue */'],
53-
['/* testBitwiseAndParamDefaultValue */'],
54-
['/* testBitwiseAnd3 */'],
55-
['/* testBitwiseAnd4 */'],
56-
['/* testBitwiseAnd5 */'],
57-
['/* testBitwiseAndClosureParamDefault */'],
58-
['/* testBitwiseAndArrowParamDefault */'],
59-
['/* testBitwiseAndArrowExpression */'],
60-
['/* testBitwiseAndInArrayKey */'],
61-
['/* testBitwiseAndInArrayValue */'],
62-
['/* testBitwiseAndInShortArrayKey */'],
63-
['/* testBitwiseAndInShortArrayValue */'],
64-
['/* testBitwiseAndNonArrowFnFunctionCall */'],
65-
['/* testBitwiseAnd6 */'],
66-
['/* testLiveCoding */'],
50+
'in simple assignment 1' => ['/* testBitwiseAnd1 */'],
51+
'in simple assignment 2' => ['/* testBitwiseAnd2 */'],
52+
'in property default value' => ['/* testBitwiseAndPropertyDefaultValue */'],
53+
'in method parameter default value' => ['/* testBitwiseAndParamDefaultValue */'],
54+
'reference for method parameter' => ['/* testBitwiseAnd3 */'],
55+
'in return statement' => ['/* testBitwiseAnd4 */'],
56+
'reference for function parameter' => ['/* testBitwiseAnd5 */'],
57+
'in closure parameter default value' => ['/* testBitwiseAndClosureParamDefault */'],
58+
'in arrow function parameter default value' => ['/* testBitwiseAndArrowParamDefault */'],
59+
'in arrow function return expression' => ['/* testBitwiseAndArrowExpression */'],
60+
'in long array key' => ['/* testBitwiseAndInArrayKey */'],
61+
'in long array value' => ['/* testBitwiseAndInArrayValue */'],
62+
'in short array key' => ['/* testBitwiseAndInShortArrayKey */'],
63+
'in short array value' => ['/* testBitwiseAndInShortArrayValue */'],
64+
'in parameter in function call' => ['/* testBitwiseAndNonArrowFnFunctionCall */'],
65+
'function return by reference' => ['/* testBitwiseAnd6 */'],
66+
'live coding / undetermined' => ['/* testLiveCoding */'],
6767
];
6868

6969
}//end dataBitwiseAnd()
@@ -95,42 +95,42 @@ public function testTypeIntersection($testMarker)
9595
*
9696
* @see testTypeIntersection()
9797
*
98-
* @return array
98+
* @return array<string, array<string>>
9999
*/
100100
public static function dataTypeIntersection()
101101
{
102102
return [
103-
['/* testTypeIntersectionPropertySimple */'],
104-
['/* testTypeIntersectionPropertyReverseModifierOrder */'],
105-
['/* testTypeIntersectionPropertyMulti1 */'],
106-
['/* testTypeIntersectionPropertyMulti2 */'],
107-
['/* testTypeIntersectionPropertyMulti3 */'],
108-
['/* testTypeIntersectionPropertyNamespaceRelative */'],
109-
['/* testTypeIntersectionPropertyPartiallyQualified */'],
110-
['/* testTypeIntersectionPropertyFullyQualified */'],
111-
['/* testTypeIntersectionPropertyWithReadOnlyKeyword */'],
112-
['/* testTypeIntersectionPropertyWithStaticKeyword */'],
113-
['/* testTypeIntersectionParam1 */'],
114-
['/* testTypeIntersectionParam2 */'],
115-
['/* testTypeIntersectionParam3 */'],
116-
['/* testTypeIntersectionParamNamespaceRelative */'],
117-
['/* testTypeIntersectionParamPartiallyQualified */'],
118-
['/* testTypeIntersectionParamFullyQualified */'],
119-
['/* testTypeIntersectionConstructorPropertyPromotion */'],
120-
['/* testTypeIntersectionReturnType */'],
121-
['/* testTypeIntersectionAbstractMethodReturnType1 */'],
122-
['/* testTypeIntersectionAbstractMethodReturnType2 */'],
123-
['/* testTypeIntersectionReturnTypeNamespaceRelative */'],
124-
['/* testTypeIntersectionReturnPartiallyQualified */'],
125-
['/* testTypeIntersectionReturnFullyQualified */'],
126-
['/* testTypeIntersectionWithReference */'],
127-
['/* testTypeIntersectionWithSpreadOperator */'],
128-
['/* testTypeIntersectionClosureParamIllegalNullable */'],
129-
['/* testTypeIntersectionClosureReturn */'],
130-
['/* testTypeIntersectionArrowParam */'],
131-
['/* testTypeIntersectionArrowReturnType */'],
132-
['/* testTypeIntersectionNonArrowFunctionDeclaration */'],
133-
['/* testTypeIntersectionWithInvalidTypes */'],
103+
'type for static property' => ['/* testTypeIntersectionPropertySimple */'],
104+
'type for static property, reversed modifier order' => ['/* testTypeIntersectionPropertyReverseModifierOrder */'],
105+
'type for property, first of multi-intersect' => ['/* testTypeIntersectionPropertyMulti1 */'],
106+
'type for property, middle of multi-intersect, also comments' => ['/* testTypeIntersectionPropertyMulti2 */'],
107+
'type for property, last of multi-intersect' => ['/* testTypeIntersectionPropertyMulti3 */'],
108+
'type for property using namespace relative names' => ['/* testTypeIntersectionPropertyNamespaceRelative */'],
109+
'type for property using partially qualified names' => ['/* testTypeIntersectionPropertyPartiallyQualified */'],
110+
'type for property using fully qualified names' => ['/* testTypeIntersectionPropertyFullyQualified */'],
111+
'type for readonly property' => ['/* testTypeIntersectionPropertyWithReadOnlyKeyword */'],
112+
'type for static readonly property' => ['/* testTypeIntersectionPropertyWithStaticKeyword */'],
113+
'type for method parameter' => ['/* testTypeIntersectionParam1 */'],
114+
'type for method parameter, first in multi-intersect' => ['/* testTypeIntersectionParam2 */'],
115+
'type for method parameter, last in multi-intersect' => ['/* testTypeIntersectionParam3 */'],
116+
'type for method parameter with namespace relative names' => ['/* testTypeIntersectionParamNamespaceRelative */'],
117+
'type for method parameter with partially qualified names' => ['/* testTypeIntersectionParamPartiallyQualified */'],
118+
'type for method parameter with fully qualified names' => ['/* testTypeIntersectionParamFullyQualified */'],
119+
'type for property in constructor property promotion' => ['/* testTypeIntersectionConstructorPropertyPromotion */'],
120+
'return type for method' => ['/* testTypeIntersectionReturnType */'],
121+
'return type for method, first of multi-intersect' => ['/* testTypeIntersectionAbstractMethodReturnType1 */'],
122+
'return type for method, last of multi-intersect' => ['/* testTypeIntersectionAbstractMethodReturnType2 */'],
123+
'return type for method with namespace relative names' => ['/* testTypeIntersectionReturnTypeNamespaceRelative */'],
124+
'return type for method with partially qualified names' => ['/* testTypeIntersectionReturnPartiallyQualified */'],
125+
'return type for method with fully qualified names' => ['/* testTypeIntersectionReturnFullyQualified */'],
126+
'type for function parameter with reference' => ['/* testTypeIntersectionWithReference */'],
127+
'type for function parameter with spread operator' => ['/* testTypeIntersectionWithSpreadOperator */'],
128+
'type for closure parameter with illegal nullable' => ['/* testTypeIntersectionClosureParamIllegalNullable */'],
129+
'return type for closure' => ['/* testTypeIntersectionClosureReturn */'],
130+
'type for arrow function parameter' => ['/* testTypeIntersectionArrowParam */'],
131+
'return type for arrow function' => ['/* testTypeIntersectionArrowReturnType */'],
132+
'type for function parameter, return by ref' => ['/* testTypeIntersectionNonArrowFunctionDeclaration */'],
133+
'type for function parameter with invalid types' => ['/* testTypeIntersectionWithInvalidTypes */'],
134134
];
135135

136136
}//end dataTypeIntersection()

0 commit comments

Comments
 (0)