Skip to content

Commit

Permalink
Merge pull request #93 from commercetools/gen-sdk-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude authored Oct 28, 2022
2 parents 806da74 + 95ff564 commit 74e1814
Show file tree
Hide file tree
Showing 7,077 changed files with 165,097 additions and 6,679 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.

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,157 @@
<?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\ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost
* @covers \Commercetools\Api\Client\Resource\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers
*/
class ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersTest 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 [
'ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("test_projectKey")
->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey")
->me()
->customers()
->post(null);
},
'post',
'test_projectKey/in-business-unit/key=test_businessUnitKey/me/customers',
]
];
}

public function getResources()
{
return [
];
}

public function getRequestBuilders()
{
return [
'ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")
->me()
->customers()
->post(null);
}
]
];
}

public function getRequestBuilderResponses()
{
return [
'ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost_201' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")
->me()
->customers()
->post(null);
},
201
],
'ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost_599' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")
->me()
->customers()
->post(null);
},
599
]
];
}
}
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\Api\Test\Client\Resource;

use Commercetools\Api\Client\ApiRequestBuilder;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers;
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\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe
*/
class ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeTest extends TestCase
{
/**
* @dataProvider getResources()
*/
public function testResources(callable $builderFunction, string $class, array $expectedArgs)
{
$builder = new ApiRequestBuilder();
$resource = $builderFunction($builder);
$this->assertInstanceOf($class, $resource);
$this->assertEquals($expectedArgs, $resource->getArgs());
}







public function getRequests()
{
return [
];
}

public function getResources()
{
return [
'ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers' => [
function (ApiRequestBuilder $builder): ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers {
return $builder
->withProjectKey("test_projectKey")
->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey")
->me()
->customers();
},
ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers::class,
['projectKey' => 'test_projectKey', 'businessUnitKey' => 'test_businessUnitKey'],
'/{projectKey}/in-business-unit/key={businessUnitKey}/me/customers'
]
];
}

public function getRequestBuilders()
{
return [
];
}

public function getRequestBuilderResponses()
{
return [
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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\Api\Client\Resource\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe;
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\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKey
*/
class ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyTest extends TestCase
{
/**
* @dataProvider getResources()
*/
public function testResources(callable $builderFunction, string $class, array $expectedArgs)
{
$builder = new ApiRequestBuilder();
$resource = $builderFunction($builder);
$this->assertInstanceOf($class, $resource);
$this->assertEquals($expectedArgs, $resource->getArgs());
}







public function getRequests()
{
return [
];
}

public function getResources()
{
return [
'ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe' => [
function (ApiRequestBuilder $builder): ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe {
return $builder
->withProjectKey("test_projectKey")
->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey")
->me();
},
ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe::class,
['projectKey' => 'test_projectKey', 'businessUnitKey' => 'test_businessUnitKey'],
'/{projectKey}/in-business-unit/key={businessUnitKey}/me'
]
];
}

public function getRequestBuilders()
{
return [
];
}

public function getRequestBuilderResponses()
{
return [
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,71 @@ public function testExecuteServerException(callable $builderFunction)
public function getRequests()
{
return [
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceCurrency' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->inStoreKeyWithStoreKeyValue('test_storeKey')
->productProjections()
->withId('test_ID')
->get()
->withPriceCurrency('priceCurrency');
},
'get',
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceCurrency=priceCurrency',
],
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceCountry' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->inStoreKeyWithStoreKeyValue('test_storeKey')
->productProjections()
->withId('test_ID')
->get()
->withPriceCountry('priceCountry');
},
'get',
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceCountry=priceCountry',
],
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceCustomerGroup' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->inStoreKeyWithStoreKeyValue('test_storeKey')
->productProjections()
->withId('test_ID')
->get()
->withPriceCustomerGroup('priceCustomerGroup');
},
'get',
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceCustomerGroup=priceCustomerGroup',
],
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceChannel' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->inStoreKeyWithStoreKeyValue('test_storeKey')
->productProjections()
->withId('test_ID')
->get()
->withPriceChannel('priceChannel');
},
'get',
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceChannel=priceChannel',
],
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withLocaleProjection' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey('test_projectKey')
->inStoreKeyWithStoreKeyValue('test_storeKey')
->productProjections()
->withId('test_ID')
->get()
->withLocaleProjection('localeProjection');
},
'get',
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?localeProjection=localeProjection',
],
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withExpand' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
Expand Down
Loading

0 comments on commit 74e1814

Please sign in to comment.