Skip to content

Commit 7b8dfd8

Browse files
committed
CC-31028: updates after CR.
1 parent dcdf4f8 commit 7b8dfd8

File tree

5 files changed

+112
-112
lines changed

5 files changed

+112
-112
lines changed

tests/PyzTest/Glue/Carts/RestApi/CartsRestApiCest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,23 +1232,6 @@ public function requestDeleteCartWithoutAuthorizationToken(CartsApiTester $I): v
12321232
$I->seeResponseMatchesOpenApiSchema();
12331233
}
12341234

1235-
/**
1236-
* @param \PyzTest\Glue\Carts\CartsApiTester $I
1237-
* @param \Generated\Shared\Transfer\CustomerTransfer|null $customerTransfer
1238-
*
1239-
* @return void
1240-
*/
1241-
protected function authorizeCustomer(CartsApiTester $I, ?CustomerTransfer $customerTransfer = null): void
1242-
{
1243-
if (!$customerTransfer) {
1244-
$customerTransfer = $this->fixtures->getCustomerTransfer();
1245-
}
1246-
1247-
$token = $I->haveAuthorizationToGlue($customerTransfer)->getAccessToken();
1248-
1249-
$I->amBearerAuthenticated($token);
1250-
}
1251-
12521235
/**
12531236
* @depends loadFixtures
12541237
*
@@ -1306,4 +1289,21 @@ public function requestCustomerCartsAuthorizationError(CartsApiTester $I): void
13061289
$I->seeResponseCodeIs(HttpCode::FORBIDDEN);
13071290
$I->seeResponseMatchesOpenApiSchema();
13081291
}
1292+
1293+
/**
1294+
* @param \PyzTest\Glue\Carts\CartsApiTester $I
1295+
* @param \Generated\Shared\Transfer\CustomerTransfer|null $customerTransfer
1296+
*
1297+
* @return void
1298+
*/
1299+
protected function authorizeCustomer(CartsApiTester $I, ?CustomerTransfer $customerTransfer = null): void
1300+
{
1301+
if (!$customerTransfer) {
1302+
$customerTransfer = $this->fixtures->getCustomerTransfer();
1303+
}
1304+
1305+
$token = $I->haveAuthorizationToGlue($customerTransfer)->getAccessToken();
1306+
1307+
$I->amBearerAuthenticated($token);
1308+
}
13091309
}

tests/PyzTest/Glue/Carts/_support/CartsApiTester.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,30 +95,6 @@ public function getGroupKeyFromQuote(QuoteTransfer $quoteTransfer, string $sku):
9595
return null;
9696
}
9797

98-
/**
99-
* @param array<\Generated\Shared\Transfer\ProductConcreteTransfer> $productConcreteTransfers
100-
*
101-
* @return array
102-
*/
103-
protected function mapProductConcreteTransfersToQuoteTransferItems(array $productConcreteTransfers): array
104-
{
105-
$quoteTransferItems = [];
106-
107-
foreach ($productConcreteTransfers as $productConcreteTransfer) {
108-
$quoteTransferItems[] = [
109-
ItemTransfer::SKU => $productConcreteTransfer->getSku(),
110-
ItemTransfer::GROUP_KEY => $productConcreteTransfer->getSku(),
111-
ItemTransfer::ABSTRACT_SKU => $productConcreteTransfer->getAbstractSku(),
112-
ItemTransfer::ID_PRODUCT_ABSTRACT => $productConcreteTransfer->getFkProductAbstract(),
113-
ItemTransfer::UNIT_PRICE => random_int(100, 1000),
114-
ItemTransfer::UNIT_GROSS_PRICE => random_int(100, 1000),
115-
ItemTransfer::QUANTITY => 1,
116-
];
117-
}
118-
119-
return $quoteTransferItems;
120-
}
121-
12298
/**
12399
* @param \PyzTest\Glue\Carts\CartsApiTester $I
124100
* @param string $cartUuid
@@ -311,4 +287,28 @@ public function buildGuestCartItemUrl(
311287
],
312288
);
313289
}
290+
291+
/**
292+
* @param array<\Generated\Shared\Transfer\ProductConcreteTransfer> $productConcreteTransfers
293+
*
294+
* @return array
295+
*/
296+
protected function mapProductConcreteTransfersToQuoteTransferItems(array $productConcreteTransfers): array
297+
{
298+
$quoteTransferItems = [];
299+
300+
foreach ($productConcreteTransfers as $productConcreteTransfer) {
301+
$quoteTransferItems[] = [
302+
ItemTransfer::SKU => $productConcreteTransfer->getSku(),
303+
ItemTransfer::GROUP_KEY => $productConcreteTransfer->getSku(),
304+
ItemTransfer::ABSTRACT_SKU => $productConcreteTransfer->getAbstractSku(),
305+
ItemTransfer::ID_PRODUCT_ABSTRACT => $productConcreteTransfer->getFkProductAbstract(),
306+
ItemTransfer::UNIT_PRICE => random_int(100, 1000),
307+
ItemTransfer::UNIT_GROSS_PRICE => random_int(100, 1000),
308+
ItemTransfer::QUANTITY => 1,
309+
];
310+
}
311+
312+
return $quoteTransferItems;
313+
}
314314
}

tests/PyzTest/Glue/Orders/RestApi/OrdersRestApiFixtures.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,35 @@ public function buildFixtures(OrdersApiTester $I): FixturesContainerInterface
9797
return $this;
9898
}
9999

100+
/**
101+
* @param \PyzTest\Glue\Orders\OrdersApiTester $I
102+
*
103+
* @return \Generated\Shared\Transfer\ProductConcreteTransfer
104+
*/
105+
public function createProductTransfer(OrdersApiTester $I): ProductConcreteTransfer
106+
{
107+
return $I->haveProduct();
108+
}
109+
110+
/**
111+
* @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
112+
* @param array $productTransfers
113+
*
114+
* @return \Spryker\Shared\Kernel\Transfer\AbstractTransfer
115+
*/
116+
public function createQuoteTransfer(CustomerTransfer $customerTransfer, array $productTransfers): AbstractTransfer
117+
{
118+
return (new QuoteBuilder())
119+
->withItem($productTransfers)
120+
->withCustomer([CustomerTransfer::CUSTOMER_REFERENCE => $customerTransfer->getCustomerReference()])
121+
->withTotals([TotalsTransfer::GRAND_TOTAL => static::TEST_GRAND_TOTAL])
122+
->withShippingAddress()
123+
->withBillingAddress()
124+
->withCurrency()
125+
->withPayment()
126+
->build();
127+
}
128+
100129
/**
101130
* @param \PyzTest\Glue\Orders\OrdersApiTester $I
102131
*
@@ -140,33 +169,4 @@ protected function createCustomerTransfer(OrdersApiTester $I, string $name, stri
140169

141170
return $I->confirmCustomer($customerTransfer);
142171
}
143-
144-
/**
145-
* @param \PyzTest\Glue\Orders\OrdersApiTester $I
146-
*
147-
* @return \Generated\Shared\Transfer\ProductConcreteTransfer
148-
*/
149-
public function createProductTransfer(OrdersApiTester $I): ProductConcreteTransfer
150-
{
151-
return $I->haveProduct();
152-
}
153-
154-
/**
155-
* @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
156-
* @param array $productTransfers
157-
*
158-
* @return \Spryker\Shared\Kernel\Transfer\AbstractTransfer
159-
*/
160-
public function createQuoteTransfer(CustomerTransfer $customerTransfer, array $productTransfers): AbstractTransfer
161-
{
162-
return (new QuoteBuilder())
163-
->withItem($productTransfers)
164-
->withCustomer([CustomerTransfer::CUSTOMER_REFERENCE => $customerTransfer->getCustomerReference()])
165-
->withTotals([TotalsTransfer::GRAND_TOTAL => static::TEST_GRAND_TOTAL])
166-
->withShippingAddress()
167-
->withBillingAddress()
168-
->withCurrency()
169-
->withPayment()
170-
->build();
171-
}
172172
}

tests/PyzTest/Glue/ProductConfigurations/RestApi/Fixtures/ProductConfigurationsRestApiFixtures.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,32 @@ public function buildFixtures(ProductConfigurationsApiTester $I): FixturesContai
162162
return $this;
163163
}
164164

165+
/**
166+
* @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
167+
* @param \Generated\Shared\Transfer\ProductConcreteTransfer $productConcreteTransfer
168+
* @param \Generated\Shared\Transfer\ProductConfigurationInstanceTransfer $productConfigurationInstanceTransfer
169+
*
170+
* @return \Generated\Shared\Transfer\QuoteTransfer
171+
*/
172+
public function createQuoteTransfer(
173+
CustomerTransfer $customerTransfer,
174+
ProductConcreteTransfer $productConcreteTransfer,
175+
ProductConfigurationInstanceTransfer $productConfigurationInstanceTransfer,
176+
): QuoteTransfer {
177+
return (new QuoteBuilder())
178+
->withItem([
179+
ItemTransfer::PRODUCT_CONFIGURATION_INSTANCE => $productConfigurationInstanceTransfer->toArray(),
180+
ItemTransfer::SKU => $productConcreteTransfer->getSku(),
181+
])
182+
->withCustomer([CustomerTransfer::CUSTOMER_REFERENCE => $customerTransfer->getCustomerReference()])
183+
->withTotals()
184+
->withShippingAddress()
185+
->withBillingAddress()
186+
->withCurrency()
187+
->withPayment()
188+
->build();
189+
}
190+
165191
/**
166192
* @param \PyzTest\Glue\ProductConfigurations\ProductConfigurationsApiTester $I
167193
*
@@ -236,32 +262,6 @@ protected function createOrder(ProductConfigurationsApiTester $I): void
236262
->saveSalesOrderItemConfigurationsFromQuote($quoteTransfer);
237263
}
238264

239-
/**
240-
* @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer
241-
* @param \Generated\Shared\Transfer\ProductConcreteTransfer $productConcreteTransfer
242-
* @param \Generated\Shared\Transfer\ProductConfigurationInstanceTransfer $productConfigurationInstanceTransfer
243-
*
244-
* @return \Generated\Shared\Transfer\QuoteTransfer
245-
*/
246-
public function createQuoteTransfer(
247-
CustomerTransfer $customerTransfer,
248-
ProductConcreteTransfer $productConcreteTransfer,
249-
ProductConfigurationInstanceTransfer $productConfigurationInstanceTransfer,
250-
): QuoteTransfer {
251-
return (new QuoteBuilder())
252-
->withItem([
253-
ItemTransfer::PRODUCT_CONFIGURATION_INSTANCE => $productConfigurationInstanceTransfer->toArray(),
254-
ItemTransfer::SKU => $productConcreteTransfer->getSku(),
255-
])
256-
->withCustomer([CustomerTransfer::CUSTOMER_REFERENCE => $customerTransfer->getCustomerReference()])
257-
->withTotals()
258-
->withShippingAddress()
259-
->withBillingAddress()
260-
->withCurrency()
261-
->withPayment()
262-
->build();
263-
}
264-
265265
/**
266266
* @param \PyzTest\Glue\ProductConfigurations\ProductConfigurationsApiTester $I
267267
*

tests/PyzTest/Glue/ProductConfigurations/_support/ProductConfigurationsApiTester.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,6 @@ public function seeCartItemContainsProductConfigurationInstance(
101101
$this->assertArrayHasKey('productConfigurationInstance', $includedByTypeAndSku);
102102
}
103103

104-
/**
105-
* @return array<string, mixed>
106-
*/
107-
protected function grabProductConfigurationInstanceDataFromConcreteProductsResource(): array
108-
{
109-
return $this->getDataFromResponseByJsonPath('$.data.attributes.productConfigurationInstance');
110-
}
111-
112-
/**
113-
* @return array<string, mixed>
114-
*/
115-
protected function grabProductConfigurationInstanceDataFromOrdersResource(): array
116-
{
117-
return $this->getDataFromResponseByJsonPath('$.data.attributes.items[0].salesOrderItemConfiguration');
118-
}
119-
120104
/**
121105
* @param string $resourceName
122106
* @param string $sku
@@ -140,6 +124,22 @@ public function grabIncludedByTypeAndSku(string $resourceName, string $sku): arr
140124
return [];
141125
}
142126

127+
/**
128+
* @return array<string, mixed>
129+
*/
130+
protected function grabProductConfigurationInstanceDataFromConcreteProductsResource(): array
131+
{
132+
return $this->getDataFromResponseByJsonPath('$.data.attributes.productConfigurationInstance');
133+
}
134+
135+
/**
136+
* @return array<string, mixed>
137+
*/
138+
protected function grabProductConfigurationInstanceDataFromOrdersResource(): array
139+
{
140+
return $this->getDataFromResponseByJsonPath('$.data.attributes.items[0].salesOrderItemConfiguration');
141+
}
142+
143143
/**
144144
* @param \Generated\Shared\Transfer\ProductConfigurationTransfer $productConfigurationTransfer
145145
* @param \Generated\Shared\Transfer\RestProductConfigurationInstanceAttributesTransfer $restProductConfigurationInstanceAttributesTransfer

0 commit comments

Comments
 (0)