@@ -64,6 +64,90 @@ public function testGetCartTotalsWithTaxApplied()
64
64
self ::assertEquals ('USD ' , $ appliedTaxesResponse [0 ]['amount ' ]['currency ' ]);
65
65
}
66
66
67
+ /**
68
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
69
+ * @magentoApiDataFixture Magento/CatalogRule/_files/catalog_rule_10_off_not_logged.php
70
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
71
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
72
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
73
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
74
+ */
75
+ public function testGetCartTotalsWithCatalogRuleApplied ()
76
+ {
77
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
78
+ $ query = $ this ->getQuery ($ maskedQuoteId );
79
+ $ response = $ this ->graphQlQuery ($ query );
80
+
81
+ $ cartItem = $ response ['cart ' ]['items ' ][0 ];
82
+ self ::assertEquals (9 , $ cartItem ['prices ' ]['price ' ]['value ' ]);
83
+ self ::assertEquals (18 , $ cartItem ['prices ' ]['row_total ' ]['value ' ]);
84
+ self ::assertEquals (18 , $ cartItem ['prices ' ]['row_total_including_tax ' ]['value ' ]);
85
+
86
+ self ::assertArrayHasKey ('prices ' , $ response ['cart ' ]);
87
+ $ pricesResponse = $ response ['cart ' ]['prices ' ];
88
+ self ::assertEquals (18 , $ pricesResponse ['grand_total ' ]['value ' ]);
89
+ self ::assertEquals (18 , $ pricesResponse ['subtotal_including_tax ' ]['value ' ]);
90
+ self ::assertEquals (18 , $ pricesResponse ['subtotal_excluding_tax ' ]['value ' ]);
91
+ self ::assertEquals (18 , $ pricesResponse ['subtotal_with_discount_excluding_tax ' ]['value ' ]);
92
+ }
93
+
94
+ /**
95
+ * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php
96
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
97
+ * @magentoApiDataFixture Magento/CatalogRule/_files/catalog_rule_10_off_not_logged.php
98
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
99
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
100
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
101
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
102
+ */
103
+ public function testGetCartTotalsWithCatalogRuleAndTaxApplied ()
104
+ {
105
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
106
+ $ query = $ this ->getQuery ($ maskedQuoteId );
107
+ $ response = $ this ->graphQlQuery ($ query );
108
+
109
+ $ cartItem = $ response ['cart ' ]['items ' ][0 ];
110
+ self ::assertEquals (9 , $ cartItem ['prices ' ]['price ' ]['value ' ]);
111
+ self ::assertEquals (18 , $ cartItem ['prices ' ]['row_total ' ]['value ' ]);
112
+ self ::assertEquals (19.35 , $ cartItem ['prices ' ]['row_total_including_tax ' ]['value ' ]);
113
+
114
+ self ::assertArrayHasKey ('prices ' , $ response ['cart ' ]);
115
+ $ pricesResponse = $ response ['cart ' ]['prices ' ];
116
+ self ::assertEquals (19.35 , $ pricesResponse ['grand_total ' ]['value ' ]);
117
+ self ::assertEquals (19.35 , $ pricesResponse ['subtotal_including_tax ' ]['value ' ]);
118
+ self ::assertEquals (18 , $ pricesResponse ['subtotal_excluding_tax ' ]['value ' ]);
119
+ self ::assertEquals (18 , $ pricesResponse ['subtotal_with_discount_excluding_tax ' ]['value ' ]);
120
+ }
121
+
122
+ /**
123
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/cart_rule_discount_no_coupon.php
124
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
125
+ * @magentoApiDataFixture Magento/CatalogRule/_files/catalog_rule_10_off_not_logged.php
126
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
127
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
128
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
129
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
130
+ */
131
+ public function testGetCartTotalsWithCatalogRuleAndCartRuleApplied ()
132
+ {
133
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
134
+ $ query = $ this ->getQuery ($ maskedQuoteId );
135
+ $ response = $ this ->graphQlQuery ($ query );
136
+
137
+ $ cartItem = $ response ['cart ' ]['items ' ][0 ];
138
+ self ::assertEquals (9 , $ cartItem ['prices ' ]['price ' ]['value ' ]);
139
+ self ::assertEquals (18 , $ cartItem ['prices ' ]['row_total ' ]['value ' ]);
140
+ self ::assertEquals (18 , $ cartItem ['prices ' ]['row_total_including_tax ' ]['value ' ]);
141
+ self ::assertEquals (9 , $ cartItem ['prices ' ]['total_item_discount ' ]['value ' ]);
142
+
143
+ self ::assertArrayHasKey ('prices ' , $ response ['cart ' ]);
144
+ $ pricesResponse = $ response ['cart ' ]['prices ' ];
145
+ self ::assertEquals (9 , $ pricesResponse ['grand_total ' ]['value ' ]);
146
+ self ::assertEquals (18 , $ pricesResponse ['subtotal_including_tax ' ]['value ' ]);
147
+ self ::assertEquals (18 , $ pricesResponse ['subtotal_excluding_tax ' ]['value ' ]);
148
+ self ::assertEquals (9 , $ pricesResponse ['subtotal_with_discount_excluding_tax ' ]['value ' ]);
149
+ }
150
+
67
151
/**
68
152
* @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php
69
153
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
@@ -190,6 +274,9 @@ private function getQuery(string $maskedQuoteId): string
190
274
value
191
275
currency
192
276
}
277
+ total_item_discount {
278
+ value
279
+ }
193
280
}
194
281
}
195
282
prices {
0 commit comments