Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

graphQl-890: Replaced usage of the CartItemQuantity with the CartItem… #899

Merged
6 changes: 3 additions & 3 deletions app/code/Magento/QuoteGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,16 @@ interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Mo
type ShippingCartAddress implements CartAddressInterface {
available_shipping_methods: [AvailableShippingMethod] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\AvailableShippingMethods")
selected_shipping_method: SelectedShippingMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\SelectedShippingMethod")
items_weight: Float
cart_items: [CartItemQuantity]
customer_notes: String
items_weight: Float @deprecated(reason: "This information shoud not be exposed on frontend")
cart_items: [CartItemInterface]
}

type BillingCartAddress implements CartAddressInterface {
customer_notes: String @deprecated (reason: "The field is used only in shipping address")
}

type CartItemQuantity {
type CartItemQuantity @deprecated(reason: "All fields in CartItemQuantity should be deprecated (so this type can be completely removed in the future releases)") {
cart_item_id: Int!
quantity: Float!
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,32 @@ public function testAddSimpleProductToCart()
self::assertArrayHasKey('cart', $response['addSimpleProductsToCart']);
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);

self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
$price = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price'];
self::assertArrayHasKey('value', $price);
self::assertEquals(10, $price['value']);
self::assertArrayHasKey('currency', $price);
self::assertEquals('USD', $price['currency']);

self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
$rowTotal = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total'];
self::assertArrayHasKey('value', $rowTotal);
self::assertEquals(20, $rowTotal['value']);
self::assertArrayHasKey('currency', $rowTotal);
self::assertEquals('USD', $rowTotal['currency']);

self::assertArrayHasKey(
'row_total_including_tax',
$response['addSimpleProductsToCart']['cart']['items'][0]['prices']
);
$rowTotalIncludingTax =
$response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax'];
self::assertArrayHasKey('value', $rowTotalIncludingTax);
self::assertEquals(20, $rowTotalIncludingTax['value']);
self::assertArrayHasKey('currency', $rowTotalIncludingTax);
self::assertEquals('USD', $rowTotalIncludingTax['currency']);
}

/**
Expand Down Expand Up @@ -262,6 +288,20 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
product {
sku
}
prices {
price {
value
currency
}
row_total {
value
currency
}
row_total_including_tax {
value
currency
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ public function testAddSimpleProductToCart()

self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);

self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
$price = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price'];
self::assertArrayHasKey('value', $price);
self::assertEquals(10, $price['value']);
self::assertArrayHasKey('currency', $price);
self::assertEquals('USD', $price['currency']);

self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
$rowTotal = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total'];
self::assertArrayHasKey('value', $rowTotal);
self::assertEquals(20, $rowTotal['value']);
self::assertArrayHasKey('currency', $rowTotal);
self::assertEquals('USD', $rowTotal['currency']);

self::assertArrayHasKey(
'row_total_including_tax',
$response['addSimpleProductsToCart']['cart']['items'][0]['prices']
);
$rowTotalIncludingTax =
$response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax'];
self::assertArrayHasKey('value', $rowTotalIncludingTax);
self::assertEquals(20, $rowTotalIncludingTax['value']);
self::assertArrayHasKey('currency', $rowTotalIncludingTax);
self::assertEquals('USD', $rowTotalIncludingTax['currency']);
}

/**
Expand Down Expand Up @@ -231,6 +257,20 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
product {
sku
}
prices {
price {
value
currency
}
row_total {
value
currency
}
row_total_including_tax {
value
currency
}
}
}
}
}
Expand Down