-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from commercetools/gen-sdk-updates
- Loading branch information
Showing
146 changed files
with
9,599 additions
and
73 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
157 changes: 157 additions & 0 deletions
157
...lient/Resource/ResourceByProjectKeyCategoriesImportContainersByImportContainerKeyTest.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,157 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file has been auto generated | ||
* Do not change it. | ||
*/ | ||
|
||
namespace Commercetools\Import\Test\Client\Resource; | ||
|
||
use Commercetools\Base\JsonObject; | ||
use Commercetools\Client\ApiRequest; | ||
use Commercetools\Exception\ApiClientException; | ||
use Commercetools\Exception\ApiServerException; | ||
use Commercetools\Import\Client\ImportRequestBuilder; | ||
use GuzzleHttp\ClientInterface; | ||
use GuzzleHttp\Exception\ClientException; | ||
use GuzzleHttp\Exception\ServerException; | ||
use GuzzleHttp\Psr7\Response; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
* @covers \Commercetools\Import\Client\Resource\ByProjectKeyCategoriesImportContainersByImportContainerKeyPost | ||
* @covers \Commercetools\Import\Client\Resource\ResourceByProjectKeyCategoriesImportContainersByImportContainerKey | ||
*/ | ||
class ResourceByProjectKeyCategoriesImportContainersByImportContainerKeyTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getRequests() | ||
*/ | ||
public function testBuilder(callable $builderFunction, string $method, string $relativeUri, string $body = null) | ||
{ | ||
$builder = new ImportRequestBuilder(); | ||
$request = $builderFunction($builder); | ||
$this->assertSame(strtolower($method), strtolower($request->getMethod())); | ||
$this->assertSame($relativeUri, (string) $request->getUri()); | ||
if (!is_null($body)) { | ||
$this->assertJsonStringEqualsJsonString($body, (string) $request->getBody()); | ||
} else { | ||
$this->assertSame("", (string) $request->getBody()); | ||
} | ||
} | ||
|
||
|
||
|
||
/** | ||
* @dataProvider getRequestBuilderResponses() | ||
*/ | ||
public function testMapFromResponse(callable $builderFunction, $statusCode) | ||
{ | ||
$builder = new ImportRequestBuilder(); | ||
$request = $builderFunction($builder); | ||
$this->assertInstanceOf(ApiRequest::class, $request); | ||
|
||
$response = new Response($statusCode, [], "{}"); | ||
$this->assertInstanceOf(JsonObject::class, $request->mapFromResponse($response)); | ||
} | ||
|
||
/** | ||
* @dataProvider getRequestBuilders() | ||
*/ | ||
public function testExecuteClientException(callable $builderFunction) | ||
{ | ||
$client = $this->createMock(ClientInterface::class); | ||
|
||
$builder = new ImportRequestBuilder($client); | ||
$request = $builderFunction($builder); | ||
$client->method("send")->willThrowException(new ClientException("Oops!", $request, new Response(400))); | ||
|
||
$this->expectException(ApiClientException::class); | ||
$request->execute(); | ||
} | ||
|
||
/** | ||
* @dataProvider getRequestBuilders() | ||
*/ | ||
public function testExecuteServerException(callable $builderFunction) | ||
{ | ||
$client = $this->createMock(ClientInterface::class); | ||
|
||
$builder = new ImportRequestBuilder($client); | ||
$request = $builderFunction($builder); | ||
$client->method("send")->willThrowException(new ServerException("Oops!", $request, new Response(500))); | ||
|
||
$this->expectException(ApiServerException::class); | ||
$request->execute(); | ||
} | ||
|
||
public function getRequests() | ||
{ | ||
return [ | ||
'ByProjectKeyCategoriesImportContainersByImportContainerKeyPost' => [ | ||
function (ImportRequestBuilder $builder): RequestInterface { | ||
return $builder | ||
->withProjectKeyValue("test_projectKey") | ||
->categories() | ||
->importContainers() | ||
->withImportContainerKeyValue("test_importContainerKey") | ||
->post(null); | ||
}, | ||
'post', | ||
'test_projectKey/categories/import-containers/test_importContainerKey', | ||
] | ||
]; | ||
} | ||
|
||
public function getResources() | ||
{ | ||
return [ | ||
]; | ||
} | ||
|
||
public function getRequestBuilders() | ||
{ | ||
return [ | ||
'ByProjectKeyCategoriesImportContainersByImportContainerKeyPost' => [ | ||
function (ImportRequestBuilder $builder): RequestInterface { | ||
return $builder | ||
->withProjectKeyValue("projectKey") | ||
->categories() | ||
->importContainers() | ||
->withImportContainerKeyValue("importContainerKey") | ||
->post(null); | ||
} | ||
] | ||
]; | ||
} | ||
|
||
public function getRequestBuilderResponses() | ||
{ | ||
return [ | ||
'ByProjectKeyCategoriesImportContainersByImportContainerKeyPost_201' => [ | ||
function (ImportRequestBuilder $builder): RequestInterface { | ||
return $builder | ||
->withProjectKeyValue("projectKey") | ||
->categories() | ||
->importContainers() | ||
->withImportContainerKeyValue("importContainerKey") | ||
->post(null); | ||
}, | ||
201 | ||
], | ||
'ByProjectKeyCategoriesImportContainersByImportContainerKeyPost_599' => [ | ||
function (ImportRequestBuilder $builder): RequestInterface { | ||
return $builder | ||
->withProjectKeyValue("projectKey") | ||
->categories() | ||
->importContainers() | ||
->withImportContainerKeyValue("importContainerKey") | ||
->post(null); | ||
}, | ||
599 | ||
] | ||
]; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...rt-tests/test/unit/Client/Resource/ResourceByProjectKeyCategoriesImportContainersTest.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,81 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file has been auto generated | ||
* Do not change it. | ||
*/ | ||
|
||
namespace Commercetools\Import\Test\Client\Resource; | ||
|
||
use Commercetools\Base\JsonObject; | ||
use Commercetools\Client\ApiRequest; | ||
use Commercetools\Exception\ApiClientException; | ||
use Commercetools\Exception\ApiServerException; | ||
use Commercetools\Import\Client\ImportRequestBuilder; | ||
use Commercetools\Import\Client\Resource\ResourceByProjectKeyCategoriesImportContainersByImportContainerKey; | ||
use GuzzleHttp\ClientInterface; | ||
use GuzzleHttp\Exception\ClientException; | ||
use GuzzleHttp\Exception\ServerException; | ||
use GuzzleHttp\Psr7\Response; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
* @covers \Commercetools\Import\Client\Resource\ResourceByProjectKeyCategoriesImportContainers | ||
*/ | ||
class ResourceByProjectKeyCategoriesImportContainersTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getResources() | ||
*/ | ||
public function testResources(callable $builderFunction, string $class, array $expectedArgs) | ||
{ | ||
$builder = new ImportRequestBuilder(); | ||
$resource = $builderFunction($builder); | ||
$this->assertInstanceOf($class, $resource); | ||
$this->assertEquals($expectedArgs, $resource->getArgs()); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
public function getRequests() | ||
{ | ||
return [ | ||
]; | ||
} | ||
|
||
public function getResources() | ||
{ | ||
return [ | ||
'ResourceByProjectKeyCategoriesImportContainersByImportContainerKey' => [ | ||
function (ImportRequestBuilder $builder): ResourceByProjectKeyCategoriesImportContainersByImportContainerKey { | ||
return $builder | ||
->withProjectKeyValue("test_projectKey") | ||
->categories() | ||
->importContainers() | ||
->withImportContainerKeyValue("test_importContainerKey"); | ||
}, | ||
ResourceByProjectKeyCategoriesImportContainersByImportContainerKey::class, | ||
['projectKey' => 'test_projectKey', 'importContainerKey' => 'test_importContainerKey'], | ||
'/{projectKey}/categories/import-containers/{importContainerKey}' | ||
] | ||
]; | ||
} | ||
|
||
public function getRequestBuilders() | ||
{ | ||
return [ | ||
]; | ||
} | ||
|
||
public function getRequestBuilderResponses() | ||
{ | ||
return [ | ||
]; | ||
} | ||
} |
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
Oops, something went wrong.