diff --git a/src/Internal/Workflow/Process/Scope.php b/src/Internal/Workflow/Process/Scope.php index 545ba177..bf5f3bb9 100644 --- a/src/Internal/Workflow/Process/Scope.php +++ b/src/Internal/Workflow/Process/Scope.php @@ -435,6 +435,7 @@ protected function next(): void } $current = $this->coroutine->current(); + $this->context->resolveConditions(); switch (true) { case $current instanceof PromiseInterface: diff --git a/tests/Fixtures/src/Workflow/Case335Workflow.php b/tests/Fixtures/src/Workflow/Case335Workflow.php new file mode 100644 index 00000000..1b1f1ba9 --- /dev/null +++ b/tests/Fixtures/src/Workflow/Case335Workflow.php @@ -0,0 +1,38 @@ +exit = true; + + yield Workflow::timer(1); + + $this->timerRun = true; + } + + #[WorkflowMethod('case335_workflow')] + public function run() + { + yield Workflow::await(fn() => $this->exit); + return $this->timerRun; + } +} diff --git a/tests/Functional/Client/TypedStubTestCase.php b/tests/Functional/Client/TypedStubTestCase.php index 71ae7ba0..008f04f9 100644 --- a/tests/Functional/Client/TypedStubTestCase.php +++ b/tests/Functional/Client/TypedStubTestCase.php @@ -16,6 +16,7 @@ use Temporal\Tests\DTO\User; use Temporal\Tests\Unit\Declaration\Fixture\WorkflowWithoutHandler; use Temporal\Tests\Workflow\ActivityReturnTypeWorkflow; +use Temporal\Tests\Workflow\Case335Workflow; use Temporal\Tests\Workflow\GeneratorWorkflow; use Temporal\Tests\Workflow\QueryWorkflow; use Temporal\Tests\Workflow\SignalledWorkflowReusable; @@ -159,4 +160,15 @@ public function testSignalRunningWorkflowWithInheritedSignalViaParentInterface() $result = $workflowRun->getResult(); $this->assertEquals(['test1'], $result); } + + public function testSignalResolvesCondidtionsBeforePromiseRun() + { + $client = $this->createClient(); + + $workflow = $client->newWorkflowStub(Case335Workflow::class); + $workflowRun = $client->startWithSignal($workflow, 'signal'); + + $result = $workflowRun->getResult('bool', 5); + $this->assertFalse($result); + } }