Skip to content

Commit eeef0be

Browse files
committed
MAGETWO-91437: Fix tests
1 parent 2c9cc60 commit eeef0be

File tree

1 file changed

+120
-120
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category

1 file changed

+120
-120
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/ProductTest.php

Lines changed: 120 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -88,126 +88,126 @@ public function testReindexAll()
8888
}
8989
}
9090

91-
// /**
92-
// * @magentoAppArea adminhtml
93-
// */
94-
// public function testCategoryMove()
95-
// {
96-
// $categories = $this->getCategories(4);
97-
// $products = $this->getProducts(2);
98-
//
99-
// /** @var Category $categoryFourth */
100-
// $categoryFourth = end($categories);
101-
// foreach ($products as $product) {
102-
// /** @var \Magento\Catalog\Model\Product $product */
103-
// $product->setCategoryIds([$categoryFourth->getId()]);
104-
// $product->save();
105-
// }
106-
//
107-
// /** @var Category $categorySecond */
108-
// $categorySecond = $categories[1];
109-
// $categorySecond->setIsAnchor(true);
110-
// $categorySecond->save();
111-
//
112-
// /** @var Category $categoryThird */
113-
// $categoryThird = $categories[2];
114-
// $categoryThird->setIsAnchor(true);
115-
// $categoryThird->save();
116-
//
117-
// $this->clearIndex();
118-
// $this->indexer->reindexAll();
119-
//
120-
// /**
121-
// * Move $categoryFourth from $categoryThird to $categorySecond
122-
// */
123-
// $categoryFourth->move($categorySecond->getId(), null);
124-
//
125-
// $categories = [self::DEFAULT_ROOT_CATEGORY, $categorySecond->getId(), $categoryFourth->getId()];
126-
//
127-
// foreach ($products as $product) {
128-
// /** @var \Magento\Catalog\Model\Product $product */
129-
// foreach ($categories as $categoryId) {
130-
// $this->assertTrue((bool)$this->productResource->canBeShowInCategory($product, $categoryId));
131-
// }
132-
//
133-
// $this->assertFalse((bool)$this->productResource->canBeShowInCategory($product, $categoryThird->getId()));
134-
// }
135-
// }
136-
//
137-
// /**
138-
// * @magentoAppArea adminhtml
139-
// * @depends testReindexAll
140-
// */
141-
// public function testCategoryDelete()
142-
// {
143-
// $categories = $this->getCategories(4);
144-
// $products = $this->getProducts(2);
145-
//
146-
// /** @var Category $categoryFourth */
147-
// $categoryFourth = end($categories);
148-
// $categoryFourth->delete();
149-
//
150-
// /** @var Category $categorySecond */
151-
// $categorySecond = $categories[1];
152-
//
153-
// $categories = [$categorySecond->getId(), $categoryFourth->getId()];
154-
//
155-
// foreach ($products as $product) {
156-
// /** @var \Magento\Catalog\Model\Product $product */
157-
// foreach ($categories as $categoryId) {
158-
// $this->assertFalse((bool)$this->productResource->canBeShowInCategory($product, $categoryId));
159-
// }
160-
// $this->assertTrue(
161-
// (bool)$this->productResource->canBeShowInCategory($product, self::DEFAULT_ROOT_CATEGORY)
162-
// );
163-
// }
164-
// }
165-
//
166-
// public function testCategoryCreate()
167-
// {
168-
// $this->testReindexAll();
169-
// $categories = $this->getCategories(4);
170-
// $products = $this->getProducts(3);
171-
//
172-
// /** @var Category $categorySecond */
173-
// $categorySecond = $categories[1];
174-
// $categorySecond->setIsAnchor(0);
175-
// $categorySecond->save();
176-
//
177-
// /** @var Category $categoryFourth */
178-
// $categoryFourth = end($categories);
179-
//
180-
// /** @var Category $categorySixth */
181-
// $categorySixth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
182-
// \Magento\Catalog\Model\Category::class
183-
// );
184-
// $categorySixth->setName(
185-
// 'Category 6'
186-
// )->setPath(
187-
// $categoryFourth->getPath()
188-
// )->setAvailableSortBy(
189-
// 'name'
190-
// )->setDefaultSortBy(
191-
// 'name'
192-
// )->setIsActive(
193-
// true
194-
// )->save();
195-
//
196-
// /** @var \Magento\Catalog\Model\Product $productThird */
197-
// $productThird = end($products);
198-
// $productThird->setCategoryIds([$categorySixth->getId()]);
199-
// $productThird->save();
200-
//
201-
// $categories = [self::DEFAULT_ROOT_CATEGORY, $categorySixth->getId(), $categoryFourth->getId()];
202-
// foreach ($categories as $categoryId) {
203-
// $this->assertTrue((bool)$this->productResource->canBeShowInCategory($productThird, $categoryId));
204-
// }
205-
//
206-
// $categories = [$categorySecond->getId()];
207-
// foreach ($categories as $categoryId) {
208-
// $this->assertFalse((bool)$this->productResource->canBeShowInCategory($productThird, $categoryId));
209-
// }
210-
// }
91+
/**
92+
* @magentoAppArea adminhtml
93+
*/
94+
public function testCategoryMove()
95+
{
96+
$categories = $this->getCategories(4);
97+
$products = $this->getProducts(2);
98+
99+
/** @var Category $categoryFourth */
100+
$categoryFourth = end($categories);
101+
foreach ($products as $product) {
102+
/** @var \Magento\Catalog\Model\Product $product */
103+
$product->setCategoryIds([$categoryFourth->getId()]);
104+
$product->save();
105+
}
106+
107+
/** @var Category $categorySecond */
108+
$categorySecond = $categories[1];
109+
$categorySecond->setIsAnchor(true);
110+
$categorySecond->save();
111+
112+
/** @var Category $categoryThird */
113+
$categoryThird = $categories[2];
114+
$categoryThird->setIsAnchor(true);
115+
$categoryThird->save();
116+
117+
$this->clearIndex();
118+
$this->indexer->reindexAll();
119+
120+
/**
121+
* Move $categoryFourth from $categoryThird to $categorySecond
122+
*/
123+
$categoryFourth->move($categorySecond->getId(), null);
124+
125+
$categories = [self::DEFAULT_ROOT_CATEGORY, $categorySecond->getId(), $categoryFourth->getId()];
126+
127+
foreach ($products as $product) {
128+
/** @var \Magento\Catalog\Model\Product $product */
129+
foreach ($categories as $categoryId) {
130+
$this->assertTrue((bool)$this->productResource->canBeShowInCategory($product, $categoryId));
131+
}
132+
133+
$this->assertFalse((bool)$this->productResource->canBeShowInCategory($product, $categoryThird->getId()));
134+
}
135+
}
136+
137+
/**
138+
* @magentoAppArea adminhtml
139+
* @depends testReindexAll
140+
*/
141+
public function testCategoryDelete()
142+
{
143+
$categories = $this->getCategories(4);
144+
$products = $this->getProducts(2);
145+
146+
/** @var Category $categoryFourth */
147+
$categoryFourth = end($categories);
148+
$categoryFourth->delete();
149+
150+
/** @var Category $categorySecond */
151+
$categorySecond = $categories[1];
152+
153+
$categories = [$categorySecond->getId(), $categoryFourth->getId()];
154+
155+
foreach ($products as $product) {
156+
/** @var \Magento\Catalog\Model\Product $product */
157+
foreach ($categories as $categoryId) {
158+
$this->assertFalse((bool)$this->productResource->canBeShowInCategory($product, $categoryId));
159+
}
160+
$this->assertTrue(
161+
(bool)$this->productResource->canBeShowInCategory($product, self::DEFAULT_ROOT_CATEGORY)
162+
);
163+
}
164+
}
165+
166+
public function testCategoryCreate()
167+
{
168+
$this->testReindexAll();
169+
$categories = $this->getCategories(4);
170+
$products = $this->getProducts(3);
171+
172+
/** @var Category $categorySecond */
173+
$categorySecond = $categories[1];
174+
$categorySecond->setIsAnchor(0);
175+
$categorySecond->save();
176+
177+
/** @var Category $categoryFourth */
178+
$categoryFourth = end($categories);
179+
180+
/** @var Category $categorySixth */
181+
$categorySixth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
182+
\Magento\Catalog\Model\Category::class
183+
);
184+
$categorySixth->setName(
185+
'Category 6'
186+
)->setPath(
187+
$categoryFourth->getPath()
188+
)->setAvailableSortBy(
189+
'name'
190+
)->setDefaultSortBy(
191+
'name'
192+
)->setIsActive(
193+
true
194+
)->save();
195+
196+
/** @var \Magento\Catalog\Model\Product $productThird */
197+
$productThird = end($products);
198+
$productThird->setCategoryIds([$categorySixth->getId()]);
199+
$productThird->save();
200+
201+
$categories = [self::DEFAULT_ROOT_CATEGORY, $categorySixth->getId(), $categoryFourth->getId()];
202+
foreach ($categories as $categoryId) {
203+
$this->assertTrue((bool)$this->productResource->canBeShowInCategory($productThird, $categoryId));
204+
}
205+
206+
$categories = [$categorySecond->getId()];
207+
foreach ($categories as $categoryId) {
208+
$this->assertFalse((bool)$this->productResource->canBeShowInCategory($productThird, $categoryId));
209+
}
210+
}
211211

212212
/**
213213
* @magentoAppArea adminhtml

0 commit comments

Comments
 (0)