File tree 4 files changed +22
-1
lines changed
Fixtures/BackedEnums/State
4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ private static function getTransitions(UnitEnum $currentTransition): array
50
50
);
51
51
52
52
$ transitions = $ transitions [$ currentTransition ->name ]
53
+ ?? $ transitions [strtolower ($ currentTransition ->name )]
53
54
?? $ transitions [EnumValue::value ($ currentTransition )]
54
55
?? [];
55
56
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Henzeb \Enumhancer \Tests \Fixtures \BackedEnums \State ;
4
+
5
+ use Henzeb \Enumhancer \Concerns \State ;
6
+
7
+ enum PostStatus: string
8
+ {
9
+ use State;
10
+
11
+ case DRAFT = 'DRAFT ' ;
12
+ case READY = 'READY ' ;
13
+ case PUBLISHED = 'PUBLISHED ' ;
14
+ case ARCHIVED = 'ARCHIVED ' ;
15
+ }
Original file line number Diff line number Diff line change 4
4
5
5
use Henzeb \Enumhancer \Contracts \TransitionHook ;
6
6
use Henzeb \Enumhancer \Exceptions \IllegalEnumTransitionException ;
7
+ use Henzeb \Enumhancer \Tests \Fixtures \BackedEnums \State \PostStatus ;
7
8
use Henzeb \Enumhancer \Tests \Fixtures \UnitEnums \State \StateElevatorComplexEnum ;
8
9
use Henzeb \Enumhancer \Tests \Fixtures \UnitEnums \State \StateElevatorDisableTransitionEnum ;
9
10
use Henzeb \Enumhancer \Tests \Fixtures \UnitEnums \State \StateElevatorEnum ;
@@ -313,4 +314,9 @@ public function testMagicCallsWithHooks(): void
313
314
314
315
StateElevatorEnum::Open->toMove ();
315
316
}
317
+
318
+ public function testStatesWithBackedEnum (): void
319
+ {
320
+ $ this ->assertEquals (PostStatus::DRAFT ->to (PostStatus::READY ), PostStatus::READY );
321
+ }
316
322
}
Original file line number Diff line number Diff line change @@ -138,7 +138,6 @@ public function testShouldJustCastWhenEnumIsNotStatefulValue()
138
138
139
139
public function testShouldAllowTransition ()
140
140
{
141
- $ this ->expectException (IllegalEnumTransitionException::class);
142
141
$ model = new CastsStatefulEnumsModel ();
143
142
144
143
$ model ->stringBackedEnum = StringBackedGetEnum::TEST ;
You can’t perform that action at this time.
0 commit comments