10
10
use Magento \Catalog \Api \CategoryLinkManagementInterface ;
11
11
use Magento \Catalog \Api \ProductRepositoryInterface ;
12
12
use Magento \Catalog \Model \Product ;
13
- use Magento \Catalog \Model \Product \Visibility ;
14
13
use Magento \SalesRule \Model \ResourceModel \Rule \Collection ;
15
14
use Magento \SalesRule \Model \Rule ;
16
15
use Magento \TestFramework \Helper \Bootstrap ;
@@ -31,16 +30,13 @@ class CartPromotionsTest extends GraphQlAbstract
31
30
*/
32
31
public function testCartPromotionSingleCartRule ()
33
32
{
33
+ $ skus =['simple1 ' , 'simple2 ' ];
34
34
$ objectManager = Bootstrap::getObjectManager ();
35
35
/** @var ProductRepositoryInterface $productRepository */
36
36
$ productRepository = $ objectManager ->get (ProductRepositoryInterface::class);
37
37
/** @var Product $prod2 */
38
38
$ prod1 = $ productRepository ->get ('simple1 ' );
39
39
$ prod2 = $ productRepository ->get ('simple2 ' );
40
- $ productsInCart = [$ prod1 , $ prod2 ];
41
- $ prod2 ->setVisibility (Visibility::VISIBILITY_BOTH );
42
- $ productRepository ->save ($ prod2 );
43
- $ skus =['simple1 ' , 'simple2 ' ];
44
40
$ categoryId = 66 ;
45
41
/** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */
46
42
$ categoryLinkManagement = $ objectManager ->create (CategoryLinkManagementInterface::class);
@@ -63,6 +59,7 @@ public function testCartPromotionSingleCartRule()
63
59
$ query = $ this ->getCartItemPricesQuery ($ cartId );
64
60
$ response = $ this ->graphQlMutation ($ query );
65
61
$ this ->assertCount (2 , $ response ['cart ' ]['items ' ]);
62
+ $ productsInCart = [$ prod1 , $ prod2 ];
66
63
//validating the line item prices, quantity and discount
67
64
$ this ->assertLineItemDiscountPrices ($ response , $ productsInCart , $ qty , $ ruleLabels );
68
65
//total discount on the cart which is the sum of the individual row discounts
@@ -105,7 +102,7 @@ private function assertLineItemDiscountPrices($response, $productsInCart, $qty,
105
102
}
106
103
107
104
/**
108
- * Test applying multiple cart rules to multiple products in a cart
105
+ * Apply multiple cart rules to multiple products in a cart
109
106
*
110
107
* @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
111
108
* @magentoApiDataFixture Magento/SalesRule/_files/rules_category.php
@@ -120,8 +117,6 @@ public function testCartPromotionsMultipleCartRules()
120
117
$ prod1 = $ productRepository ->get ('simple1 ' );
121
118
$ prod2 = $ productRepository ->get ('simple2 ' );
122
119
$ productsInCart = [$ prod1 , $ prod2 ];
123
- $ prod2 ->setVisibility (Visibility::VISIBILITY_BOTH );
124
- $ productRepository ->save ($ prod2 );
125
120
$ skus =['simple1 ' , 'simple2 ' ];
126
121
$ categoryId = 66 ;
127
122
/** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */
@@ -188,8 +183,8 @@ public function testCartPromotionsMultipleCartRules()
188
183
}
189
184
190
185
/**
191
- * Test applying single cart rules to multiple products in a cart with tax settings
192
- * Tax settings are : Including and Excluding tax for Price Display and Shopping cart display settings
186
+ * Apply cart rules to multiple products in a cart with taxes
187
+ * Tax settings : Including and Excluding tax for Price Display and Shopping cart display
193
188
* Discount on Prices Includes Tax
194
189
* Tax rate = 7.5%
195
190
* Cart rule to apply 50% for products assigned to a specific category
@@ -287,8 +282,7 @@ public function testCartPromotionsWithCoupons()
287
282
$ prod1 = $ productRepository ->get ('simple1 ' );
288
283
$ prod2 = $ productRepository ->get ('simple2 ' );
289
284
$ productsInCart = [$ prod1 , $ prod2 ];
290
- $ prod2 ->setVisibility (Visibility::VISIBILITY_BOTH );
291
- $ productRepository ->save ($ prod2 );
285
+
292
286
$ skus =['simple1 ' , 'simple2 ' ];
293
287
294
288
/** @var Collection $ruleCollection */
@@ -343,14 +337,6 @@ public function testCartPromotionsWithCoupons()
343
337
*/
344
338
public function testCartPromotionsWhenNoDiscountIsAvailable ()
345
339
{
346
- $ objectManager = Bootstrap::getObjectManager ();
347
- /** @var ProductRepositoryInterface $productRepository */
348
- $ productRepository = $ objectManager ->get (ProductRepositoryInterface::class);
349
- /** @var Product $prod2 */
350
- $ prod1 = $ productRepository ->get ('simple1 ' );
351
- $ prod2 = $ productRepository ->get ('simple2 ' );
352
- $ prod2 ->setVisibility (Visibility::VISIBILITY_BOTH );
353
- $ productRepository ->save ($ prod2 );
354
340
$ skus =['simple1 ' , 'simple2 ' ];
355
341
$ qty = 2 ;
356
342
$ cartId = $ this ->createEmptyCart ();
0 commit comments