File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Safemood \Workflow \Action ;
4
+ use Safemood \Workflow \Enums \ActionState ;
5
+
6
+ it ('can set and get the state using ActionState ' , function () {
7
+ $ action = new class extends Action {
8
+ public function handle (array &$ context ) {}
9
+ };
10
+
11
+ $ action ->setState (ActionState::PENDING );
12
+
13
+ expect ($ action ->getState ())->toBe (ActionState::PENDING );
14
+
15
+ $ action ->setState (ActionState::SUCCESS );
16
+
17
+ expect ($ action ->getState ())->toBe (ActionState::SUCCESS );
18
+ });
19
+
20
+ it ('can set and get the exception ' , function () {
21
+ $ action = new class extends Action {
22
+ public function handle (array &$ context ) {}
23
+ };
24
+
25
+ $ exception = new \Exception ('Test Exception ' );
26
+ $ action ->setException ($ exception );
27
+
28
+ expect ($ action ->getException ())->toBe ($ exception );
29
+ });
30
+
31
+ it ('should handle the abstract handle method ' , function () {
32
+ $ action = new class extends Action {
33
+ public function handle (array &$ context ) {
34
+ // Example handle logic
35
+ $ context ['handled ' ] = true ;
36
+ }
37
+ };
38
+
39
+ $ context = [];
40
+ $ action ->handle ($ context );
41
+
42
+ expect ($ context ['handled ' ])->toBeTrue ();
43
+ });
You can’t perform that action at this time.
0 commit comments