File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace NeutronStars \Enum \Test \Fixture ;
6+
7+ use NeutronStars \Enum \Enum ;
8+
9+ /**
10+ * @method static self FOO()
11+ * @method static self BAR()
12+ * Class FooWithValueIntEnum
13+ * @package NeutronStars\Enum\Test\Fixture
14+ */
15+ class FooWithValueIntEnum extends Enum
16+ {
17+ public const FOO = 2 ;
18+ public const BAR = 1 ;
19+ }
Original file line number Diff line number Diff line change 66
77use NeutronStars \Enum \Error \ValueError ;
88use NeutronStars \Enum \Test \Fixture \FooWithoutValueEnum ;
9+ use NeutronStars \Enum \Test \Fixture \FooWithValueIntEnum ;
910use NeutronStars \Enum \Test \Fixture \FooWithValueStringEnum ;
1011use PHPUnit \Framework \TestCase ;
1112
@@ -104,6 +105,20 @@ public function testTryFromEnum(): void
104105 );
105106 }
106107
108+ public function testTryFromPriorityEnum (): void
109+ {
110+ $ this ->assertSame (
111+ FooWithValueIntEnum::BAR (),
112+ FooWithValueIntEnum::tryFrom (1 ),
113+ 'The value priority did not work. '
114+ );
115+ $ this ->assertSame (
116+ FooWithValueIntEnum::FOO (),
117+ FooWithValueIntEnum::tryFrom (2 ),
118+ 'The value priority did not work. '
119+ );
120+ }
121+
107122 public function testTryFromEnumWithError (): void
108123 {
109124 $ this ->assertNull (
You can’t perform that action at this time.
0 commit comments