Skip to content

Commit

Permalink
Merge pull request #101 from commercetools/gen-sdk-updates
Browse files Browse the repository at this point in the history
Update generated SDKs
  • Loading branch information
barbara79 authored Feb 10, 2023
2 parents 89c31d1 + ce70823 commit 5863d56
Show file tree
Hide file tree
Showing 347 changed files with 16,508 additions and 14,346 deletions.
220 changes: 169 additions & 51 deletions changes.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
<?php

declare(strict_types=1);
/**
* This file has been auto generated
* Do not change it.
*/

namespace Commercetools\Api\Test\Client\Resource;

use Commercetools\Api\Client\ApiRequestBuilder;
use Commercetools\Base\JsonObject;
use Commercetools\Client\ApiRequest;
use Commercetools\Exception\ApiClientException;
use Commercetools\Exception\ApiServerException;
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\Api\Client\Resource\ByProjectKeyShippingMethodsMatchingCartLocationGet
* @covers \Commercetools\Api\Client\Resource\ResourceByProjectKeyShippingMethodsMatchingCartLocation
*/
class ResourceByProjectKeyShippingMethodsMatchingCartLocationTest extends TestCase
{
/**
* @dataProvider getRequests()
*/
public function testBuilder(callable $builderFunction, string $method, string $relativeUri, string $body = null)
{
$builder = new ApiRequestBuilder();
$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 ApiRequestBuilder();
$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 ApiRequestBuilder($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 ApiRequestBuilder($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 [
'ByProjectKeyShippingMethodsMatchingCartLocationGet_withCountry' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->shippingMethods()
->matchingCartLocation()
->get()
->withCountry('country');
},
'get',
'test_projectKey/shipping-methods/matching-cart-location?country=country',
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_withState' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->shippingMethods()
->matchingCartLocation()
->get()
->withState('state');
},
'get',
'test_projectKey/shipping-methods/matching-cart-location?state=state',
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_withCartId' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->shippingMethods()
->matchingCartLocation()
->get()
->withCartId('cartId');
},
'get',
'test_projectKey/shipping-methods/matching-cart-location?cartId=cartId',
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_withExpand' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->shippingMethods()
->matchingCartLocation()
->get()
->withExpand('expand');
},
'get',
'test_projectKey/shipping-methods/matching-cart-location?expand=expand',
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("test_projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
'get',
'test_projectKey/shipping-methods/matching-cart-location',
]
];
}

public function getResources()
{
return [
];
}

public function getRequestBuilders()
{
return [
'ByProjectKeyShippingMethodsMatchingCartLocationGet' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
}
]
];
}

public function getRequestBuilderResponses()
{
return [
'ByProjectKeyShippingMethodsMatchingCartLocationGet_200' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
200
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_400' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
400
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_401' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
401
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_403' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
403
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_404' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
404
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_500' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
500
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_502' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
502
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_503' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
503
],
'ByProjectKeyShippingMethodsMatchingCartLocationGet_599' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->shippingMethods()
->matchingCartLocation()
->get();
},
599
]
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Commercetools\Api\Client\Resource\ResourceByProjectKeyShippingMethodsByID;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyShippingMethodsKeyByKey;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyShippingMethodsMatchingCart;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyShippingMethodsMatchingCartLocation;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyShippingMethodsMatchingLocation;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyShippingMethodsMatchingOrderedit;
use Commercetools\Base\JsonObject;
Expand Down Expand Up @@ -241,6 +242,17 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyShippingMethodsMatchi
['projectKey' => 'test_projectKey'],
'/{projectKey}/shipping-methods/matching-cart'
],
'ResourceByProjectKeyShippingMethodsMatchingCartLocation' => [
function (ApiRequestBuilder $builder): ResourceByProjectKeyShippingMethodsMatchingCartLocation {
return $builder
->withProjectKey("test_projectKey")
->shippingMethods()
->matchingCartLocation();
},
ResourceByProjectKeyShippingMethodsMatchingCartLocation::class,
['projectKey' => 'test_projectKey'],
'/{projectKey}/shipping-methods/matching-cart-location'
],
'ResourceByProjectKeyShippingMethodsMatchingOrderedit' => [
function (ApiRequestBuilder $builder): ResourceByProjectKeyShippingMethodsMatchingOrderedit {
return $builder
Expand Down
Loading

0 comments on commit 5863d56

Please sign in to comment.