Skip to content

Commit 74e1814

Browse files
authored
Merge pull request #93 from commercetools/gen-sdk-updates
2 parents 806da74 + 95ff564 commit 74e1814

File tree

7,077 files changed

+165097
-6679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,077 files changed

+165097
-6679
lines changed

lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsByIDTest.php

Lines changed: 513 additions & 0 deletions
Large diffs are not rendered by default.

lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsKeyByKeyTest.php

Lines changed: 513 additions & 0 deletions
Large diffs are not rendered by default.

lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsTest.php

Lines changed: 433 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file has been auto generated
6+
* Do not change it.
7+
*/
8+
9+
namespace Commercetools\Api\Test\Client\Resource;
10+
11+
use Commercetools\Api\Client\ApiRequestBuilder;
12+
use Commercetools\Base\JsonObject;
13+
use Commercetools\Client\ApiRequest;
14+
use Commercetools\Exception\ApiClientException;
15+
use Commercetools\Exception\ApiServerException;
16+
use GuzzleHttp\ClientInterface;
17+
use GuzzleHttp\Exception\ClientException;
18+
use GuzzleHttp\Exception\ServerException;
19+
use GuzzleHttp\Psr7\Response;
20+
use PHPUnit\Framework\TestCase;
21+
use Psr\Http\Message\RequestInterface;
22+
23+
/**
24+
* @covers \Commercetools\Api\Client\Resource\ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost
25+
* @covers \Commercetools\Api\Client\Resource\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers
26+
*/
27+
class ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersTest extends TestCase
28+
{
29+
/**
30+
* @dataProvider getRequests()
31+
*/
32+
public function testBuilder(callable $builderFunction, string $method, string $relativeUri, string $body = null)
33+
{
34+
$builder = new ApiRequestBuilder();
35+
$request = $builderFunction($builder);
36+
$this->assertSame(strtolower($method), strtolower($request->getMethod()));
37+
$this->assertSame($relativeUri, (string) $request->getUri());
38+
if (!is_null($body)) {
39+
$this->assertJsonStringEqualsJsonString($body, (string) $request->getBody());
40+
} else {
41+
$this->assertSame("", (string) $request->getBody());
42+
}
43+
}
44+
45+
46+
47+
/**
48+
* @dataProvider getRequestBuilderResponses()
49+
*/
50+
public function testMapFromResponse(callable $builderFunction, $statusCode)
51+
{
52+
$builder = new ApiRequestBuilder();
53+
$request = $builderFunction($builder);
54+
$this->assertInstanceOf(ApiRequest::class, $request);
55+
56+
$response = new Response($statusCode, [], "{}");
57+
$this->assertInstanceOf(JsonObject::class, $request->mapFromResponse($response));
58+
}
59+
60+
/**
61+
* @dataProvider getRequestBuilders()
62+
*/
63+
public function testExecuteClientException(callable $builderFunction)
64+
{
65+
$client = $this->createMock(ClientInterface::class);
66+
67+
$builder = new ApiRequestBuilder($client);
68+
$request = $builderFunction($builder);
69+
$client->method("send")->willThrowException(new ClientException("Oops!", $request, new Response(400)));
70+
71+
$this->expectException(ApiClientException::class);
72+
$request->execute();
73+
}
74+
75+
/**
76+
* @dataProvider getRequestBuilders()
77+
*/
78+
public function testExecuteServerException(callable $builderFunction)
79+
{
80+
$client = $this->createMock(ClientInterface::class);
81+
82+
$builder = new ApiRequestBuilder($client);
83+
$request = $builderFunction($builder);
84+
$client->method("send")->willThrowException(new ServerException("Oops!", $request, new Response(500)));
85+
86+
$this->expectException(ApiServerException::class);
87+
$request->execute();
88+
}
89+
90+
public function getRequests()
91+
{
92+
return [
93+
'ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost' => [
94+
function (ApiRequestBuilder $builder): RequestInterface {
95+
return $builder
96+
->withProjectKey("test_projectKey")
97+
->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey")
98+
->me()
99+
->customers()
100+
->post(null);
101+
},
102+
'post',
103+
'test_projectKey/in-business-unit/key=test_businessUnitKey/me/customers',
104+
]
105+
];
106+
}
107+
108+
public function getResources()
109+
{
110+
return [
111+
];
112+
}
113+
114+
public function getRequestBuilders()
115+
{
116+
return [
117+
'ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost' => [
118+
function (ApiRequestBuilder $builder): RequestInterface {
119+
return $builder
120+
->withProjectKey("projectKey")
121+
->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")
122+
->me()
123+
->customers()
124+
->post(null);
125+
}
126+
]
127+
];
128+
}
129+
130+
public function getRequestBuilderResponses()
131+
{
132+
return [
133+
'ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost_201' => [
134+
function (ApiRequestBuilder $builder): RequestInterface {
135+
return $builder
136+
->withProjectKey("projectKey")
137+
->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")
138+
->me()
139+
->customers()
140+
->post(null);
141+
},
142+
201
143+
],
144+
'ByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomersPost_599' => [
145+
function (ApiRequestBuilder $builder): RequestInterface {
146+
return $builder
147+
->withProjectKey("projectKey")
148+
->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")
149+
->me()
150+
->customers()
151+
->post(null);
152+
},
153+
599
154+
]
155+
];
156+
}
157+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file has been auto generated
6+
* Do not change it.
7+
*/
8+
9+
namespace Commercetools\Api\Test\Client\Resource;
10+
11+
use Commercetools\Api\Client\ApiRequestBuilder;
12+
use Commercetools\Api\Client\Resource\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers;
13+
use Commercetools\Base\JsonObject;
14+
use Commercetools\Client\ApiRequest;
15+
use Commercetools\Exception\ApiClientException;
16+
use Commercetools\Exception\ApiServerException;
17+
use GuzzleHttp\ClientInterface;
18+
use GuzzleHttp\Exception\ClientException;
19+
use GuzzleHttp\Exception\ServerException;
20+
use GuzzleHttp\Psr7\Response;
21+
use PHPUnit\Framework\TestCase;
22+
use Psr\Http\Message\RequestInterface;
23+
24+
/**
25+
* @covers \Commercetools\Api\Client\Resource\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe
26+
*/
27+
class ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeTest extends TestCase
28+
{
29+
/**
30+
* @dataProvider getResources()
31+
*/
32+
public function testResources(callable $builderFunction, string $class, array $expectedArgs)
33+
{
34+
$builder = new ApiRequestBuilder();
35+
$resource = $builderFunction($builder);
36+
$this->assertInstanceOf($class, $resource);
37+
$this->assertEquals($expectedArgs, $resource->getArgs());
38+
}
39+
40+
41+
42+
43+
44+
45+
46+
public function getRequests()
47+
{
48+
return [
49+
];
50+
}
51+
52+
public function getResources()
53+
{
54+
return [
55+
'ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers' => [
56+
function (ApiRequestBuilder $builder): ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers {
57+
return $builder
58+
->withProjectKey("test_projectKey")
59+
->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey")
60+
->me()
61+
->customers();
62+
},
63+
ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMeCustomers::class,
64+
['projectKey' => 'test_projectKey', 'businessUnitKey' => 'test_businessUnitKey'],
65+
'/{projectKey}/in-business-unit/key={businessUnitKey}/me/customers'
66+
]
67+
];
68+
}
69+
70+
public function getRequestBuilders()
71+
{
72+
return [
73+
];
74+
}
75+
76+
public function getRequestBuilderResponses()
77+
{
78+
return [
79+
];
80+
}
81+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file has been auto generated
6+
* Do not change it.
7+
*/
8+
9+
namespace Commercetools\Api\Test\Client\Resource;
10+
11+
use Commercetools\Api\Client\ApiRequestBuilder;
12+
use Commercetools\Api\Client\Resource\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe;
13+
use Commercetools\Base\JsonObject;
14+
use Commercetools\Client\ApiRequest;
15+
use Commercetools\Exception\ApiClientException;
16+
use Commercetools\Exception\ApiServerException;
17+
use GuzzleHttp\ClientInterface;
18+
use GuzzleHttp\Exception\ClientException;
19+
use GuzzleHttp\Exception\ServerException;
20+
use GuzzleHttp\Psr7\Response;
21+
use PHPUnit\Framework\TestCase;
22+
use Psr\Http\Message\RequestInterface;
23+
24+
/**
25+
* @covers \Commercetools\Api\Client\Resource\ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKey
26+
*/
27+
class ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyTest extends TestCase
28+
{
29+
/**
30+
* @dataProvider getResources()
31+
*/
32+
public function testResources(callable $builderFunction, string $class, array $expectedArgs)
33+
{
34+
$builder = new ApiRequestBuilder();
35+
$resource = $builderFunction($builder);
36+
$this->assertInstanceOf($class, $resource);
37+
$this->assertEquals($expectedArgs, $resource->getArgs());
38+
}
39+
40+
41+
42+
43+
44+
45+
46+
public function getRequests()
47+
{
48+
return [
49+
];
50+
}
51+
52+
public function getResources()
53+
{
54+
return [
55+
'ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe' => [
56+
function (ApiRequestBuilder $builder): ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe {
57+
return $builder
58+
->withProjectKey("test_projectKey")
59+
->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey")
60+
->me();
61+
},
62+
ResourceByProjectKeyInBusinessUnitKeyByBusinessUnitKeyMe::class,
63+
['projectKey' => 'test_projectKey', 'businessUnitKey' => 'test_businessUnitKey'],
64+
'/{projectKey}/in-business-unit/key={businessUnitKey}/me'
65+
]
66+
];
67+
}
68+
69+
public function getRequestBuilders()
70+
{
71+
return [
72+
];
73+
}
74+
75+
public function getRequestBuilderResponses()
76+
{
77+
return [
78+
];
79+
}
80+
}

lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDTest.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,71 @@ public function testExecuteServerException(callable $builderFunction)
9090
public function getRequests()
9191
{
9292
return [
93+
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceCurrency' => [
94+
function (ApiRequestBuilder $builder): RequestInterface {
95+
return $builder
96+
->withProjectKey('test_projectKey')
97+
->inStoreKeyWithStoreKeyValue('test_storeKey')
98+
->productProjections()
99+
->withId('test_ID')
100+
->get()
101+
->withPriceCurrency('priceCurrency');
102+
},
103+
'get',
104+
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceCurrency=priceCurrency',
105+
],
106+
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceCountry' => [
107+
function (ApiRequestBuilder $builder): RequestInterface {
108+
return $builder
109+
->withProjectKey('test_projectKey')
110+
->inStoreKeyWithStoreKeyValue('test_storeKey')
111+
->productProjections()
112+
->withId('test_ID')
113+
->get()
114+
->withPriceCountry('priceCountry');
115+
},
116+
'get',
117+
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceCountry=priceCountry',
118+
],
119+
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceCustomerGroup' => [
120+
function (ApiRequestBuilder $builder): RequestInterface {
121+
return $builder
122+
->withProjectKey('test_projectKey')
123+
->inStoreKeyWithStoreKeyValue('test_storeKey')
124+
->productProjections()
125+
->withId('test_ID')
126+
->get()
127+
->withPriceCustomerGroup('priceCustomerGroup');
128+
},
129+
'get',
130+
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceCustomerGroup=priceCustomerGroup',
131+
],
132+
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withPriceChannel' => [
133+
function (ApiRequestBuilder $builder): RequestInterface {
134+
return $builder
135+
->withProjectKey('test_projectKey')
136+
->inStoreKeyWithStoreKeyValue('test_storeKey')
137+
->productProjections()
138+
->withId('test_ID')
139+
->get()
140+
->withPriceChannel('priceChannel');
141+
},
142+
'get',
143+
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?priceChannel=priceChannel',
144+
],
145+
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withLocaleProjection' => [
146+
function (ApiRequestBuilder $builder): RequestInterface {
147+
return $builder
148+
->withProjectKey('test_projectKey')
149+
->inStoreKeyWithStoreKeyValue('test_storeKey')
150+
->productProjections()
151+
->withId('test_ID')
152+
->get()
153+
->withLocaleProjection('localeProjection');
154+
},
155+
'get',
156+
'test_projectKey/in-store/key=test_storeKey/product-projections/test_ID?localeProjection=localeProjection',
157+
],
93158
'ByProjectKeyInStoreKeyByStoreKeyProductProjectionsByIDGet_withExpand' => [
94159
function (ApiRequestBuilder $builder): RequestInterface {
95160
return $builder

0 commit comments

Comments
 (0)