10
10
use Magento \Catalog \Api \CategoryLinkManagementInterface ;
11
11
use Magento \Catalog \Api \ProductRepositoryInterface ;
12
12
use Magento \Catalog \Model \Product ;
13
+ use Magento \SalesRule \Api \RuleRepositoryInterface ;
13
14
use Magento \SalesRule \Model \ResourceModel \Rule \Collection ;
14
15
use Magento \SalesRule \Model \Rule ;
15
- use Magento \TestFramework \Helper \Bootstrap ;
16
- use Magento \TestFramework \TestCase \GraphQlAbstract ;
17
16
use Magento \Tax \Model \ClassModel as TaxClassModel ;
18
17
use 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 ;
20
20
21
21
/**
22
22
* Test cases for applying cart promotions to items in cart
@@ -91,8 +91,7 @@ private function assertLineItemDiscountPrices($response, $productsInCart, $qty,
91
91
'total_item_discount ' => ['value ' => $ productsInCart [$ itemIndex ]->getSpecialPrice ()*$ qty *0.5 ],
92
92
'discounts ' => [
93
93
0 =>[
94
- 'amount ' =>
95
- ['value ' => $ productsInCart [$ itemIndex ]->getSpecialPrice ()*$ qty *0.5 ],
94
+ 'amount ' => ['value ' => $ productsInCart [$ itemIndex ]->getSpecialPrice ()*$ qty *0.5 ],
96
95
'label ' => $ ruleLabels [0 ]
97
96
]
98
97
]
@@ -108,6 +107,7 @@ private function assertLineItemDiscountPrices($response, $productsInCart, $qty,
108
107
* @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
109
108
* @magentoApiDataFixture Magento/SalesRule/_files/rules_category.php
110
109
* @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
111
111
*/
112
112
public function testCartPromotionsMultipleCartRules ()
113
113
{
@@ -138,6 +138,7 @@ public function testCartPromotionsMultipleCartRules()
138
138
$ qty = 2 ;
139
139
$ cartId = $ this ->createEmptyCart ();
140
140
$ this ->addMultipleSimpleProductsToCart ($ cartId , $ qty , $ skus [0 ], $ skus [1 ]);
141
+ $ this ->setShippingAddressOnCart ($ cartId );
141
142
$ query = $ this ->getCartItemPricesQuery ($ cartId );
142
143
$ response = $ this ->graphQlMutation ($ query );
143
144
$ this ->assertCount (2 , $ response ['cart ' ]['items ' ]);
@@ -179,8 +180,7 @@ public function testCartPromotionsMultipleCartRules()
179
180
]
180
181
);
181
182
}
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 );
184
184
}
185
185
186
186
/**
@@ -255,8 +255,7 @@ public function testCartPromotionsCartRulesWithTaxes()
255
255
'total_item_discount ' => ['value ' => round ($ rowTotalIncludingTax /2 , 2 )],
256
256
'discounts ' => [
257
257
0 =>[
258
- 'amount ' =>
259
- ['value ' => round ($ rowTotalIncludingTax /2 , 2 )],
258
+ 'amount ' => ['value ' => round ($ rowTotalIncludingTax /2 , 2 )],
260
259
'label ' => 'TestRule_Label '
261
260
]
262
261
]
@@ -318,8 +317,7 @@ public function testCartPromotionsWithCoupons()
318
317
'total_item_discount ' => ['value ' => round (($ rowTotal /$ sumOfPricesForBothProducts )*5 , 2 )],
319
318
'discounts ' => [
320
319
0 =>[
321
- 'amount ' =>
322
- ['value ' => round (($ rowTotal /$ sumOfPricesForBothProducts )*5 , 2 )],
320
+ 'amount ' => ['value ' => round (($ rowTotal /$ sumOfPricesForBothProducts )*5 , 2 )],
323
321
'label ' => $ ruleLabels [0 ]
324
322
]
325
323
]
@@ -425,8 +423,7 @@ public function testCartPromotionsFixedDiscountNotHigherThanProductsPrice()
425
423
'total_item_discount ' => ['value ' => $ rowTotal ],
426
424
'discounts ' => [
427
425
0 =>[
428
- 'amount ' =>
429
- ['value ' => $ rowTotal ],
426
+ 'amount ' => ['value ' => $ rowTotal ],
430
427
'label ' => $ ruleLabels [0 ]
431
428
]
432
429
]
0 commit comments