-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ add unit tests for RepresentativeCompanyUserRestApiPermission bundl…
…e (#327) ✅ add unit tests for RepresentativeCompanyUserRestApiPermission bundle
- Loading branch information
1 parent
b21ad55
commit f49ed96
Showing
6 changed files
with
455 additions
and
10 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
63 changes: 63 additions & 0 deletions
63
...endency/Client/RepresentativeCompanyUserRestApiPermissionToZedRequestClientBridgeTest.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,63 @@ | ||
<?php | ||
|
||
namespace FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Dependency\Client; | ||
|
||
use Codeception\Test\Unit; | ||
use Spryker\Client\ZedRequest\ZedRequestClientInterface; | ||
use Spryker\Shared\Kernel\Transfer\TransferInterface; | ||
|
||
class RepresentativeCompanyUserRestApiPermissionToZedRequestClientBridgeTest extends Unit | ||
{ | ||
/** | ||
* @var \PHPUnit\Framework\MockObject\MockObject|\Spryker\Client\ZedRequest\ZedRequestClientInterface | ||
*/ | ||
protected $zedRequestClientMock; | ||
|
||
/** | ||
* @var \PHPUnit\Framework\MockObject\MockObject|\Spryker\Shared\Kernel\Transfer\TransferInterface | ||
*/ | ||
protected $transferMock; | ||
|
||
/** | ||
* @var \FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Dependency\Client\RepresentativeCompanyUserRestApiPermissionToZedRequestBridge | ||
*/ | ||
protected $zedRequestClientBridge; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function _before(): void | ||
{ | ||
parent::_before(); | ||
|
||
$this->zedRequestClientMock = $this->getMockBuilder(ZedRequestClientInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->transferMock = $this->getMockBuilder(TransferInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->zedRequestClientBridge = new RepresentativeCompanyUserRestApiPermissionToZedRequestBridge( | ||
$this->zedRequestClientMock, | ||
); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testCall(): void | ||
{ | ||
$url = 'url'; | ||
|
||
$this->zedRequestClientMock->expects(static::atLeastOnce()) | ||
->method('call') | ||
->with($url, $this->transferMock, null) | ||
->willReturn($this->transferMock); | ||
|
||
static::assertEquals( | ||
$this->transferMock, | ||
$this->zedRequestClientBridge->call($url, $this->transferMock), | ||
); | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...tiveCompanyUserRestApiPermission/RepresentativeCompanyUserRestApiPermissionClientTest.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,109 @@ | ||
<?php | ||
|
||
namespace FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission; | ||
|
||
use Codeception\Test\Unit; | ||
use FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Zed\RepresentativeCompanyUserRestApiPermissionStubInterface; | ||
use Generated\Shared\Transfer\RepresentativeCompanyUserRestApiPermissionRequestTransfer; | ||
use Generated\Shared\Transfer\RepresentativeCompanyUserRestApiPermissionResponseTransfer; | ||
|
||
class RepresentativeCompanyUserRestApiPermissionClientTest extends Unit | ||
{ | ||
/** | ||
* @var \FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\RepresentativeCompanyUserRestApiPermissionFactory|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
protected $factoryMock; | ||
|
||
/** | ||
* @var \FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Zed\RepresentativeCompanyUserRestApiPermissionStubInterface|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
protected $zedStubMock; | ||
|
||
/** | ||
* @var \Generated\Shared\Transfer\RepresentativeCompanyUserRestApiPermissionResponseTransfer|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
protected $representativeCompanyUserRestApiPermissionResponseTransferMock; | ||
|
||
/** | ||
* @var \Generated\Shared\Transfer\RepresentativeCompanyUserRestApiPermissionRequestTransfer|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
protected $representativeCompanyUserRestApiPermissionRequestTransferMock; | ||
|
||
/** | ||
* @var \FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\RepresentativeCompanyUserRestApiPermissionClient | ||
*/ | ||
protected $client; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function _before(): void | ||
{ | ||
parent::_before(); | ||
|
||
$this->factoryMock = $this->getMockBuilder(RepresentativeCompanyUserRestApiPermissionFactory::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->zedStubMock = $this->getMockBuilder(RepresentativeCompanyUserRestApiPermissionStubInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->representativeCompanyUserRestApiPermissionResponseTransferMock = $this->getMockBuilder(RepresentativeCompanyUserRestApiPermissionResponseTransfer::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->representativeCompanyUserRestApiPermissionRequestTransferMock = $this->getMockBuilder(RepresentativeCompanyUserRestApiPermissionRequestTransfer::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->client = new RepresentativeCompanyUserRestApiPermissionClient(); | ||
$this->client->setFactory($this->factoryMock); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testHasPermissionToManageGlobalRepresentations(): void | ||
{ | ||
$this->factoryMock->expects(static::atLeastOnce()) | ||
->method('createRepresentativeCompanyUserRestApiPermissionStub') | ||
->willReturn($this->zedStubMock); | ||
|
||
$this->representativeCompanyUserRestApiPermissionResponseTransferMock->expects(static::atLeastOnce()) | ||
->method('getHasPermissionToManageGlobalRepresentations') | ||
->willReturn(true); | ||
|
||
$this->zedStubMock->expects(static::atLeastOnce()) | ||
->method('hasPermissionToManageGlobalRepresentations') | ||
->with($this->representativeCompanyUserRestApiPermissionRequestTransferMock) | ||
->willReturn($this->representativeCompanyUserRestApiPermissionResponseTransferMock); | ||
|
||
static::assertTrue( | ||
$this->client->hasPermissionToManageGlobalRepresentations($this->representativeCompanyUserRestApiPermissionRequestTransferMock), | ||
); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testHasPermissionToManageOwnRepresentations(): void | ||
{ | ||
$this->factoryMock->expects(static::atLeastOnce()) | ||
->method('createRepresentativeCompanyUserRestApiPermissionStub') | ||
->willReturn($this->zedStubMock); | ||
|
||
$this->representativeCompanyUserRestApiPermissionResponseTransferMock->expects(static::atLeastOnce()) | ||
->method('getHasPermissionToManageOwnRepresentations') | ||
->willReturn(true); | ||
|
||
$this->zedStubMock->expects(static::atLeastOnce()) | ||
->method('hasPermissionToManageOwnRepresentations') | ||
->with($this->representativeCompanyUserRestApiPermissionRequestTransferMock) | ||
->willReturn($this->representativeCompanyUserRestApiPermissionResponseTransferMock); | ||
|
||
static::assertTrue( | ||
$this->client->hasPermissionToManageOwnRepresentations($this->representativeCompanyUserRestApiPermissionRequestTransferMock), | ||
); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...iveCompanyUserRestApiPermission/RepresentativeCompanyUserRestApiPermissionFactoryTest.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,65 @@ | ||
<?php | ||
|
||
namespace FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission; | ||
|
||
use Codeception\Test\Unit; | ||
use FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Dependency\Client\RepresentativeCompanyUserRestApiPermissionToZedRequestInterface; | ||
use FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Zed\RepresentativeCompanyUserRestApiPermissionStub; | ||
use Spryker\Client\Kernel\Container; | ||
|
||
class RepresentativeCompanyUserRestApiPermissionFactoryTest extends Unit | ||
{ | ||
/** | ||
* @var \PHPUnit\Framework\MockObject\MockObject|\Spryker\Client\Kernel\Container | ||
*/ | ||
protected $containerMock; | ||
|
||
/** | ||
* @var \FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Dependency\Client\RepresentativeCompanyUserRestApiPermissionToZedRequestInterface|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
protected $zedRequestClientMock; | ||
|
||
/** | ||
* @var \FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\RepresentativeCompanyUserRestApiPermissionFactory | ||
*/ | ||
protected $factory; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function _before(): void | ||
{ | ||
parent::_before(); | ||
|
||
$this->containerMock = $this->getMockBuilder(Container::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->zedRequestClientMock = $this->getMockBuilder(RepresentativeCompanyUserRestApiPermissionToZedRequestInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->factory = new RepresentativeCompanyUserRestApiPermissionFactory(); | ||
$this->factory->setContainer($this->containerMock); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testCreateZedRepresentativeCompanyUserRestApiPermissionStub(): void | ||
{ | ||
$this->containerMock->expects(static::atLeastOnce()) | ||
->method('has') | ||
->willReturn(true); | ||
|
||
$this->containerMock->expects(static::atLeastOnce()) | ||
->method('get') | ||
->with(RepresentativeCompanyUserRestApiPermissionDependencyProvider::CLIENT_ZED_REQUEST) | ||
->willReturn($this->zedRequestClientMock); | ||
|
||
static::assertInstanceOf( | ||
RepresentativeCompanyUserRestApiPermissionStub::class, | ||
$this->factory->createRepresentativeCompanyUserRestApiPermissionStub(), | ||
); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...veCompanyUserRestApiPermission/Zed/RepresentativeCompanyUserRestApiPermissionStubTest.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,89 @@ | ||
<?php | ||
|
||
namespace FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Zed; | ||
|
||
use Codeception\Test\Unit; | ||
use FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Dependency\Client\RepresentativeCompanyUserRestApiPermissionToZedRequestInterface; | ||
use Generated\Shared\Transfer\RepresentativeCompanyUserRestApiPermissionRequestTransfer; | ||
use Generated\Shared\Transfer\RepresentativeCompanyUserRestApiPermissionResponseTransfer; | ||
|
||
class RepresentativeCompanyUserRestApiPermissionStubTest extends Unit | ||
{ | ||
/** | ||
* @var \Generated\Shared\Transfer\RepresentativeCompanyUserRestApiPermissionRequestTransfer|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
protected $representativeCompanyUserRestApiPermissionRequestTransferMock; | ||
|
||
/** | ||
* @var \Generated\Shared\Transfer\RepresentativeCompanyUserRestApiPermissionResponseTransfer|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
protected $representativeCompanyUserRestApiPermissionResponseTransferMock; | ||
|
||
/** | ||
* @var \FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Dependency\Client\RepresentativeCompanyUserRestApiPermissionToZedRequestInterface|\PHPUnit\Framework\MockObject\MockObject | ||
*/ | ||
protected $zedRequestClientMock; | ||
|
||
/** | ||
* @var \FondOfOryx\Client\RepresentativeCompanyUserRestApiPermission\Zed\RepresentativeCompanyUserRestApiPermissionStub | ||
*/ | ||
protected $stub; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function _before(): void | ||
{ | ||
parent::_before(); | ||
|
||
$this->representativeCompanyUserRestApiPermissionRequestTransferMock = $this->getMockBuilder(RepresentativeCompanyUserRestApiPermissionRequestTransfer::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->representativeCompanyUserRestApiPermissionResponseTransferMock = $this->getMockBuilder(RepresentativeCompanyUserRestApiPermissionResponseTransfer::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->zedRequestClientMock = $this->getMockBuilder(RepresentativeCompanyUserRestApiPermissionToZedRequestInterface::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->stub = new RepresentativeCompanyUserRestApiPermissionStub($this->zedRequestClientMock); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testHasPermissionToManageGlobalRepresentations(): void | ||
{ | ||
$this->zedRequestClientMock->expects(static::atLeastOnce()) | ||
->method('call') | ||
->with( | ||
'/representative-company-user-rest-api-permission/gateway/has-permission-to-manage-global-representations', | ||
$this->representativeCompanyUserRestApiPermissionRequestTransferMock, | ||
)->willReturn($this->representativeCompanyUserRestApiPermissionResponseTransferMock); | ||
|
||
static::assertEquals( | ||
$this->representativeCompanyUserRestApiPermissionResponseTransferMock, | ||
$this->stub->hasPermissionToManageGlobalRepresentations($this->representativeCompanyUserRestApiPermissionRequestTransferMock), | ||
); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testHasPermissionToManageOwnRepresentations(): void | ||
{ | ||
$this->zedRequestClientMock->expects(static::atLeastOnce()) | ||
->method('call') | ||
->with( | ||
'/representative-company-user-rest-api-permission/gateway/has-permission-to-manage-own-representations', | ||
$this->representativeCompanyUserRestApiPermissionRequestTransferMock, | ||
)->willReturn($this->representativeCompanyUserRestApiPermissionResponseTransferMock); | ||
|
||
static::assertEquals( | ||
$this->representativeCompanyUserRestApiPermissionResponseTransferMock, | ||
$this->stub->hasPermissionToManageOwnRepresentations($this->representativeCompanyUserRestApiPermissionRequestTransferMock), | ||
); | ||
} | ||
} |
Oops, something went wrong.