From b575ab3917e4bb7cdd2f1bfe86b6da4aa632d797 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Tue, 9 Apr 2024 19:37:33 +0400 Subject: [PATCH] Add test; fix psalm --- src/Internal/Client/WorkflowStub.php | 1 + .../Client/UntypedWorkflowStubTestCase.php | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/Internal/Client/WorkflowStub.php b/src/Internal/Client/WorkflowStub.php index d6fb041f..028efdeb 100644 --- a/src/Internal/Client/WorkflowStub.php +++ b/src/Internal/Client/WorkflowStub.php @@ -513,6 +513,7 @@ function (DescribeInput $input): WorkflowExecutionDescription { $response = $this->serviceClient->DescribeWorkflowExecution($request); $mapper = new WorkflowExecutionInfoMapper($this->converter); + /** @psalm-suppress PossiblyNullArgument */ return new WorkflowExecutionDescription( info: $mapper->fromMessage($response->getWorkflowExecutionInfo()), ); diff --git a/tests/Functional/Client/UntypedWorkflowStubTestCase.php b/tests/Functional/Client/UntypedWorkflowStubTestCase.php index fecf99f8..dd91ec0a 100644 --- a/tests/Functional/Client/UntypedWorkflowStubTestCase.php +++ b/tests/Functional/Client/UntypedWorkflowStubTestCase.php @@ -19,6 +19,7 @@ use Temporal\Exception\IllegalStateException; use Temporal\Exception\InvalidArgumentException; use Temporal\Tests\Unit\Declaration\Fixture\WorkflowWithoutHandler; +use Temporal\Workflow\WorkflowExecutionStatus; /** * @group client @@ -212,6 +213,31 @@ public function testTerminated() } } + public function testDescribe(): void + { + $client = $this->createClient(); + $simple = $client->newUntypedWorkflowStub('SimpleSignalledWorkflowWithSleep'); + + $e = $client->start($simple, -1); + + $stubDescription = $simple->describe(); + $runDescription = $e->describe(); + + self::assertEquals($stubDescription, $runDescription); + self::assertSame(WorkflowExecutionStatus::Running, $runDescription->info->status); + + $simple->terminate('user triggered'); + // Wait a little bit for the workflow to terminate + \usleep(1000); + + $stubDescription = $simple->describe(); + $runDescription = $e->describe(); + + // After termination + self::assertEquals($stubDescription, $runDescription); + self::assertSame(WorkflowExecutionStatus::Terminated, $runDescription->info->status); + } + public function testSignalRunningWorkflowWithInheritedSignal() { $client = $this->createClient();