@@ -153,6 +153,44 @@ public function testGetTotalsFromAnotherCustomerCart()
153
153
$ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ('customer3@search.example.com ' ));
154
154
}
155
155
156
+ /**
157
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
158
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/cart_rule_discount_no_coupon.php
159
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
160
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
161
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
162
+ */
163
+ public function testGetDiscountInformation ()
164
+ {
165
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
166
+ $ query = $ this ->getQuery ($ maskedQuoteId );
167
+ $ response = $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
168
+
169
+ $ discountResponse = $ response ['cart ' ]['prices ' ]['discount ' ];
170
+ self ::assertEquals (-10 , $ discountResponse ['amount ' ]['value ' ]);
171
+ self ::assertEquals ('50% Off for all orders ' , $ discountResponse ['label ' ]);
172
+ }
173
+
174
+ /**
175
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
176
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/cart_rule_discount_no_coupon.php
177
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
178
+ * @magentoApiDataFixture Magento/Checkout/_files/discount_10percent_generalusers.php
179
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
180
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
181
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/apply_coupon.php
182
+ */
183
+ public function testGetDiscountInformationWithTwoRulesApplied ()
184
+ {
185
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
186
+ $ query = $ this ->getQuery ($ maskedQuoteId );
187
+ $ response = $ this ->graphQlQuery ($ query , [], '' , $ this ->getHeaderMap ());
188
+
189
+ $ discountResponse = $ response ['cart ' ]['prices ' ]['discount ' ];
190
+ self ::assertEquals (-11 , $ discountResponse ['amount ' ]['value ' ]);
191
+ self ::assertEquals ('50% Off for all orders, Test Coupon for General ' , $ discountResponse ['label ' ]);
192
+ }
193
+
156
194
/**
157
195
* Generates GraphQl query for retrieving cart totals
158
196
*
@@ -188,6 +226,13 @@ private function getQuery(string $maskedQuoteId): string
188
226
currency
189
227
}
190
228
}
229
+ discount {
230
+ label
231
+ amount {
232
+ value
233
+ currency
234
+ }
235
+ }
191
236
}
192
237
}
193
238
}
0 commit comments