Skip to content

Commit 920a64e

Browse files
authored
ENGCOM-5768: graphQl-889: base_amount marked as deprecated #898
2 parents c9fe439 + a52aa16 commit 920a64e

11 files changed

+11
-110
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddress/AvailableShippingMethods.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
7575
);
7676
$methods[] = $this->processMoneyTypeData(
7777
$methodData,
78-
$cart->getQuoteCurrencyCode(),
79-
$context->getExtensionAttributes()->getStore()
78+
$cart->getQuoteCurrencyCode()
8079
);
8180
}
8281
}
@@ -88,21 +87,17 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
8887
*
8988
* @param array $data
9089
* @param string $quoteCurrencyCode
91-
* @param StoreInterface $store
9290
* @return array
9391
* @throws NoSuchEntityException
9492
*/
95-
private function processMoneyTypeData(array $data, string $quoteCurrencyCode, StoreInterface $store): array
93+
private function processMoneyTypeData(array $data, string $quoteCurrencyCode): array
9694
{
9795
if (isset($data['amount'])) {
9896
$data['amount'] = ['value' => $data['amount'], 'currency' => $quoteCurrencyCode];
9997
}
10098

101-
if (isset($data['base_amount'])) {
102-
/** @var Currency $currency */
103-
$currency = $store->getBaseCurrency();
104-
$data['base_amount'] = ['value' => $data['base_amount'], 'currency' => $currency->getCode()];
105-
}
99+
/** @deprecated The field should not be used on the storefront */
100+
$data['base_amount'] = null;
106101

107102
if (isset($data['price_excl_tax'])) {
108103
$data['price_excl_tax'] = ['value' => $data['price_excl_tax'], 'currency' => $quoteCurrencyCode];

app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddress/SelectedShippingMethod.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
4646
}
4747
}
4848

49-
/** @var Currency $currency */
50-
$currency = $context->getExtensionAttributes()->getStore()->getBaseCurrency();
51-
5249
$data = [
5350
'carrier_code' => $carrierCode,
5451
'method_code' => $methodCode,
@@ -58,10 +55,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5855
'value' => $address->getShippingAmount(),
5956
'currency' => $address->getQuote()->getQuoteCurrencyCode(),
6057
],
61-
'base_amount' => [
62-
'value' => $address->getBaseShippingAmount(),
63-
'currency' => $currency->getCode(),
64-
],
58+
/** @deprecated The field should not be used on the storefront */
59+
'base_amount' => null,
6560
];
6661
} else {
6762
$data = [
@@ -70,6 +65,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
7065
'carrier_title' => $carrierTitle,
7166
'method_title' => $methodTitle,
7267
'amount' => null,
68+
/** @deprecated The field should not be used on the storefront */
7369
'base_amount' => null,
7470
];
7571
}

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ type SelectedShippingMethod {
244244
carrier_title: String
245245
method_title: String
246246
amount: Money
247-
base_amount: Money
247+
base_amount: Money @deprecated(reason: "The field should not be used on the storefront")
248248
}
249249

250250
type AvailableShippingMethod {
@@ -254,7 +254,7 @@ type AvailableShippingMethod {
254254
method_title: String @doc(description: "Could be null if method is not available")
255255
error_message: String
256256
amount: Money!
257-
base_amount: Money @doc(description: "Could be null if method is not available")
257+
base_amount: Money @deprecated(reason: "The field should not be used on the storefront")
258258
price_excl_tax: Money!
259259
price_incl_tax: Money!
260260
available: Boolean!

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ public function testGetAvailableShippingMethods()
6262
'value' => 10,
6363
'currency' => 'USD',
6464
],
65-
'base_amount' => [
66-
'value' => 10,
67-
'currency' => 'USD',
68-
],
6965
'carrier_code' => 'flatrate',
7066
'carrier_title' => 'Flat Rate',
7167
'error_message' => '',
@@ -176,10 +172,6 @@ private function getQuery(string $maskedQuoteId): string
176172
value
177173
currency
178174
}
179-
base_amount {
180-
value
181-
currency
182-
}
183175
carrier_code
184176
carrier_title
185177
error_message

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ public function testGetSelectedShippingMethod()
7878
self::assertEquals(10, $amount['value']);
7979
self::assertArrayHasKey('currency', $amount);
8080
self::assertEquals('USD', $amount['currency']);
81-
82-
self::assertArrayHasKey('base_amount', $shippingAddress['selected_shipping_method']);
83-
$baseAmount = $shippingAddress['selected_shipping_method']['base_amount'];
84-
85-
self::assertArrayHasKey('value', $baseAmount);
86-
self::assertEquals(10, $baseAmount['value']);
87-
self::assertArrayHasKey('currency', $baseAmount);
88-
self::assertEquals('USD', $baseAmount['currency']);
8981
}
9082

9183
/**
@@ -188,7 +180,6 @@ public function testGetGetSelectedShippingMethodIfShippingMethodIsNotSet()
188180
self::assertNull($shippingAddress['selected_shipping_method']['carrier_title']);
189181
self::assertNull($shippingAddress['selected_shipping_method']['method_title']);
190182
self::assertNull($shippingAddress['selected_shipping_method']['amount']);
191-
self::assertNull($shippingAddress['selected_shipping_method']['base_amount']);
192183
}
193184

194185
/**
@@ -240,10 +231,6 @@ private function getQuery(string $maskedQuoteId): string
240231
value
241232
currency
242233
}
243-
base_amount {
244-
value
245-
currency
246-
}
247234
}
248235
}
249236
}

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ protected function setUp()
5353
* @param string $carrierTitle
5454
* @param string $methodTitle
5555
* @param array $amount
56-
* @param array $baseAmount
5756
* @throws \Magento\Framework\Exception\NoSuchEntityException
5857
* @dataProvider offlineShippingMethodDataProvider
5958
*/
@@ -62,8 +61,7 @@ public function testSetOfflineShippingMethod(
6261
string $methodCode,
6362
string $carrierTitle,
6463
string $methodTitle,
65-
array $amount,
66-
array $baseAmount
64+
array $amount
6765
) {
6866
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
6967

@@ -96,9 +94,6 @@ public function testSetOfflineShippingMethod(
9694

9795
self::assertArrayHasKey('amount', $shippingAddress['selected_shipping_method']);
9896
self::assertEquals($amount, $shippingAddress['selected_shipping_method']['amount']);
99-
100-
self::assertArrayHasKey('base_amount', $shippingAddress['selected_shipping_method']);
101-
self::assertEquals($baseAmount, $shippingAddress['selected_shipping_method']['base_amount']);
10297
}
10398

10499
/**
@@ -113,23 +108,20 @@ public function offlineShippingMethodDataProvider(): array
113108
'Flat Rate',
114109
'Fixed',
115110
['value' => 10, 'currency' => 'USD'],
116-
['value' => 10, 'currency' => 'USD'],
117111
],
118112
'tablerate_bestway' => [
119113
'tablerate',
120114
'bestway',
121115
'Best Way',
122116
'Table Rate',
123117
['value' => 10, 'currency' => 'USD'],
124-
['value' => 10, 'currency' => 'USD'],
125118
],
126119
'freeshipping_freeshipping' => [
127120
'freeshipping',
128121
'freeshipping',
129122
'Free Shipping',
130123
'Free',
131124
['value' => 0, 'currency' => 'USD'],
132-
['value' => 0, 'currency' => 'USD'],
133125
],
134126
];
135127
}
@@ -166,10 +158,6 @@ private function getQuery(
166158
value
167159
currency
168160
}
169-
base_amount {
170-
value
171-
currency
172-
}
173161
}
174162
}
175163
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,6 @@ public function testSetShippingMethodOnCartWithSimpleProduct()
8585
self::assertEquals(10, $amount['value']);
8686
self::assertArrayHasKey('currency', $amount);
8787
self::assertEquals('USD', $amount['currency']);
88-
89-
self::assertArrayHasKey('base_amount', $shippingAddress['selected_shipping_method']);
90-
$baseAmount = $shippingAddress['selected_shipping_method']['base_amount'];
91-
92-
self::assertArrayHasKey('value', $baseAmount);
93-
self::assertEquals(10, $baseAmount['value']);
94-
self::assertArrayHasKey('currency', $baseAmount);
95-
self::assertEquals('USD', $baseAmount['currency']);
9688
}
9789

9890
/**
@@ -379,10 +371,6 @@ private function getQuery(
379371
value
380372
currency
381373
}
382-
base_amount {
383-
value
384-
currency
385-
}
386374
}
387375
}
388376
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ public function testGetAvailableShippingMethods()
5454
'value' => 10,
5555
'currency' => 'USD',
5656
],
57-
'base_amount' => [
58-
'value' => 10,
59-
'currency' => 'USD',
60-
],
6157
'carrier_code' => 'flatrate',
6258
'carrier_title' => 'Flat Rate',
6359
'error_message' => '',
@@ -144,10 +140,6 @@ private function getQuery(string $maskedQuoteId): string
144140
value
145141
currency
146142
}
147-
base_amount {
148-
value
149-
currency
150-
}
151143
carrier_code
152144
carrier_title
153145
error_message

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ public function testGetSelectedShippingMethod()
7070
self::assertEquals(10, $amount['value']);
7171
self::assertArrayHasKey('currency', $amount);
7272
self::assertEquals('USD', $amount['currency']);
73-
74-
self::assertArrayHasKey('base_amount', $shippingAddress['selected_shipping_method']);
75-
$baseAmount = $shippingAddress['selected_shipping_method']['base_amount'];
76-
77-
self::assertArrayHasKey('value', $baseAmount);
78-
self::assertEquals(10, $baseAmount['value']);
79-
self::assertArrayHasKey('currency', $baseAmount);
80-
self::assertEquals('USD', $baseAmount['currency']);
8173
}
8274

8375
/**
@@ -158,7 +150,6 @@ public function testGetGetSelectedShippingMethodIfShippingMethodIsNotSet()
158150
self::assertNull($shippingAddress['selected_shipping_method']['carrier_title']);
159151
self::assertNull($shippingAddress['selected_shipping_method']['method_title']);
160152
self::assertNull($shippingAddress['selected_shipping_method']['amount']);
161-
self::assertNull($shippingAddress['selected_shipping_method']['base_amount']);
162153
}
163154

164155
/**
@@ -195,10 +186,6 @@ private function getQuery(string $maskedQuoteId): string
195186
value
196187
currency
197188
}
198-
base_amount {
199-
value
200-
currency
201-
}
202189
}
203190
}
204191
}

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ protected function setUp()
4545
* @param string $carrierTitle
4646
* @param string $methodTitle
4747
* @param array $amount
48-
* @param array $baseAmount
4948
* @throws \Magento\Framework\Exception\NoSuchEntityException
5049
* @dataProvider offlineShippingMethodDataProvider
5150
*/
@@ -54,8 +53,7 @@ public function testSetOfflineShippingMethod(
5453
string $methodCode,
5554
string $carrierTitle,
5655
string $methodTitle,
57-
array $amount,
58-
array $baseAmount
56+
array $amount
5957
) {
6058
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
6159

@@ -88,9 +86,6 @@ public function testSetOfflineShippingMethod(
8886

8987
self::assertArrayHasKey('amount', $shippingAddress['selected_shipping_method']);
9088
self::assertEquals($amount, $shippingAddress['selected_shipping_method']['amount']);
91-
92-
self::assertArrayHasKey('base_amount', $shippingAddress['selected_shipping_method']);
93-
self::assertEquals($baseAmount, $shippingAddress['selected_shipping_method']['base_amount']);
9489
}
9590

9691
/**
@@ -105,23 +100,20 @@ public function offlineShippingMethodDataProvider(): array
105100
'Flat Rate',
106101
'Fixed',
107102
['value' => 10, 'currency' => 'USD'],
108-
['value' => 10, 'currency' => 'USD'],
109103
],
110104
'tablerate_bestway' => [
111105
'tablerate',
112106
'bestway',
113107
'Best Way',
114108
'Table Rate',
115109
['value' => 10, 'currency' => 'USD'],
116-
['value' => 10, 'currency' => 'USD'],
117110
],
118111
'freeshipping_freeshipping' => [
119112
'freeshipping',
120113
'freeshipping',
121114
'Free Shipping',
122115
'Free',
123116
['value' => 0, 'currency' => 'USD'],
124-
['value' => 0, 'currency' => 'USD'],
125117
],
126118
];
127119
}
@@ -158,10 +150,6 @@ private function getQuery(
158150
value
159151
currency
160152
}
161-
base_amount {
162-
value
163-
currency
164-
}
165153
}
166154
}
167155
}

0 commit comments

Comments
 (0)