88use React \Promise \PromiseInterface ;
99use Temporal \Client \WorkflowStubInterface ;
1010use Temporal \DataConverter \Type ;
11+ use Temporal \Exception \Failure \CanceledFailure ;
1112use Temporal \Tests \Acceptance \App \Attribute \Stub ;
1213use Temporal \Tests \Acceptance \App \TestCase ;
1314use Temporal \Workflow ;
@@ -28,6 +29,7 @@ public function runLockedWithGeneratorAndAwait(
2829 $ this ->assertTrue ($ result [0 ], 'Mutex must be unlocked after runLocked is finished ' );
2930 $ this ->assertTrue ($ result [1 ], 'The function inside runLocked mist wait for signal ' );
3031 $ this ->assertTrue ($ result [2 ], 'Mutex must be locked during runLocked ' );
32+ $ this ->assertNull ($ result [3 ], 'No exception must be thrown ' );
3133 }
3234
3335 #[Test]
@@ -41,6 +43,7 @@ public function runLockedAndCancel(
4143
4244 $ this ->assertTrue ($ result [0 ], 'Mutex must be unlocked after runLocked is cancelled ' );
4345 $ this ->assertNull ($ result [2 ], 'Mutex must be locked during runLocked ' );
46+ $ this ->assertSame (CanceledFailure::class, $ result [3 ], 'CanceledFailure must be thrown ' );
4447 }
4548}
4649
@@ -64,7 +67,12 @@ public function __construct()
6467 #[Workflow \ReturnType(Type::TYPE_ARRAY )]
6568 public function handle (): \Generator
6669 {
67- $ result = yield $ this ->promise = Workflow::runLocked ($ this ->mutex , $ this ->runLocked (...));
70+ $ exception = null ;
71+ try {
72+ $ result = yield $ this ->promise = Workflow::runLocked ($ this ->mutex , $ this ->runLocked (...));
73+ } catch (\Throwable $ e ) {
74+ $ exception = $ e ::class;
75+ }
6876
6977 $ trailed = false ;
7078 yield Workflow::await (
@@ -78,7 +86,7 @@ public function handle(): \Generator
7886 // that was created inside the first runLocked
7987 $ trailed and throw new \Exception ('The trailed runLocked must not be executed. ' );
8088
81- return [$ this ->unlocked , $ this ->unblock , $ result ];
89+ return [$ this ->unlocked , $ this ->unblock , $ result, $ exception ];
8290 }
8391
8492 #[Workflow \SignalMethod]
0 commit comments