Skip to content

Commit 82ff905

Browse files
authored
Merge pull request #652: Expose Root Workflow Execution in Workflow scope
2 parents a5f0489 + e4b9ddb commit 82ff905

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/Workflow/WorkflowInfo.php

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

108+
/**
109+
* @since SDK 2.16.0
110+
*/
111+
#[Marshal(name: 'RootWorkflowExecution', type: NullableType::class, of: WorkflowExecution::class)]
112+
public ?WorkflowExecution $rootExecution = null;
113+
108114
#[Marshal(name: 'ParentWorkflowExecution', type: NullableType::class, of: WorkflowExecution::class)]
109115
public ?WorkflowExecution $parentExecution = null;
110116

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
}

tests/Unit/DTO/WorkflowInfoTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function testMarshalling(): void
4242
'CronSchedule' => null,
4343
'ContinuedExecutionRunID' => null,
4444
'ParentWorkflowNamespace' => null,
45+
'RootWorkflowExecution' => null,
4546
'ParentWorkflowExecution' => null,
4647
'SearchAttributes' => null,
4748
'TypedSearchAttributes' => [],

0 commit comments

Comments
 (0)