-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
static
keyword in WorkflowException::withoutMessage method (#189)
::withoutMessage method is used in classes which extends WorkflowException
- Loading branch information
Showing
2 changed files
with
73 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Tests\Unit\Internal\Client; | ||
|
||
use Temporal\Client\ClientOptions; | ||
use Temporal\Client\GRPC\ServiceClientInterface; | ||
use Temporal\Client\GRPC\StatusCode; | ||
use Temporal\DataConverter\DataConverterInterface; | ||
use Temporal\Exception\Client\ServiceClientException; | ||
use Temporal\Exception\Client\WorkflowNotFoundException; | ||
use Temporal\Exception\Client\WorkflowServiceException; | ||
use Temporal\Internal\Client\WorkflowStub; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Temporal\Workflow\WorkflowExecution; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @covers \Temporal\Internal\Client\WorkflowStub | ||
*/ | ||
final class WorkflowStubTest extends TestCase | ||
{ | ||
private WorkflowStub $workflowStub; | ||
/** @var MockObject|ServiceClientInterface */ | ||
private $serviceClient; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->serviceClient = $this->createMock(ServiceClientInterface::class); | ||
$this->workflowStub = new WorkflowStub( | ||
$this->serviceClient, | ||
new ClientOptions(), | ||
$this->createMock(DataConverterInterface::class), | ||
); | ||
$this->workflowStub->setExecution(new WorkflowExecution()); | ||
} | ||
|
||
public function testSignalThrowsWorkflowNotFoundException(): void | ||
{ | ||
$status = new \stdClass(); | ||
$status->details = 'status details'; | ||
$status->code = StatusCode::NOT_FOUND; | ||
$serviceClientException = new ServiceClientException($status); | ||
$this->serviceClient | ||
->expects(static::once()) | ||
->method('SignalWorkflowExecution') | ||
->willThrowException($serviceClientException); | ||
|
||
static::expectException(WorkflowNotFoundException::class); | ||
|
||
$this->workflowStub->signal('signalName'); | ||
} | ||
|
||
public function testSignalThrowsWorkflowServiceException(): void | ||
{ | ||
$status = new \stdClass(); | ||
$status->details = 'status details'; | ||
$status->code = StatusCode::INTERNAL; | ||
$serviceClientException = new ServiceClientException($status); | ||
$this->serviceClient | ||
->expects(static::once()) | ||
->method('SignalWorkflowExecution') | ||
->willThrowException($serviceClientException); | ||
|
||
static::expectException(WorkflowServiceException::class); | ||
|
||
$this->workflowStub->signal('signalName'); | ||
} | ||
} |