|
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
|
|
|
namespace PyzTest\Glue\ProductConfigurations\RestApi; |
|
9
|
|
|
|
|
10
|
|
|
use Codeception\Util\HttpCode; |
|
11
|
|
|
use Generated\Shared\Transfer\QuoteTransfer; |
|
|
|
|
|
|
12
|
|
|
use Generated\Shared\Transfer\StoreTransfer; |
|
|
|
|
|
|
13
|
|
|
use PyzTest\Glue\ProductConfigurations\ProductConfigurationsApiTester; |
|
14
|
|
|
use PyzTest\Glue\ProductConfigurations\RestApi\Fixtures\ProductConfigurationsRestApiFixtures; |
|
15
|
|
|
use Spryker\Glue\CartsRestApi\CartsRestApiConfig; |
|
16
|
|
|
use Spryker\Glue\OrdersRestApi\OrdersRestApiConfig; |
|
17
|
|
|
use Spryker\Glue\ProductsRestApi\ProductsRestApiConfig; |
|
18
|
|
|
use Spryker\Shared\Price\PriceConfig; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Auto-generated group annotations |
|
22
|
|
|
* |
|
23
|
|
|
* @group PyzTest |
|
24
|
|
|
* @group Glue |
|
25
|
|
|
* @group ProductConfigurations |
|
26
|
|
|
* @group RestApi |
|
27
|
|
|
* @group ProductConfigurationRestApiCest |
|
28
|
|
|
* Add your own group annotations below this line |
|
29
|
|
|
* @group EndToEnd |
|
30
|
|
|
*/ |
|
31
|
|
|
class ProductConfigurationRestApiCest |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var \PyzTest\Glue\ProductConfigurations\RestApi\Fixtures\ProductConfigurationsRestApiFixtures |
|
35
|
|
|
*/ |
|
36
|
|
|
protected ProductConfigurationsRestApiFixtures $fixtures; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param \PyzTest\Glue\ProductConfigurations\ProductConfigurationsApiTester $I |
|
40
|
|
|
* |
|
41
|
|
|
* @return void |
|
42
|
|
|
*/ |
|
43
|
|
|
public function loadFixtures(ProductConfigurationsApiTester $I): void |
|
44
|
|
|
{ |
|
45
|
|
|
/** @var \PyzTest\Glue\ProductConfigurations\RestApi\Fixtures\ProductConfigurationsRestApiFixtures $fixtures */ |
|
46
|
|
|
$fixtures = $I->loadFixtures(ProductConfigurationsRestApiFixtures::class); |
|
47
|
|
|
|
|
48
|
|
|
$this->fixtures = $fixtures; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @depends loadFixtures |
|
53
|
|
|
* |
|
54
|
|
|
* @param \PyzTest\Glue\ProductConfigurations\ProductConfigurationsApiTester $I |
|
55
|
|
|
* |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
public function requestProductConcrete(ProductConfigurationsApiTester $I): void |
|
59
|
|
|
{ |
|
60
|
|
|
// Act |
|
61
|
|
|
$I->sendGET($I->formatFullUrl( |
|
62
|
|
|
'{resourceConcreteProducts}/{productConcreteSku}', |
|
63
|
|
|
[ |
|
64
|
|
|
'resourceConcreteProducts' => ProductsRestApiConfig::RESOURCE_CONCRETE_PRODUCTS, |
|
65
|
|
|
'productConcreteSku' => $this->fixtures->getProductConcreteTransfer()->getSkuOrFail(), |
|
66
|
|
|
], |
|
67
|
|
|
)); |
|
68
|
|
|
|
|
69
|
|
|
// Assert |
|
70
|
|
|
$I->seeResponseCodeIs(HttpCode::OK); |
|
71
|
|
|
$I->seeResponseIsJson(); |
|
72
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
73
|
|
|
|
|
74
|
|
|
$I->amSure('Returned resource is of type concrete-products') |
|
75
|
|
|
->whenI() |
|
76
|
|
|
->seeResponseDataContainsSingleResourceOfType(ProductsRestApiConfig::RESOURCE_CONCRETE_PRODUCTS); |
|
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
$I->amSure('Returned resource has correct id') |
|
79
|
|
|
->whenI() |
|
80
|
|
|
->seeSingleResourceIdEqualTo($this->fixtures->getProductConcreteTransfer()->getSkuOrFail()); |
|
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
$I->amSure('Returned resource has product configuration instance') |
|
83
|
|
|
->whenI() |
|
84
|
|
|
->seeSingleResourceHasAttribute($this->fixtures::PRODUCT_CONFIGURATION_INSTANCE_ATTRIBUTE_JSON_PATH); |
|
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
$I->amSure('Returned product configuration instance is correct') |
|
87
|
|
|
->whenI() |
|
88
|
|
|
->seeProductConfigurationInstanceEqualToExpectedValue($this->fixtures->getProductConfigurationTransfer()); |
|
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @param \PyzTest\Glue\ProductConfigurations\ProductConfigurationsApiTester $I |
|
93
|
|
|
* |
|
94
|
|
|
* @return void |
|
95
|
|
|
*/ |
|
96
|
|
|
public function requestAddConfigurableItemsToCart(ProductConfigurationsApiTester $I): void |
|
97
|
|
|
{ |
|
98
|
|
|
// Arrange |
|
99
|
|
|
$I->amAuthorizedCustomer($this->fixtures->getCustomerTransfer()); |
|
100
|
|
|
$quoteTransfer = $I->havePersistentQuote([ |
|
101
|
|
|
QuoteTransfer::CUSTOMER => $this->fixtures->getCustomerTransfer(), |
|
102
|
|
|
QuoteTransfer::STORE => [StoreTransfer::NAME => $this->fixtures::STORE_NAME_DE], |
|
103
|
|
|
QuoteTransfer::PRICE_MODE => PriceConfig::PRICE_MODE_GROSS, |
|
104
|
|
|
]); |
|
105
|
|
|
$quoteUuid = $quoteTransfer->getUuidOrFail(); |
|
106
|
|
|
$productConcreteSku = $this->fixtures->getProductConcreteTransfer()->getSkuOrFail(); |
|
107
|
|
|
|
|
108
|
|
|
// Act |
|
109
|
|
|
$I->sendPOST( |
|
110
|
|
|
$I->formatUrl( |
|
111
|
|
|
'{resourceCarts}/{cartUuid}/{resourceCartItems}?include={resourceCartItems}', |
|
112
|
|
|
[ |
|
113
|
|
|
'resourceCarts' => CartsRestApiConfig::RESOURCE_CARTS, |
|
114
|
|
|
'cartUuid' => $quoteUuid, |
|
115
|
|
|
'resourceCartItems' => CartsRestApiConfig::RESOURCE_CART_ITEMS, |
|
116
|
|
|
], |
|
117
|
|
|
), |
|
118
|
|
|
[ |
|
119
|
|
|
'data' => [ |
|
120
|
|
|
'type' => CartsRestApiConfig::RESOURCE_CART_ITEMS, |
|
121
|
|
|
'attributes' => [ |
|
122
|
|
|
'sku' => $productConcreteSku, |
|
123
|
|
|
'quantity' => 1, |
|
124
|
|
|
'productConfigurationInstance' => $this->fixtures::PRODUCT_CONFIGURATION_CART_ITEM_DATA, |
|
125
|
|
|
], |
|
126
|
|
|
], |
|
127
|
|
|
], |
|
128
|
|
|
); |
|
129
|
|
|
|
|
130
|
|
|
// Assert |
|
131
|
|
|
$I->seeResponseCodeIs(HttpCode::CREATED); |
|
132
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
133
|
|
|
|
|
134
|
|
|
$I->amSure('Returned resource has correct id') |
|
135
|
|
|
->whenI() |
|
136
|
|
|
->seeSingleResourceIdEqualTo($quoteUuid); |
|
137
|
|
|
|
|
138
|
|
|
$I->amSure(sprintf('Returned resource is of type %s', CartsRestApiConfig::RESOURCE_CARTS)) |
|
139
|
|
|
->whenI() |
|
140
|
|
|
->seeResponseDataContainsSingleResourceOfType(CartsRestApiConfig::RESOURCE_CARTS); |
|
141
|
|
|
|
|
142
|
|
|
$I->amSure('Returned resource has include of type items') |
|
143
|
|
|
->whenI() |
|
144
|
|
|
->seeIncludesContainResourceOfType(CartsRestApiConfig::RESOURCE_CART_ITEMS); |
|
|
|
|
|
|
145
|
|
|
|
|
146
|
|
|
$I->amSure('Included resource has product configuration instance') |
|
147
|
|
|
->whenI() |
|
148
|
|
|
->seeCartItemContainsProductConfigurationInstance( |
|
|
|
|
|
|
149
|
|
|
CartsRestApiConfig::RESOURCE_CART_ITEMS, |
|
150
|
|
|
$productConcreteSku, |
|
151
|
|
|
); |
|
152
|
|
|
|
|
153
|
|
|
$I->seeSingleResourceHasSelfLink( |
|
154
|
|
|
$I->formatFullUrl( |
|
155
|
|
|
'{resourceCarts}/{cartUuid}', |
|
156
|
|
|
[ |
|
157
|
|
|
'resourceCarts' => CartsRestApiConfig::RESOURCE_CARTS, |
|
158
|
|
|
'cartUuid' => $I->getDataFromResponseByJsonPath('$.data')['id'], |
|
159
|
|
|
], |
|
160
|
|
|
), |
|
161
|
|
|
); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @param \PyzTest\Glue\ProductConfigurations\ProductConfigurationsApiTester $I |
|
166
|
|
|
* |
|
167
|
|
|
* @return void |
|
168
|
|
|
*/ |
|
169
|
|
|
public function requestGetOrderDetails(ProductConfigurationsApiTester $I): void |
|
170
|
|
|
{ |
|
171
|
|
|
// Arrange |
|
172
|
|
|
$I->amAuthorizedCustomer($this->fixtures->getCustomerTransfer()); |
|
173
|
|
|
$orderReference = $this->fixtures->getSaveOrderTransfer()->getOrderReferenceOrFail(); |
|
174
|
|
|
|
|
175
|
|
|
// Act |
|
176
|
|
|
$I->sendGET( |
|
177
|
|
|
$I->formatUrl( |
|
178
|
|
|
'{orders}/{customerOrderReference}?include=items', |
|
179
|
|
|
[ |
|
180
|
|
|
'orders' => OrdersRestApiConfig::RESOURCE_ORDERS, |
|
181
|
|
|
'customerOrderReference' => $orderReference, |
|
182
|
|
|
], |
|
183
|
|
|
), |
|
184
|
|
|
); |
|
185
|
|
|
|
|
186
|
|
|
// Assert |
|
187
|
|
|
$I->seeResponseCodeIs(HttpCode::OK); |
|
188
|
|
|
$I->seeResponseIsJson(); |
|
189
|
|
|
$I->seeResponseMatchesOpenApiSchema(); |
|
190
|
|
|
|
|
191
|
|
|
$I->amSure('The returned resource is of correct type') |
|
192
|
|
|
->whenI() |
|
193
|
|
|
->seeResponseDataContainsSingleResourceOfType('orders'); |
|
194
|
|
|
|
|
195
|
|
|
$I->amSure('The returned resource has correct id') |
|
196
|
|
|
->whenI() |
|
197
|
|
|
->seeSingleResourceIdEqualTo($orderReference); |
|
198
|
|
|
|
|
199
|
|
|
$I->amSure('Order item contains product configuration data') |
|
200
|
|
|
->whenI() |
|
201
|
|
|
->seeOrderItemContainProductConfigurationInstance($this->fixtures->getProductConfigurationTransfer()); |
|
|
|
|
|
|
202
|
|
|
} |
|
203
|
|
|
} |
|
204
|
|
|
|
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