1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Spryker Commerce OS. |
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
declare(strict_types = 1); |
9
|
|
|
|
10
|
|
|
namespace PyzTest\Glue\OrderAmendments\RestApi; |
11
|
|
|
|
12
|
|
|
use Codeception\Util\HttpCode; |
13
|
|
|
use Generated\Shared\Transfer\RestCheckoutErrorTransfer; |
|
|
|
|
14
|
|
|
use PyzTest\Glue\OrderAmendments\OrderAmendmentsApiTester; |
15
|
|
|
use PyzTest\Glue\OrderAmendments\RestApi\Fixtures\OrderAmendmentRestApiFixtures; |
16
|
|
|
use Spryker\Glue\CartReorderRestApi\CartReorderRestApiConfig; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Auto-generated group annotations |
20
|
|
|
* |
21
|
|
|
* @group PyzTest |
22
|
|
|
* @group Glue |
23
|
|
|
* @group OrderAmendments |
24
|
|
|
* @group RestApi |
25
|
|
|
* @group OrderAmendmentsRestApiCest |
26
|
|
|
* Add your own group annotations below this line |
27
|
|
|
* @group EndToEnd |
28
|
|
|
*/ |
29
|
|
|
class OrderAmendmentsRestApiCest |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected const RESPONSE_CODE_ORDER_IS_NOT_AMENDABLE = '5800'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected const RESPONSE_DETAIL_ORDER_IS_NOT_AMENDABLE = 'The order cannot be amended.'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected const RESPONSE_CODE_PARAMETER_IS_AMENDABLE_INVALID = '901'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
protected const RESPONSE_DETAIL_PARAMETER_IS_AMENDABLE_INVALID = 'isAmendment => This value should be of type bool.'; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var \PyzTest\Glue\OrderAmendments\RestApi\Fixtures\OrderAmendmentRestApiFixtures |
53
|
|
|
*/ |
54
|
|
|
protected OrderAmendmentRestApiFixtures $fixtures; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param \PyzTest\Glue\OrderAmendments\OrderAmendmentsApiTester $I |
58
|
|
|
* |
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
|
|
public function loadFixtures(OrderAmendmentsApiTester $I): void |
62
|
|
|
{ |
63
|
|
|
/** @var \PyzTest\Glue\OrderAmendments\RestApi\Fixtures\OrderAmendmentRestApiFixtures $fixtures */ |
64
|
|
|
$fixtures = $I->loadFixtures(OrderAmendmentRestApiFixtures::class); |
65
|
|
|
$this->fixtures = $fixtures; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param \PyzTest\Glue\OrderAmendments\OrderAmendmentsApiTester $I |
70
|
|
|
* |
71
|
|
|
* @return void |
72
|
|
|
*/ |
73
|
|
|
public function requestCreateOrderAmendmentWithInvalidOrder(OrderAmendmentsApiTester $I): void |
74
|
|
|
{ |
75
|
|
|
//Arrange |
76
|
|
|
$I->authorizeCustomerToGlue($this->fixtures->getCustomerTransfer()); |
77
|
|
|
|
78
|
|
|
$requestPayload = [ |
79
|
|
|
'data' => [ |
80
|
|
|
'type' => CartReorderRestApiConfig::RESOURCE_CART_REORDER, |
81
|
|
|
'attributes' => [ |
82
|
|
|
'orderReference' => $this->fixtures->getNotReadyForAmendmentOrderTransfer()->getOrderReferenceOrFail(), |
83
|
|
|
'isAmendment' => true, |
84
|
|
|
], |
85
|
|
|
], |
86
|
|
|
]; |
87
|
|
|
|
88
|
|
|
// Act |
89
|
|
|
$I->sendPost($I->getCartReorderUrl(), $requestPayload); |
90
|
|
|
|
91
|
|
|
// Assert |
92
|
|
|
$I->seeResponseCodeIs(HttpCode::UNPROCESSABLE_ENTITY); |
93
|
|
|
$I->seeResponseIsJson(); |
94
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
95
|
|
|
|
96
|
|
|
$errors = $I->getDataFromResponseByJsonPath('$.errors[0]'); |
97
|
|
|
$I->assertEquals($errors[RestCheckoutErrorTransfer::CODE], static::RESPONSE_CODE_ORDER_IS_NOT_AMENDABLE); |
98
|
|
|
$I->assertEquals($errors[RestCheckoutErrorTransfer::STATUS], HttpCode::UNPROCESSABLE_ENTITY); |
99
|
|
|
$I->assertEquals($errors[RestCheckoutErrorTransfer::DETAIL], static::RESPONSE_DETAIL_ORDER_IS_NOT_AMENDABLE); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param \PyzTest\Glue\OrderAmendments\OrderAmendmentsApiTester $I |
104
|
|
|
* |
105
|
|
|
* @return void |
106
|
|
|
*/ |
107
|
|
|
public function requestCreateOrderAmendmentWithEmptyIsAmendmentParameter(OrderAmendmentsApiTester $I): void |
108
|
|
|
{ |
109
|
|
|
//Arrange |
110
|
|
|
$I->authorizeCustomerToGlue($this->fixtures->getCustomerTransfer()); |
111
|
|
|
|
112
|
|
|
$requestPayload = [ |
113
|
|
|
'data' => [ |
114
|
|
|
'type' => CartReorderRestApiConfig::RESOURCE_CART_REORDER, |
115
|
|
|
'attributes' => [ |
116
|
|
|
'orderReference' => $this->fixtures->getReadyForAmendmentOrderTransfer()->getOrderReferenceOrFail(), |
117
|
|
|
'isAmendment' => '', |
118
|
|
|
], |
119
|
|
|
], |
120
|
|
|
]; |
121
|
|
|
|
122
|
|
|
// Act |
123
|
|
|
$I->sendPost($I->getCartReorderUrl(), $requestPayload); |
124
|
|
|
|
125
|
|
|
// Assert |
126
|
|
|
$I->seeResponseCodeIs(HttpCode::UNPROCESSABLE_ENTITY); |
127
|
|
|
$I->seeResponseIsJson(); |
128
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
129
|
|
|
|
130
|
|
|
$errors = $I->getDataFromResponseByJsonPath('$.errors[0]'); |
131
|
|
|
$I->assertEquals($errors[RestCheckoutErrorTransfer::CODE], static::RESPONSE_CODE_PARAMETER_IS_AMENDABLE_INVALID); |
132
|
|
|
$I->assertEquals($errors[RestCheckoutErrorTransfer::STATUS], HttpCode::UNPROCESSABLE_ENTITY); |
133
|
|
|
$I->assertEquals($errors[RestCheckoutErrorTransfer::DETAIL], static::RESPONSE_DETAIL_PARAMETER_IS_AMENDABLE_INVALID); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param \PyzTest\Glue\OrderAmendments\OrderAmendmentsApiTester $I |
138
|
|
|
* |
139
|
|
|
* @return void |
140
|
|
|
*/ |
141
|
|
|
public function requestCreateOrderAmendmentWithValidOrder(OrderAmendmentsApiTester $I): void |
142
|
|
|
{ |
143
|
|
|
//Arrange |
144
|
|
|
$I->authorizeCustomerToGlue($this->fixtures->getCustomerTransfer()); |
145
|
|
|
|
146
|
|
|
$requestPayload = [ |
147
|
|
|
'data' => [ |
148
|
|
|
'type' => CartReorderRestApiConfig::RESOURCE_CART_REORDER, |
149
|
|
|
'attributes' => [ |
150
|
|
|
'orderReference' => $this->fixtures->getReadyForAmendmentOrderTransfer()->getOrderReferenceOrFail(), |
151
|
|
|
'isAmendment' => true, |
152
|
|
|
], |
153
|
|
|
], |
154
|
|
|
]; |
155
|
|
|
|
156
|
|
|
// Act |
157
|
|
|
$I->sendPost($I->getCartReorderUrl(), $requestPayload); |
158
|
|
|
|
159
|
|
|
// Assert |
160
|
|
|
$I->seeResponseCodeIs(HttpCode::CREATED); |
161
|
|
|
$I->seeResponseIsJson(); |
162
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
163
|
|
|
|
164
|
|
|
$I->amSure('The returned resource is of correct type') |
165
|
|
|
->whenI() |
166
|
|
|
->seeResponseDataContainsSingleResourceOfType('carts'); |
|
|
|
|
167
|
|
|
|
168
|
|
|
$I->amSure('The returned response data contains amendment order reference') |
169
|
|
|
->whenI() |
170
|
|
|
->assertResponseContainsAmendmentOrderReference($this->fixtures->getReadyForAmendmentOrderTransfer()->getOrderReferenceOrFail()); |
|
|
|
|
171
|
|
|
|
172
|
|
|
$I->amSure('The returned response data contains correct cart name') |
173
|
|
|
->whenI() |
174
|
|
|
->assertResponseContainsCorrectCartName( |
|
|
|
|
175
|
|
|
sprintf('Editing Order %s', $this->fixtures->getReadyForAmendmentOrderTransfer()->getOrderReferenceOrFail()), |
176
|
|
|
); |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths