Skip to content

Commit 866ca20

Browse files
authored
Merge pull request #268 from PHPCSStandards/feature/tests-enum-case-improvements
Tests/EnumCaseTest: use named data sets + activate three extra tests
2 parents 8ecd89e + 9860504 commit 866ca20

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

tests/Core/Tokenizer/EnumCaseTest.php

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ public function testEnumCases($testMarker)
4747
*
4848
* @see testEnumCases()
4949
*
50-
* @return array
50+
* @return array<string, array<string>>
5151
*/
5252
public static function dataEnumCases()
5353
{
5454
return [
55-
['/* testPureEnumCase */'],
56-
['/* testBackingIntegerEnumCase */'],
57-
['/* testBackingStringEnumCase */'],
58-
['/* testEnumCaseInComplexEnum */'],
59-
['/* testEnumCaseIsCaseInsensitive */'],
60-
['/* testEnumCaseAfterSwitch */'],
61-
['/* testEnumCaseAfterSwitchWithEndSwitch */'],
55+
'enum case, no value' => ['/* testPureEnumCase */'],
56+
'enum case, integer value' => ['/* testBackingIntegerEnumCase */'],
57+
'enum case, string value' => ['/* testBackingStringEnumCase */'],
58+
'enum case, integer value in more complex enum' => ['/* testEnumCaseInComplexEnum */'],
59+
'enum case, keyword in mixed case' => ['/* testEnumCaseIsCaseInsensitive */'],
60+
'enum case, after switch statement' => ['/* testEnumCaseAfterSwitch */'],
61+
'enum case, after switch statement using alternative syntax' => ['/* testEnumCaseAfterSwitchWithEndSwitch */'],
6262
];
6363

6464
}//end dataEnumCases()
@@ -96,18 +96,18 @@ public function testNotEnumCases($testMarker)
9696
*
9797
* @see testNotEnumCases()
9898
*
99-
* @return array
99+
* @return array<string, array<string>>
100100
*/
101101
public static function dataNotEnumCases()
102102
{
103103
return [
104-
['/* testCaseWithSemicolonIsNotEnumCase */'],
105-
['/* testCaseWithConstantIsNotEnumCase */'],
106-
['/* testCaseWithConstantAndIdenticalIsNotEnumCase */'],
107-
['/* testCaseWithAssigmentToConstantIsNotEnumCase */'],
108-
['/* testIsNotEnumCaseIsCaseInsensitive */'],
109-
['/* testCaseInSwitchWhenCreatingEnumInSwitch1 */'],
110-
['/* testCaseInSwitchWhenCreatingEnumInSwitch2 */'],
104+
'switch case with constant, semicolon condition end' => ['/* testCaseWithSemicolonIsNotEnumCase */'],
105+
'switch case with constant, colon condition end' => ['/* testCaseWithConstantIsNotEnumCase */'],
106+
'switch case with constant, comparison' => ['/* testCaseWithConstantAndIdenticalIsNotEnumCase */'],
107+
'switch case with constant, assignment' => ['/* testCaseWithAssigmentToConstantIsNotEnumCase */'],
108+
'switch case with constant, keyword in mixed case' => ['/* testIsNotEnumCaseIsCaseInsensitive */'],
109+
'switch case, body in curlies declares enum' => ['/* testCaseInSwitchWhenCreatingEnumInSwitch1 */'],
110+
'switch case, body after semicolon declares enum' => ['/* testCaseInSwitchWhenCreatingEnumInSwitch2 */'],
111111
];
112112

113113
}//end dataNotEnumCases()
@@ -140,15 +140,18 @@ public function testKeywordAsEnumCaseNameShouldBeString($testMarker)
140140
*
141141
* @see testKeywordAsEnumCaseNameShouldBeString()
142142
*
143-
* @return array
143+
* @return array<string, array<string>>
144144
*/
145145
public static function dataKeywordAsEnumCaseNameShouldBeString()
146146
{
147147
return [
148-
['/* testKeywordAsEnumCaseNameShouldBeString1 */'],
149-
['/* testKeywordAsEnumCaseNameShouldBeString2 */'],
150-
['/* testKeywordAsEnumCaseNameShouldBeString3 */'],
151-
['/* testKeywordAsEnumCaseNameShouldBeString4 */'],
148+
'"interface" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString1 */'],
149+
'"trait" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString2 */'],
150+
'"enum" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString3 */'],
151+
'"function" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString4 */'],
152+
'"false" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString5 */'],
153+
'"default" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString6 */'],
154+
'"array" as case name' => ['/* testKeywordAsEnumCaseNameShouldBeString7 */'],
152155
];
153156

154157
}//end dataKeywordAsEnumCaseNameShouldBeString()

0 commit comments

Comments
 (0)