@@ -25,33 +25,42 @@ class EnumRequirementTest extends TestCase
25
25
public function testNotABackedEnum ()
26
26
{
27
27
$ this ->expectException (InvalidArgumentException::class);
28
- $ this ->expectExceptionMessage ('"Symfony\Component\Routing\Tests\Fixtures\Enum\TestUnitEnum" is not a \ BackedEnum class. ' );
28
+ $ this ->expectExceptionMessage ('"Symfony\Component\Routing\Tests\Fixtures\Enum\TestUnitEnum" is not a " BackedEnum" class. ' );
29
29
30
30
new EnumRequirement (TestUnitEnum::class);
31
31
}
32
32
33
+ public function testCaseNotABackedEnum ()
34
+ {
35
+ $ this ->expectException (InvalidArgumentException::class);
36
+ $ this ->expectExceptionMessage ('Case must be a "BackedEnum" instance, "string" given. ' );
37
+
38
+ new EnumRequirement (['wrong ' ]);
39
+ }
40
+
33
41
public function testCaseFromAnotherEnum ()
34
42
{
35
43
$ this ->expectException (InvalidArgumentException::class);
36
44
$ this ->expectExceptionMessage ('"Symfony\Component\Routing\Tests\Fixtures\Enum\TestStringBackedEnum2::Spades" is not a case of "Symfony\Component\Routing\Tests\Fixtures\Enum\TestStringBackedEnum". ' );
37
45
38
- new EnumRequirement (TestStringBackedEnum::class, TestStringBackedEnum:: Diamonds, TestStringBackedEnum2::Spades);
46
+ new EnumRequirement ([ TestStringBackedEnum::Diamonds, TestStringBackedEnum2::Spades] );
39
47
}
40
48
41
49
/**
42
50
* @dataProvider provideToString
43
51
*/
44
- public function testToString (string $ expected , string $ enum , \ BackedEnum ... $ cases )
52
+ public function testToString (string $ expected , string | array $ cases = [] )
45
53
{
46
- $ this ->assertSame ($ expected , (string ) new EnumRequirement ($ enum , ... $ cases ));
54
+ $ this ->assertSame ($ expected , (string ) new EnumRequirement ($ cases ));
47
55
}
48
56
49
57
public function provideToString ()
50
58
{
51
59
return [
52
60
['hearts|diamonds|clubs|spades ' , TestStringBackedEnum::class],
53
61
['10|20|30|40 ' , TestIntBackedEnum::class],
54
- ['diamonds|spades ' , TestStringBackedEnum::class, TestStringBackedEnum::Diamonds, TestStringBackedEnum::Spades],
62
+ ['diamonds|spades ' , [TestStringBackedEnum::Diamonds, TestStringBackedEnum::Spades]],
63
+ ['diamonds ' , [TestStringBackedEnum::Diamonds]],
55
64
['hearts|diamonds|clubs|spa\|des ' , TestStringBackedEnum2::class],
56
65
];
57
66
}
0 commit comments