Skip to content

Commit 334ea98

Browse files
authored
Merge pull request #76 from commercetools/gen-sdk-updates
2 parents d070e6b + c5c2a41 commit 334ea98

File tree

981 files changed

+8997
-1217
lines changed

Some content is hidden

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

981 files changed

+8997
-1217
lines changed
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
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\ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost
25+
* @covers \Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyMeEmailConfirm
26+
*/
27+
class ResourceByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmTest 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+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost' => [
94+
function (ApiRequestBuilder $builder): RequestInterface {
95+
return $builder
96+
->withProjectKey("test_projectKey")
97+
->inStoreKeyWithStoreKeyValue("test_storeKey")
98+
->me()
99+
->emailConfirm()
100+
->post();
101+
},
102+
'post',
103+
'test_projectKey/in-store/key=test_storeKey/me/email/confirm',
104+
]
105+
];
106+
}
107+
108+
public function getResources()
109+
{
110+
return [
111+
];
112+
}
113+
114+
public function getRequestBuilders()
115+
{
116+
return [
117+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost' => [
118+
function (ApiRequestBuilder $builder): RequestInterface {
119+
return $builder
120+
->withProjectKey("projectKey")
121+
->inStoreKeyWithStoreKeyValue("storeKey")
122+
->me()
123+
->emailConfirm()
124+
->post();
125+
}
126+
]
127+
];
128+
}
129+
130+
public function getRequestBuilderResponses()
131+
{
132+
return [
133+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost_400' => [
134+
function (ApiRequestBuilder $builder): RequestInterface {
135+
return $builder
136+
->withProjectKey("projectKey")
137+
->inStoreKeyWithStoreKeyValue("storeKey")
138+
->me()
139+
->emailConfirm()
140+
->post();
141+
},
142+
400
143+
],
144+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost_401' => [
145+
function (ApiRequestBuilder $builder): RequestInterface {
146+
return $builder
147+
->withProjectKey("projectKey")
148+
->inStoreKeyWithStoreKeyValue("storeKey")
149+
->me()
150+
->emailConfirm()
151+
->post();
152+
},
153+
401
154+
],
155+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost_403' => [
156+
function (ApiRequestBuilder $builder): RequestInterface {
157+
return $builder
158+
->withProjectKey("projectKey")
159+
->inStoreKeyWithStoreKeyValue("storeKey")
160+
->me()
161+
->emailConfirm()
162+
->post();
163+
},
164+
403
165+
],
166+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost_404' => [
167+
function (ApiRequestBuilder $builder): RequestInterface {
168+
return $builder
169+
->withProjectKey("projectKey")
170+
->inStoreKeyWithStoreKeyValue("storeKey")
171+
->me()
172+
->emailConfirm()
173+
->post();
174+
},
175+
404
176+
],
177+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost_500' => [
178+
function (ApiRequestBuilder $builder): RequestInterface {
179+
return $builder
180+
->withProjectKey("projectKey")
181+
->inStoreKeyWithStoreKeyValue("storeKey")
182+
->me()
183+
->emailConfirm()
184+
->post();
185+
},
186+
500
187+
],
188+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost_502' => [
189+
function (ApiRequestBuilder $builder): RequestInterface {
190+
return $builder
191+
->withProjectKey("projectKey")
192+
->inStoreKeyWithStoreKeyValue("storeKey")
193+
->me()
194+
->emailConfirm()
195+
->post();
196+
},
197+
502
198+
],
199+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost_503' => [
200+
function (ApiRequestBuilder $builder): RequestInterface {
201+
return $builder
202+
->withProjectKey("projectKey")
203+
->inStoreKeyWithStoreKeyValue("storeKey")
204+
->me()
205+
->emailConfirm()
206+
->post();
207+
},
208+
503
209+
],
210+
'ByProjectKeyInStoreKeyByStoreKeyMeEmailConfirmPost_599' => [
211+
function (ApiRequestBuilder $builder): RequestInterface {
212+
return $builder
213+
->withProjectKey("projectKey")
214+
->inStoreKeyWithStoreKeyValue("storeKey")
215+
->me()
216+
->emailConfirm()
217+
->post();
218+
},
219+
599
220+
]
221+
];
222+
}
223+
}

0 commit comments

Comments
 (0)