1010use Magento \Catalog \Api \CategoryLinkManagementInterface ;
1111use Magento \Catalog \Api \ProductRepositoryInterface ;
1212use Magento \Catalog \Model \Product ;
13+ use Magento \SalesRule \Api \RuleRepositoryInterface ;
1314use Magento \SalesRule \Model \ResourceModel \Rule \Collection ;
1415use Magento \SalesRule \Model \Rule ;
15- use Magento \TestFramework \Helper \Bootstrap ;
16- use Magento \TestFramework \TestCase \GraphQlAbstract ;
1716use Magento \Tax \Model \ClassModel as TaxClassModel ;
1817use Magento \Tax \Model \ResourceModel \TaxClass \CollectionFactory as TaxClassCollectionFactory ;
19- use Magento \SalesRule \Api \RuleRepositoryInterface ;
18+ use Magento \TestFramework \Helper \Bootstrap ;
19+ use Magento \TestFramework \TestCase \GraphQlAbstract ;
2020
2121/**
2222 * Test cases for applying cart promotions to items in cart
@@ -91,8 +91,7 @@ private function assertLineItemDiscountPrices($response, $productsInCart, $qty,
9191 'total_item_discount ' => ['value ' => $ productsInCart [$ itemIndex ]->getSpecialPrice ()*$ qty *0.5 ],
9292 'discounts ' => [
9393 0 =>[
94- 'amount ' =>
95- ['value ' => $ productsInCart [$ itemIndex ]->getSpecialPrice ()*$ qty *0.5 ],
94+ 'amount ' => ['value ' => $ productsInCart [$ itemIndex ]->getSpecialPrice ()*$ qty *0.5 ],
9695 'label ' => $ ruleLabels [0 ]
9796 ]
9897 ]
@@ -108,6 +107,7 @@ private function assertLineItemDiscountPrices($response, $productsInCart, $qty,
108107 * @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
109108 * @magentoApiDataFixture Magento/SalesRule/_files/rules_category.php
110109 * @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_10_percent_off_qty_more_than_2_items.php
110+ * @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_free_shipping.php
111111 */
112112 public function testCartPromotionsMultipleCartRules ()
113113 {
@@ -138,6 +138,7 @@ public function testCartPromotionsMultipleCartRules()
138138 $ qty = 2 ;
139139 $ cartId = $ this ->createEmptyCart ();
140140 $ this ->addMultipleSimpleProductsToCart ($ cartId , $ qty , $ skus [0 ], $ skus [1 ]);
141+ $ this ->setShippingAddressOnCart ($ cartId );
141142 $ query = $ this ->getCartItemPricesQuery ($ cartId );
142143 $ response = $ this ->graphQlMutation ($ query );
143144 $ this ->assertCount (2 , $ response ['cart ' ]['items ' ]);
@@ -179,8 +180,7 @@ public function testCartPromotionsMultipleCartRules()
179180 ]
180181 );
181182 }
182- $ this ->assertEquals ($ response ['cart ' ]['prices ' ]['discounts ' ][0 ]['amount ' ]['value ' ], 21.98 );
183- $ this ->assertEquals ($ response ['cart ' ]['prices ' ]['discounts ' ][1 ]['amount ' ]['value ' ], 2.2 );
183+ $ this ->assertEquals ($ response ['cart ' ]['prices ' ]['discounts ' ][0 ]['amount ' ]['value ' ], 24.18 );
184184 }
185185
186186 /**
@@ -255,8 +255,7 @@ public function testCartPromotionsCartRulesWithTaxes()
255255 'total_item_discount ' => ['value ' => round ($ rowTotalIncludingTax /2 , 2 )],
256256 'discounts ' => [
257257 0 =>[
258- 'amount ' =>
259- ['value ' => round ($ rowTotalIncludingTax /2 , 2 )],
258+ 'amount ' => ['value ' => round ($ rowTotalIncludingTax /2 , 2 )],
260259 'label ' => 'TestRule_Label '
261260 ]
262261 ]
@@ -318,8 +317,7 @@ public function testCartPromotionsWithCoupons()
318317 'total_item_discount ' => ['value ' => round (($ rowTotal /$ sumOfPricesForBothProducts )*5 , 2 )],
319318 'discounts ' => [
320319 0 =>[
321- 'amount ' =>
322- ['value ' => round (($ rowTotal /$ sumOfPricesForBothProducts )*5 , 2 )],
320+ 'amount ' => ['value ' => round (($ rowTotal /$ sumOfPricesForBothProducts )*5 , 2 )],
323321 'label ' => $ ruleLabels [0 ]
324322 ]
325323 ]
@@ -425,8 +423,7 @@ public function testCartPromotionsFixedDiscountNotHigherThanProductsPrice()
425423 'total_item_discount ' => ['value ' => $ rowTotal ],
426424 'discounts ' => [
427425 0 =>[
428- 'amount ' =>
429- ['value ' => $ rowTotal ],
426+ 'amount ' => ['value ' => $ rowTotal ],
430427 'label ' => $ ruleLabels [0 ]
431428 ]
432429 ]
0 commit comments