From 468ac78ac8e7344620a96f6d306f18ad11b11da4 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Mon, 3 Jun 2024 20:05:21 +0400 Subject: [PATCH] Add tests --- src/Client/GRPC/Context.php | 2 +- tests/Unit/Client/GRPC/BaseClientTestCase.php | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Client/GRPC/Context.php b/src/Client/GRPC/Context.php index 3ba0279f..12b9034d 100644 --- a/src/Client/GRPC/Context.php +++ b/src/Client/GRPC/Context.php @@ -43,7 +43,7 @@ public function withTimeout($timeout, string $format = DateInterval::FORMAT_SECO $ctx = clone $this; $ctx->timeout = $internal; - $ctx->deadline =null; + $ctx->deadline = null; return $ctx; } diff --git a/tests/Unit/Client/GRPC/BaseClientTestCase.php b/tests/Unit/Client/GRPC/BaseClientTestCase.php index 36adcfe7..66d6222f 100644 --- a/tests/Unit/Client/GRPC/BaseClientTestCase.php +++ b/tests/Unit/Client/GRPC/BaseClientTestCase.php @@ -16,7 +16,6 @@ use Temporal\Client\GRPC\ContextInterface; use Temporal\Client\GRPC\ServiceClient; use Temporal\Client\GRPC\StatusCode; -use Temporal\Common\RetryOptions; use Temporal\Exception\Client\ServiceClientException; use Temporal\Exception\Client\TimeoutException; use Temporal\Internal\Interceptor\Pipeline; @@ -87,6 +86,30 @@ public function testWithContext(): void $this->assertNotSame($client, $client2); } + public function testWithTimeoutDynamicDeadline(): void + { + $client = $this->createClientMock(); + $context = $client->getContext()->withTimeout(1.234); + + $this->assertNotSame($context->getDeadline(), $context->getDeadline()); + } + + public function testContextGetDeadlineWithoutDeadline(): void + { + $client = $this->createClientMock(); + $context = $client->getContext(); + + $this->assertNull($context->getDeadline()); + } + + public function testContextGetDeadlineWithStaticDeadline(): void + { + $client = $this->createClientMock(); + $context = $client->getContext()->withDeadline(new DateTimeImmutable('+1 second')); + + $this->assertSame($context->getDeadline(), $context->getDeadline()); + } + public function testWithAuthKey(): void { $client = $this->createClientMock();