Skip to content

Commit 29290f9

Browse files
committed
Tests/ArrayKeywordTest: use named data within data sets
This commit adds the parameter name for each item in the data set in an effort to make it more straight forward to update and add tests as it will be more obvious what each key in the data set signifies. Includes minor array normalization. Includes making the data type in the docblock more specific.
1 parent a902981 commit 29290f9

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

tests/Core/Tokenizer/ArrayKeywordTest.php

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,27 @@ public function testArrayKeyword($testMarker, $testContent='array')
4949
*
5050
* @see testArrayKeyword()
5151
*
52-
* @return array
52+
* @return array<string, array<string, string>>
5353
*/
5454
public static function dataArrayKeyword()
5555
{
5656
return [
57-
'empty array' => ['/* testEmptyArray */'],
58-
'array with space before parenthesis' => ['/* testArrayWithSpace */'],
57+
'empty array' => [
58+
'testMarker' => '/* testEmptyArray */',
59+
],
60+
'array with space before parenthesis' => [
61+
'testMarker' => '/* testArrayWithSpace */',
62+
],
5963
'array with comment before parenthesis' => [
60-
'/* testArrayWithComment */',
61-
'Array',
64+
'testMarker' => '/* testArrayWithComment */',
65+
'testContent' => 'Array',
66+
],
67+
'nested: outer array' => [
68+
'testMarker' => '/* testNestingArray */',
69+
],
70+
'nested: inner array' => [
71+
'testMarker' => '/* testNestedArray */',
6272
],
63-
'nested: outer array' => ['/* testNestingArray */'],
64-
'nested: inner array' => ['/* testNestedArray */'],
6573
];
6674

6775
}//end dataArrayKeyword()
@@ -101,17 +109,21 @@ public function testArrayType($testMarker, $testContent='array')
101109
*
102110
* @see testArrayType()
103111
*
104-
* @return array
112+
* @return array<string, array<string, string>>
105113
*/
106114
public static function dataArrayType()
107115
{
108116
return [
109117
'closure return type' => [
110-
'/* testClosureReturnType */',
111-
'Array',
118+
'testMarker' => '/* testClosureReturnType */',
119+
'testContent' => 'Array',
120+
],
121+
'function param type' => [
122+
'testMarker' => '/* testFunctionDeclarationParamType */',
123+
],
124+
'function union return type' => [
125+
'testMarker' => '/* testFunctionDeclarationReturnType */',
112126
],
113-
'function param type' => ['/* testFunctionDeclarationParamType */'],
114-
'function union return type' => ['/* testFunctionDeclarationReturnType */'],
115127
];
116128

117129
}//end dataArrayType()
@@ -152,16 +164,18 @@ public function testNotArrayKeyword($testMarker, $testContent='array')
152164
*
153165
* @see testNotArrayKeyword()
154166
*
155-
* @return array
167+
* @return array<string, array<string, string>>
156168
*/
157169
public static function dataNotArrayKeyword()
158170
{
159171
return [
160172
'class-constant-name' => [
161-
'/* testClassConst */',
162-
'ARRAY',
173+
'testMarker' => '/* testClassConst */',
174+
'testContent' => 'ARRAY',
175+
],
176+
'class-method-name' => [
177+
'testMarker' => '/* testClassMethod */',
163178
],
164-
'class-method-name' => ['/* testClassMethod */'],
165179
];
166180

167181
}//end dataNotArrayKeyword()

0 commit comments

Comments
 (0)