diff options
Diffstat (limited to 'tests/temporal/Workflow/CancelledWorkflow.php')
-rw-r--r-- | tests/temporal/Workflow/CancelledWorkflow.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/temporal/Workflow/CancelledWorkflow.php b/tests/temporal/Workflow/CancelledWorkflow.php new file mode 100644 index 00000000..be9f7542 --- /dev/null +++ b/tests/temporal/Workflow/CancelledWorkflow.php @@ -0,0 +1,31 @@ +<?php + +namespace Temporal\Tests\Workflow; + +use Temporal\Activity\ActivityOptions; +use Temporal\Exception\Failure\CanceledFailure; +use Temporal\Tests\Activity\SimpleActivity; +use Temporal\Workflow; +use Temporal\Workflow\WorkflowMethod; + +#[Workflow\WorkflowInterface] +class CancelledWorkflow +{ + #[WorkflowMethod(name: 'CancelledWorkflow')] + public function handler() + { + $simple = Workflow::newActivityStub( + SimpleActivity::class, + ActivityOptions::new()->withStartToCloseTimeout(5) + ); + + // waits for 2 seconds + $slow = $simple->slow('DOING SLOW ACTIVITY'); + + try { + return yield $slow; + } catch (CanceledFailure $e) { + return "CANCELLED"; + } + } +} |