-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix decoding of search attributes in `Workflow::getInfo()->searchAttr…
…ibutes`
- Loading branch information
Showing
3 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/Acceptance/Extra/Workflow/ChildWorkflowSearchAttributesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Tests\Acceptance\Extra\Workflow\ChildWorkflowSearchAttributes; | ||
|
||
use PHPUnit\Framework\Attributes\CoversFunction; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Temporal\Client\WorkflowStubInterface; | ||
use Temporal\Tests\Acceptance\App\Attribute\Stub; | ||
use Temporal\Tests\Acceptance\App\TestCase; | ||
use Temporal\Workflow; | ||
use Temporal\Workflow\WorkflowInterface; | ||
use Temporal\Workflow\WorkflowMethod; | ||
|
||
#[CoversFunction('Temporal\Internal\Workflow\Process\Process::logRunningHandlers')] | ||
class ChildWorkflowSearchAttributesTest extends TestCase | ||
{ | ||
#[Test] | ||
public function updateHandlersWithOneCall( | ||
#[Stub( | ||
'Extra_Workflow_ChildWorkflowSearchAttributes', | ||
args: [ | ||
['foo' => 'bar'], | ||
], | ||
)] | ||
WorkflowStubInterface $stub, | ||
): void { | ||
$result = $stub->getResult('array', timeout: 3); | ||
$this->assertSame(['foo' => 'bar'], $result, 'Workflow result contains resolved value'); | ||
} | ||
} | ||
|
||
#[WorkflowInterface] | ||
class TestWorkflow | ||
{ | ||
#[WorkflowMethod(name: "Extra_Workflow_ChildWorkflowSearchAttributes")] | ||
public function handle(array $searchAttributes): \Generator | ||
{ | ||
return yield Workflow::newChildWorkflowStub( | ||
TestWorkflowChild::class, | ||
Workflow\ChildWorkflowOptions::new() | ||
->withSearchAttributes($searchAttributes) | ||
->withTaskQueue(Workflow::getInfo()->taskQueue) | ||
)->handle(); | ||
} | ||
} | ||
|
||
#[WorkflowInterface] | ||
class TestWorkflowChild | ||
{ | ||
#[WorkflowMethod(name: "Extra_Workflow_ChildWorkflowSearchAttributes_Child")] | ||
public function handle(): array | ||
{ | ||
return Workflow::getInfo()->searchAttributes; | ||
} | ||
} |