/** * @magentoDataFixture Magento/Catalog/_files/indexer_catalog_category.php * @magentoDbIsolation enabled */ public function testReindexAll() { $categories = $this->getCategories(4); $products = $this->getProducts(2); /** @var Category $categoryFourth */ $categoryFourth = end($categories); foreach ($products as $product) { /** @var \Magento\Catalog\Model\Product $product */ $product->setCategoryIds([$categoryFourth->getId()]); $product->save(); } /** @var Category $categoryThird */ $categoryThird = $categories[2]; $categoryThird->setIsAnchor(true); $categoryThird->save(); $this->clearIndex(); $categories = [self::DEFAULT_ROOT_CATEGORY, $categoryThird->getId(), $categoryFourth->getId()]; $this->indexer->reindexAll(); foreach ($products as $product) { /** @var \Magento\Catalog\Model\Product $product */ foreach ($categories as $categoryId) { $this->assertTrue((bool) $this->productResource->canBeShowInCategory($product, $categoryId)); } $this->assertFalse((bool) $this->productResource->canBeShowInCategory($product, $categoryThird->getParentId())); } }
/** * @magentoDataFixture Magento/Bundle/_files/product.php * @covers \Magento\Indexer\Model\Indexer::reindexAll * @covers \Magento\Bundle\Model\Product\Type::getSearchableData */ public function testPrepareProductIndexForBundleProduct() { $this->indexer->reindexAll(); $select = $this->adapter->select()->from($this->resource->getTableName('catalogsearch_fulltext_scope1'))->where('`data_index` LIKE ?', '%' . 'Bundle Product Items' . '%'); $result = $this->adapter->fetchAll($select); $this->assertCount(1, $result); }
public function testReindexAll() { $this->engine->cleanIndex(); $this->indexer->reindexAll(); $products = $this->search('Simple Product First'); $this->assertCount(1, $products); $this->assertEquals($this->productFirst->getId(), $products[0]->getId()); $products = $this->search('Simple Product'); $this->assertCount(2, $products); $this->assertEquals($this->productFirst->getId(), $products[0]->getId()); $this->assertEquals($this->productSecond->getId(), $products[1]->getId()); }
public function testReindexAll() { $this->indexer->reindexAll(); $products = $this->search('Apple'); $this->assertCount(1, $products); $this->assertEquals($this->productApple->getId(), $products[0]->getId()); $products = $this->search('Simple Product'); $this->assertCount(5, $products); $this->assertEquals($this->productApple->getId(), $products[0]->getId()); $this->assertEquals($this->productBanana->getId(), $products[1]->getId()); $this->assertEquals($this->productOrange->getId(), $products[2]->getId()); $this->assertEquals($this->productPapaya->getId(), $products[3]->getId()); $this->assertEquals($this->productCherry->getId(), $products[4]->getId()); }