/** * @magentoDataFixture Magento/Catalog/_files/row_fixture.php * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 * @magentoAppArea frontend */ public function testProductUpdate() { $this->markTestSkipped('Incomplete due to MAGETWO-21369'); $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\CategoryFactory'); $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Block\\Product\\ListProduct'); $this->_processor->getIndexer()->setScheduled(false); $this->assertFalse($this->_processor->getIndexer()->isScheduled(), 'Indexer is in scheduled mode when turned to update on save mode'); $this->_processor->reindexAll(); $this->_product->load(1); $this->_product->setName('Updated Product'); $this->_product->save(); $category = $categoryFactory->create()->load(9); $layer = $listProduct->getLayer(); $layer->setCurrentCategory($category); /** @var \Magento\Catalog\Model\Resource\Product\Collection $productCollection */ $productCollection = $layer->getProductCollection(); $this->assertTrue($productCollection->isEnabledFlat(), 'Product collection is not using flat resource when flat is on'); $this->assertEquals(2, $productCollection->count(), 'Product collection items count must be exactly 2'); foreach ($productCollection as $product) { /** @var $product \Magento\Catalog\Model\Product */ if ($product->getId() == 1) { $this->assertEquals('Updated Product', $product->getName(), 'Product name from flat does not match with updated name'); } } }
/** * Process flat enabled mode change * * @return void */ public function processValue() { if ((bool) $this->getValue() != (bool) $this->getOldValue()) { if ((bool) $this->getValue()) { $this->indexerState->loadByIndexer(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::INDEXER_ID); $this->indexerState->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID); $this->indexerState->save(); } else { $this->_productFlatIndexerProcessor->getIndexer()->setScheduled(false); } } }
/** * @magentoDbIsolation enabled * @magentoAppIsolation enabled * @magentoAppArea adminhtml * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testAddNewStoreGroup() { /** @var \Magento\Store\Model\Group $storeGroup */ $storeGroup = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Store\\Model\\Group'); $storeGroup->setData(['website_id' => 1, 'name' => 'New Store Group', 'root_category_id' => 2, 'group_id' => null]); $storeGroup->save(); $this->assertTrue($this->_processor->getIndexer()->isInvalid()); }
/** * Test get indexer instance */ public function testGetIndexer() { $this->assertInstanceOf('\\Magento\\Indexer\\Model\\Indexer', $this->_model->getIndexer()); }