Skip to content

Commit 8861fb7

Browse files
committed
feat: Expose Root Workflow Execution in Workflow scope
1 parent a5f0489 commit 8861fb7

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Workflow/WorkflowInfo.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ final class WorkflowInfo
105105
#[Marshal(name: 'ParentWorkflowNamespace')]
106106
public ?string $parentNamespace = null;
107107

108+
#[Marshal(name: 'RootWorkflowExecution', type: NullableType::class, of: WorkflowExecution::class)]
109+
public ?WorkflowExecution $rootExecution = null;
110+
108111
#[Marshal(name: 'ParentWorkflowExecution', type: NullableType::class, of: WorkflowExecution::class)]
109112
public ?WorkflowExecution $parentExecution = null;
110113

tests/Acceptance/Extra/Workflow/RootWorkflowExecutionTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ class RootWorkflowExecutionTest extends TestCase
1717
#[Test]
1818
public static function check(#[Stub('Extra_Workflow_RootWorkflowExecution')]WorkflowStubInterface $stub): void
1919
{
20-
self::markTestSkipped('Waiting https://github.com/temporalio/sdk-go/issues/1848');
21-
self::assertSame('Test', $stub->getResult());
20+
$result = $stub->getResult(type: 'array');
21+
self::assertSame([
22+
'ID' => $stub->getExecution()->getID(),
23+
'RunID' => $stub->getExecution()->getRunID(),
24+
], $result);
2225
}
2326
}
2427

@@ -37,19 +40,19 @@ public function run()
3740
class ChildWorkflow
3841
{
3942
#[WorkflowMethod('Extra_Workflow_RootWorkflowExecution_Child')]
40-
public function run(string $input)
43+
public function run()
4144
{
4245
return yield Workflow::newChildWorkflowStub(ChildWorkflow2::class)
43-
->run($input);
46+
->run();
4447
}
4548
}
4649

4750
#[WorkflowInterface]
4851
class ChildWorkflow2
4952
{
5053
#[WorkflowMethod('Extra_Workflow_RootWorkflowExecution_Child2')]
51-
public function run(string $input)
54+
public function run()
5255
{
53-
return $input;
56+
return Workflow::getCurrentContext()->getInfo()->rootExecution;
5457
}
5558
}

0 commit comments

Comments
 (0)