summaryrefslogtreecommitdiff
path: root/tests/temporal/Workflow/ActivityStubWorkflow.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/temporal/Workflow/ActivityStubWorkflow.php')
-rw-r--r--tests/temporal/Workflow/ActivityStubWorkflow.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/temporal/Workflow/ActivityStubWorkflow.php b/tests/temporal/Workflow/ActivityStubWorkflow.php
new file mode 100644
index 00000000..58dcdafb
--- /dev/null
+++ b/tests/temporal/Workflow/ActivityStubWorkflow.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Temporal\Tests\Workflow;
+
+use Temporal\Activity\ActivityOptions;
+use Temporal\Tests\Activity\SimpleActivity;
+use Temporal\Workflow;
+use Temporal\Workflow\WorkflowMethod;
+
+#[Workflow\WorkflowInterface]
+class ActivityStubWorkflow
+{
+ #[WorkflowMethod(name: 'ActivityStubWorkflow')]
+ public function handler(
+ string $input
+ ) {
+ // typed stub
+ $simple = Workflow::newActivityStub(
+ SimpleActivity::class,
+ ActivityOptions::new()->withStartToCloseTimeout(5)
+ );
+
+ $result = [];
+ $result[] = yield $simple->echo($input);
+
+ try {
+ $simple->undefined($input);
+ } catch (\BadMethodCallException $e) {
+ $result[] = 'invalid method call';
+ }
+
+ // untyped stub
+ $untyped = Workflow::newUntypedActivityStub(ActivityOptions::new()->withStartToCloseTimeout(1));
+
+ $result[] = yield $untyped->execute('SimpleActivity.echo', ['untyped']);
+
+ return $result;
+ }
+}