Skip to content

Commit f91b685

Browse files
author
Prabhu Ram
committed
static test fixes
1 parent b46af1c commit f91b685

File tree

7 files changed

+39
-36
lines changed

7 files changed

+39
-36
lines changed

app/code/Magento/Quote/Model/Cart/BuyRequest/CustomizableOptionDataProvider.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ public function execute(CartItem $cartItem): array
3535
}
3636
$this->validateInput($optionData);
3737

38-
[, $optionId, $optionValue] = $optionData;
39-
$customizableOptionsData[$optionId][] = $optionValue;
38+
[$optionType, $optionId, $optionValue] = $optionData;
39+
if ($optionType == self::OPTION_TYPE) {
40+
$customizableOptionsData[$optionId][] = $optionValue;
41+
}
4042
}
4143

4244
foreach ($cartItem->getEnteredOptions() as $option) {
@@ -47,8 +49,10 @@ public function execute(CartItem $cartItem): array
4749
continue;
4850
}
4951

50-
[, $optionId] = $optionData;
51-
$customizableOptionsData[$optionId][] = $option->getValue();
52+
[$optionType, $optionId] = $optionData;
53+
if ($optionType == self::OPTION_TYPE) {
54+
$customizableOptionsData[$optionId][] = $option->getValue();
55+
}
5256
}
5357

5458
return ['options' => $this->flattenOptionValues($customizableOptionsData)];

app/code/Magento/QuoteBundleOptions/Model/Cart/BuyRequest/BundleDataProvider.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ public function execute(CartItem $cartItem): array
3636
}
3737
$this->validateInput($optionData);
3838

39-
[, $optionId, $optionValueId, $optionQuantity] = $optionData;
40-
$bundleOptionsData['bundle_option'][$optionId] = $optionValueId;
41-
$bundleOptionsData['bundle_option_qty'][$optionId] = $optionQuantity;
39+
[$optionType, $optionId, $optionValueId, $optionQuantity] = $optionData;
40+
if ($optionType == self::OPTION_TYPE) {
41+
$bundleOptionsData['bundle_option'][$optionId] = $optionValueId;
42+
$bundleOptionsData['bundle_option_qty'][$optionId] = $optionQuantity;
43+
}
4244
}
4345
//for bundle options with custom quantity
4446
foreach ($cartItem->getEnteredOptions() as $option) {
@@ -50,10 +52,12 @@ public function execute(CartItem $cartItem): array
5052
}
5153
$this->validateInput($optionData);
5254

53-
[, $optionId, $optionValueId] = $optionData;
54-
$optionQuantity = $option->getValue();
55-
$bundleOptionsData['bundle_option'][$optionId] = $optionValueId;
56-
$bundleOptionsData['bundle_option_qty'][$optionId] = $optionQuantity;
55+
[$optionType, $optionId, $optionValueId] = $optionData;
56+
if ($optionType == self::OPTION_TYPE) {
57+
$optionQuantity = $option->getValue();
58+
$bundleOptionsData['bundle_option'][$optionId] = $optionValueId;
59+
$bundleOptionsData['bundle_option_qty'][$optionId] = $optionQuantity;
60+
}
5761
}
5862

5963
return $bundleOptionsData;

app/code/Magento/QuoteConfigurableOptions/Model/Cart/BuyRequest/SuperAttributeDataProvider.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ public function execute(CartItem $cartItem): array
3535
}
3636
$this->validateInput($optionData);
3737

38-
[, $attributeId, $valueIndex] = $optionData;
39-
$configurableProductData[$attributeId] = $valueIndex;
38+
[$optionType, $attributeId, $valueIndex] = $optionData;
39+
if ($optionType == self::OPTION_TYPE) {
40+
$configurableProductData[$attributeId] = $valueIndex;
41+
}
4042
}
4143

4244
return ['super_attribute' => $configurableProductData];

app/code/Magento/QuoteDownloadableLinks/Model/Cart/BuyRequest/DownloadableLinkDataProvider.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ public function execute(CartItem $cartItem): array
3636
}
3737
$this->validateInput($optionData);
3838

39-
[, $linkId] = $optionData;
40-
$linksData[] = $linkId;
39+
[$optionType, $linkId] = $optionData;
40+
if ($optionType == self::OPTION_TYPE) {
41+
$linksData[] = $linkId;
42+
}
4143
}
4244

4345
return ['links' => $linksData];

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductToCartEndToEndTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ private function getProductOptionsViaQuery(string $sku): array
111111
'value' => $value
112112
];
113113

114-
115114
} elseif (isset($option['selected_option'])) {
116115
$receivedItemOptions['selected_options'][] = reset($option['selected_option'])['uid'];
117116
$expectedItemOptions[$option['option_id']] = reset($option['selected_option'])['option_type_id'];
@@ -132,10 +131,9 @@ private function getProductOptionsViaQuery(string $sku): array
132131
*/
133132
private function getProductQuery(string $sku): string
134133
{
135-
$sku = $options = $values = null; // WTF?
136134
return <<<QUERY
137135
query {
138-
products(filter: { sku: { eq: "$sku" } }) {
136+
products(search: "$sku") {
139137
items {
140138
sku
141139

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductToCartSingleMutationTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,4 @@ private function getAddToCartMutation(
256256
}
257257
MUTATION;
258258
}
259-
260-
private function getCartQuery(string $maskedQuoteId)
261-
{
262-
return <<<QUERY
263-
{
264-
cart(cart_id: "{$maskedQuoteId}") {
265-
total_quantity
266-
}
267-
QUERY;
268-
}
269259
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartItemOptionsFromUID.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,25 @@ public function execute(array $encodedCustomOptions): array
2323
$customOptions = [];
2424

2525
foreach ($encodedCustomOptions['selected_options'] as $selectedOption) {
26-
[,$optionId, $optionValueId] = explode('/', base64_decode($selectedOption));
27-
if (isset($customOptions[$optionId])) {
28-
$customOptions[$optionId] = [$customOptions[$optionId], $optionValueId];
29-
} else {
30-
$customOptions[$optionId] = $optionValueId;
26+
[$optionType, $optionId, $optionValueId] = explode('/', base64_decode($selectedOption));
27+
if ($optionType == 'custom-option') {
28+
if (isset($customOptions[$optionId])) {
29+
$customOptions[$optionId] = [$customOptions[$optionId], $optionValueId];
30+
} else {
31+
$customOptions[$optionId] = $optionValueId;
32+
}
3133
}
32-
3334
}
3435

3536
foreach ($encodedCustomOptions['entered_options'] as $enteredOption) {
3637
/* The date normalization is required since the attribute might value is formatted by the system */
3738
if ($enteredOption['type'] === 'date') {
3839
$enteredOption['value'] = date('M d, Y', strtotime($enteredOption['value']));
3940
}
40-
[,$optionId] = explode('/', base64_decode($enteredOption['id']));
41-
$customOptions[$optionId] = $enteredOption['value'];
41+
[$optionType, $optionId] = explode('/', base64_decode($enteredOption['id']));
42+
if ($optionType = 'custom-option') {
43+
$customOptions[$optionId] = $enteredOption['value'];
44+
}
4245
}
4346

4447
return $customOptions;

0 commit comments

Comments
 (0)