Skip to content

Commit cf72a8a

Browse files
MAGETWO-62405: Ignoring product visibility for SalesRules
1 parent 55be826 commit cf72a8a

File tree

3 files changed

+28
-30
lines changed

3 files changed

+28
-30
lines changed

dev/tests/integration/testsuite/Magento/SalesRule/Model/Rule/Condition/ProductTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@ protected function setUp()
1919
}
2020

2121
/**
22+
* Ensure that SalesRules filtering on category ignore product visibility
23+
*
2224
* @magentoAppIsolation enabled
2325
* @param int $categoryId
2426
* @param int $visibility
2527
* @param bool $expectedResult
2628
* @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product.php
2729
* @magentoDataFixture Magento/SalesRule/_files/rules_category.php
28-
* @magentoDataFixture Magento/SalesRule/_files/category.php
2930
* @dataProvider validateProductConditionDataProvider
3031
*/
3132
public function testValidateCategorySalesRuleIgnoresVisibility($categoryId, $visibility, $expectedResult)
3233
{
3334
/** @var $session \Magento\Checkout\Model\Session */
3435
$session = $this->objectManager->create(\Magento\Checkout\Model\Session::class);
3536

37+
// Prepare product with given visibility and category settings
3638
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
3739
$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
3840
/** @var $product \Magento\Catalog\Model\Product */
@@ -41,6 +43,7 @@ public function testValidateCategorySalesRuleIgnoresVisibility($categoryId, $vis
4143
$product->setCategoryIds([$categoryId]);
4244
$product->save();
4345

46+
// Load the SalesRule looking for products in a category and assert that the validation is as expected
4447
/** @var $rule \Magento\SalesRule\Model\Rule */
4548
$rule = $this->objectManager->get(\Magento\Framework\Registry::class)
4649
->registry('_fixture/Magento_SalesRule_Category');

dev/tests/integration/testsuite/Magento/SalesRule/_files/category.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/SalesRule/_files/rules_category.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,30 @@
5656

5757
$salesRule->save();
5858

59+
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Category::class);
60+
$category->isObjectNew(true);
61+
$category->setId(
62+
66
63+
)->setCreatedAt(
64+
'2014-06-23 09:50:07'
65+
)->setName(
66+
'Category 1'
67+
)->setParentId(
68+
2
69+
)->setPath(
70+
'1/2/333'
71+
)->setLevel(
72+
2
73+
)->setAvailableSortBy(
74+
['position', 'name']
75+
)->setDefaultSortBy(
76+
'name'
77+
)->setIsActive(
78+
true
79+
)->setPosition(
80+
1
81+
)->save();
82+
5983
/** @var Magento\Framework\Registry $registry */
6084
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
6185

0 commit comments

Comments
 (0)