Skip to content

Commit c7d920a

Browse files
committed
Tests/BitwiseOrTest: 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 960e8b4 commit c7d920a

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

tests/Core/Tokenizer/BitwiseOrTest.php

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@ public function testBitwiseOr($testMarker)
4141
*
4242
* @see testBitwiseOr()
4343
*
44-
* @return array
44+
* @return array<string, array<string>>
4545
*/
4646
public static function dataBitwiseOr()
4747
{
4848
return [
49-
['/* testBitwiseOr1 */'],
50-
['/* testBitwiseOr2 */'],
51-
['/* testBitwiseOrPropertyDefaultValue */'],
52-
['/* testBitwiseOrParamDefaultValue */'],
53-
['/* testBitwiseOr3 */'],
54-
['/* testBitwiseOrClosureParamDefault */'],
55-
['/* testBitwiseOrArrowParamDefault */'],
56-
['/* testBitwiseOrArrowExpression */'],
57-
['/* testBitwiseOrInArrayKey */'],
58-
['/* testBitwiseOrInArrayValue */'],
59-
['/* testBitwiseOrInShortArrayKey */'],
60-
['/* testBitwiseOrInShortArrayValue */'],
61-
['/* testBitwiseOrTryCatch */'],
62-
['/* testBitwiseOrNonArrowFnFunctionCall */'],
63-
['/* testLiveCoding */'],
49+
'in simple assignment 1' => ['/* testBitwiseOr1 */'],
50+
'in simple assignment 2' => ['/* testBitwiseOr2 */'],
51+
'in property default value' => ['/* testBitwiseOrPropertyDefaultValue */'],
52+
'in method parameter default value' => ['/* testBitwiseOrParamDefaultValue */'],
53+
'in return statement' => ['/* testBitwiseOr3 */'],
54+
'in closure parameter default value' => ['/* testBitwiseOrClosureParamDefault */'],
55+
'in arrow function parameter default value' => ['/* testBitwiseOrArrowParamDefault */'],
56+
'in arrow function return expression' => ['/* testBitwiseOrArrowExpression */'],
57+
'in long array key' => ['/* testBitwiseOrInArrayKey */'],
58+
'in long array value' => ['/* testBitwiseOrInArrayValue */'],
59+
'in short array key' => ['/* testBitwiseOrInShortArrayKey */'],
60+
'in short array value' => ['/* testBitwiseOrInShortArrayValue */'],
61+
'in catch condition' => ['/* testBitwiseOrTryCatch */'],
62+
'in parameter in function call' => ['/* testBitwiseOrNonArrowFnFunctionCall */'],
63+
'live coding / undetermined' => ['/* testLiveCoding */'],
6464
];
6565

6666
}//end dataBitwiseOr()
@@ -92,48 +92,48 @@ public function testTypeUnion($testMarker)
9292
*
9393
* @see testTypeUnion()
9494
*
95-
* @return array
95+
* @return array<string, array<string>>
9696
*/
9797
public static function dataTypeUnion()
9898
{
9999
return [
100-
['/* testTypeUnionPropertySimple */'],
101-
['/* testTypeUnionPropertyReverseModifierOrder */'],
102-
['/* testTypeUnionPropertyMulti1 */'],
103-
['/* testTypeUnionPropertyMulti2 */'],
104-
['/* testTypeUnionPropertyMulti3 */'],
105-
['/* testTypeUnionPropertyNamespaceRelative */'],
106-
['/* testTypeUnionPropertyPartiallyQualified */'],
107-
['/* testTypeUnionPropertyFullyQualified */'],
108-
['/* testTypeUnionPropertyWithReadOnlyKeyword */'],
109-
['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */'],
110-
['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */'],
111-
['/* testTypeUnionPropertyWithReadOnlyKeywordFirst */'],
112-
['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */'],
113-
['/* testTypeUnionPropertyWithOnlyStaticKeyword */'],
114-
['/* testTypeUnionParam1 */'],
115-
['/* testTypeUnionParam2 */'],
116-
['/* testTypeUnionParam3 */'],
117-
['/* testTypeUnionParamNamespaceRelative */'],
118-
['/* testTypeUnionParamPartiallyQualified */'],
119-
['/* testTypeUnionParamFullyQualified */'],
120-
['/* testTypeUnionConstructorPropertyPromotion */'],
121-
['/* testTypeUnionReturnType */'],
122-
['/* testTypeUnionAbstractMethodReturnType1 */'],
123-
['/* testTypeUnionAbstractMethodReturnType2 */'],
124-
['/* testTypeUnionReturnTypeNamespaceRelative */'],
125-
['/* testTypeUnionReturnPartiallyQualified */'],
126-
['/* testTypeUnionReturnFullyQualified */'],
127-
['/* testTypeUnionWithReference */'],
128-
['/* testTypeUnionWithSpreadOperator */'],
129-
['/* testTypeUnionClosureParamIllegalNullable */'],
130-
['/* testTypeUnionClosureReturn */'],
131-
['/* testTypeUnionArrowParam */'],
132-
['/* testTypeUnionArrowReturnType */'],
133-
['/* testTypeUnionNonArrowFunctionDeclaration */'],
134-
['/* testTypeUnionPHP82TrueFirst */'],
135-
['/* testTypeUnionPHP82TrueMiddle */'],
136-
['/* testTypeUnionPHP82TrueLast */'],
100+
'type for static property' => ['/* testTypeUnionPropertySimple */'],
101+
'type for static property, reversed modifier order' => ['/* testTypeUnionPropertyReverseModifierOrder */'],
102+
'type for property, first of multi-union' => ['/* testTypeUnionPropertyMulti1 */'],
103+
'type for property, middle of multi-union, also comments' => ['/* testTypeUnionPropertyMulti2 */'],
104+
'type for property, last of multi-union' => ['/* testTypeUnionPropertyMulti3 */'],
105+
'type for property using namespace relative names' => ['/* testTypeUnionPropertyNamespaceRelative */'],
106+
'type for property using partially qualified names' => ['/* testTypeUnionPropertyPartiallyQualified */'],
107+
'type for property using fully qualified names' => ['/* testTypeUnionPropertyFullyQualified */'],
108+
'type for readonly property' => ['/* testTypeUnionPropertyWithReadOnlyKeyword */'],
109+
'type for static readonly property' => ['/* testTypeUnionPropertyWithStaticAndReadOnlyKeywords */'],
110+
'type for readonly property using var keyword' => ['/* testTypeUnionPropertyWithVarAndReadOnlyKeywords */'],
111+
'type for readonly property, reversed modifier order' => ['/* testTypeUnionPropertyWithReadOnlyKeywordFirst */'],
112+
'type for readonly property, no visibility' => ['/* testTypeUnionPropertyWithOnlyReadOnlyKeyword */'],
113+
'type for static property, no visibility' => ['/* testTypeUnionPropertyWithOnlyStaticKeyword */'],
114+
'type for method parameter' => ['/* testTypeUnionParam1 */'],
115+
'type for method parameter, first in multi-union' => ['/* testTypeUnionParam2 */'],
116+
'type for method parameter, last in multi-union' => ['/* testTypeUnionParam3 */'],
117+
'type for method parameter with namespace relative names' => ['/* testTypeUnionParamNamespaceRelative */'],
118+
'type for method parameter with partially qualified names' => ['/* testTypeUnionParamPartiallyQualified */'],
119+
'type for method parameter with fully qualified names' => ['/* testTypeUnionParamFullyQualified */'],
120+
'type for property in constructor property promotion' => ['/* testTypeUnionConstructorPropertyPromotion */'],
121+
'return type for method' => ['/* testTypeUnionReturnType */'],
122+
'return type for method, first of multi-union' => ['/* testTypeUnionAbstractMethodReturnType1 */'],
123+
'return type for method, last of multi-union' => ['/* testTypeUnionAbstractMethodReturnType2 */'],
124+
'return type for method with namespace relative names' => ['/* testTypeUnionReturnTypeNamespaceRelative */'],
125+
'return type for method with partially qualified names' => ['/* testTypeUnionReturnPartiallyQualified */'],
126+
'return type for method with fully qualified names' => ['/* testTypeUnionReturnFullyQualified */'],
127+
'type for function parameter with reference' => ['/* testTypeUnionWithReference */'],
128+
'type for function parameter with spread operator' => ['/* testTypeUnionWithSpreadOperator */'],
129+
'type for closure parameter with illegal nullable' => ['/* testTypeUnionClosureParamIllegalNullable */'],
130+
'return type for closure' => ['/* testTypeUnionClosureReturn */'],
131+
'type for arrow function parameter' => ['/* testTypeUnionArrowParam */'],
132+
'return type for arrow function' => ['/* testTypeUnionArrowReturnType */'],
133+
'type for function parameter, return by ref' => ['/* testTypeUnionNonArrowFunctionDeclaration */'],
134+
'type for function param with true type first' => ['/* testTypeUnionPHP82TrueFirst */'],
135+
'type for function param with true type middle' => ['/* testTypeUnionPHP82TrueMiddle */'],
136+
'type for function param with true type last' => ['/* testTypeUnionPHP82TrueLast */'],
137137
];
138138

139139
}//end dataTypeUnion()

0 commit comments

Comments
 (0)