Skip to content

Commit 6bf3d68

Browse files
ACQE-8324: Using rest api update guest cart of configurable product
- Fixed empty line issues
1 parent dad7d9a commit 6bf3d68

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartConfigurableItemRepositoryTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,13 @@ private function addConfigurableProductToCart(string $guestCartId): array
117117
{
118118
$configurableProduct = $this->getConfigurableProduct();
119119
$optionData = $this->getConfigurableOptionData($configurableProduct);
120-
121120
$requestData = $this->buildCartItemRequestData(
122121
$guestCartId,
123122
$configurableProduct->getSku(),
124123
$optionData['attribute_id'],
125124
$optionData['option_id']
126125
);
127-
128126
$serviceInfo = $this->getCartServiceInfo($guestCartId, 'add');
129-
130127
$response = $this->_webApiCall($serviceInfo, $requestData);
131128
$this->assertNotNull($response['item_id']);
132129
$this->assertEquals(Configurable::TYPE_CODE, $response['product_type']);
@@ -137,7 +134,6 @@ private function addConfigurableProductToCart(string $guestCartId): array
137134
$requestData['cartItem']['product_option']['extension_attributes']['configurable_item_options'][0]
138135
);
139136

140-
141137
return $response;
142138
}
143139

@@ -164,7 +160,10 @@ private function verifyCartItems(string $guestCartId, int $expectedItemId): void
164160
$this->assertArrayHasKey('product_option', $item);
165161
$this->assertContains($item['sku'], $this->simpleProductSkus);
166162
$this->assertArrayHasKey('extension_attributes', $item['product_option']);
167-
$this->assertArrayHasKey('configurable_item_options', $item['product_option']['extension_attributes']);
163+
$this->assertArrayHasKey(
164+
'configurable_item_options',
165+
$item['product_option']['extension_attributes']
166+
);
168167
break;
169168
}
170169
}
@@ -229,7 +228,6 @@ private function getConfigurableProduct(): ProductInterface
229228
private function getConfigurableOptionData(ProductInterface $configurableProduct): array
230229
{
231230
$configOptions = $configurableProduct->getExtensionAttributes()->getConfigurableProductOptions();
232-
233231
$options = $configOptions[0]->getOptions();
234232
$optionKey = isset($options[null]) ? null : 0;
235233

@@ -248,8 +246,12 @@ private function getConfigurableOptionData(ProductInterface $configurableProduct
248246
* @param string $optionId
249247
* @return array[]
250248
*/
251-
private function buildCartItemRequestData(string $cartId, string $sku, string $attributeId, string $optionId): array
252-
{
249+
private function buildCartItemRequestData(
250+
string $cartId,
251+
string $sku,
252+
string $attributeId,
253+
string $optionId
254+
): array {
253255
return [
254256
'cartItem' => [
255257
'sku' => $sku,
@@ -286,15 +288,12 @@ private function getCartServiceInfo(
286288
if ($action === 'update' && $itemId !== null) {
287289
$resourcePath .= '/' . $itemId;
288290
}
289-
290291
$httpMethod = Request::HTTP_METHOD_POST;
291292
if ($action === 'update') {
292293
$httpMethod = Request::HTTP_METHOD_PUT;
293294
} elseif ($action === 'get') {
294295
$httpMethod = Request::HTTP_METHOD_GET;
295296
}
296-
297-
// Determine SOAP operation based on action
298297
$soapOperation = match ($action) {
299298
'get' => self::SERVICE_NAME_GUEST_CART_ITEM . 'GetList',
300299
'add', 'update' => self::SERVICE_NAME_GUEST_CART_ITEM . 'Save',

0 commit comments

Comments
 (0)