Skip to content

Commit b3f510d

Browse files
author
Vitaliy Boyko
committed
graphQl-890: Replaced usage of the CartItemQuantity with the CartItemInterface
1 parent db43c11 commit b3f510d

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,14 @@ interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Mo
216216
type ShippingCartAddress implements CartAddressInterface {
217217
available_shipping_methods: [AvailableShippingMethod] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\AvailableShippingMethods")
218218
selected_shipping_method: SelectedShippingMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\SelectedShippingMethod")
219-
items_weight: Float
220-
cart_items: [CartItemQuantity]
219+
items_weight: Float @deprecated
220+
cart_items: [CartItemInterface]
221221
}
222222

223223
type BillingCartAddress implements CartAddressInterface {
224224
}
225225

226-
type CartItemQuantity {
226+
type CartItemQuantity @deprecated(reason: "Use CartItemInterface instead") {
227227
cart_item_id: Int!
228228
quantity: Float!
229229
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ public function testAddSimpleProductToCart()
5252
self::assertArrayHasKey('cart', $response['addSimpleProductsToCart']);
5353
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
5454
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
55+
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
56+
57+
self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
58+
self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']);
59+
self::assertEquals(10, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['value']);
60+
self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['currency']);
61+
62+
self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
63+
self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']);
64+
self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['value']);
65+
self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['currency']);
66+
67+
self::assertArrayHasKey('row_total_including_tax', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
68+
self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']);
69+
self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['value']);
70+
self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['currency']);
5571
}
5672

5773
/**
@@ -262,6 +278,20 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
262278
product {
263279
sku
264280
}
281+
prices {
282+
price {
283+
value
284+
currency
285+
}
286+
row_total {
287+
value
288+
currency
289+
}
290+
row_total_including_tax {
291+
value
292+
currency
293+
}
294+
}
265295
}
266296
}
267297
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ public function testAddSimpleProductToCart()
4747

4848
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
4949
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
50+
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
51+
52+
self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
53+
self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']);
54+
self::assertEquals(10, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['value']);
55+
self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['currency']);
56+
57+
self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
58+
self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']);
59+
self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['value']);
60+
self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['currency']);
61+
62+
self::assertArrayHasKey('row_total_including_tax', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
63+
self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']);
64+
self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['value']);
65+
self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['currency']);
5066
}
5167

5268
/**
@@ -231,6 +247,20 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
231247
product {
232248
sku
233249
}
250+
prices {
251+
price {
252+
value
253+
currency
254+
}
255+
row_total {
256+
value
257+
currency
258+
}
259+
row_total_including_tax {
260+
value
261+
currency
262+
}
263+
}
234264
}
235265
}
236266
}

0 commit comments

Comments
 (0)