Пример #1
0
 /**
  * Regenerate indexes for all indexers
  *
  * @return void
  */
 public function reindexAll()
 {
     /** @var IndexerInterface[] $indexers */
     $indexers = $this->indexersFactory->create()->getItems();
     foreach ($indexers as $indexer) {
         $indexer->reindexAll();
     }
 }
Пример #2
0
 public function testReindexAll()
 {
     $indexerMock = $this->getMock('Magento\\Indexer\\Model\\Indexer', [], [], '', false);
     $indexerMock->expects($this->exactly(2))->method('reindexAll');
     $indexers = [$indexerMock, $indexerMock];
     $indexersMock = $this->getMock('Magento\\Indexer\\Model\\Indexer\\Collection', [], [], '', false);
     $this->indexersFactoryMock->expects($this->once())->method('create')->will($this->returnValue($indexersMock));
     $indexersMock->expects($this->once())->method('getItems')->will($this->returnValue($indexers));
     $this->model->reindexAll();
 }
Пример #3
0
 /**
  * @param string $args
  * @dataProvider runExceptionDataProvider
  */
 public function testRunException($args)
 {
     $indexerMock = $this->getMock('\\Magento\\Indexer\\Model\\Indexer', ['reindexAll', 'turnViewOff', 'turnViewOn'], [], '', false);
     $this->model->setRawArgs(['testme.php', '--', $args]);
     if ($args == 'reindex') {
         $indexerMock->expects($this->any())->method('reindexAll')->will($this->throwException(new \Exception()));
     }
     if ($args == '--mode-realtime') {
         $indexerMock->expects($this->any())->method('turnViewOff')->will($this->throwException(new \Exception()));
     }
     if ($args == 'reindexall') {
         $indexerMock->expects($this->any())->method('reindexAll')->will($this->throwException(new \Magento\Framework\Exception\LocalizedException(__('Something went wrong during reindexing all.'))));
     }
     if ($args == '--mode-schedule') {
         $indexerMock->expects($this->any())->method('turnViewOn')->will($this->throwException(new \Magento\Framework\Exception\LocalizedException(__('Something went wrong during turning view on.'))));
     }
     if ($args == '--reindex=price') {
         $this->indexerFactoryMock->expects($this->once())->method('create')->will($this->returnSelf());
         $this->indexerFactoryMock->expects($this->any())->method('load')->will($this->throwException(new \Exception()));
     } else {
         $this->indexersFactoryMock->expects($this->once())->method('create')->will($this->returnSelf());
         $this->indexersFactoryMock->expects($this->once())->method('getItems')->will($this->returnValue([$indexerMock]));
     }
     ob_start();
     $this->assertInstanceOf('\\Magento\\Indexer\\Model\\Shell', $this->model->run());
     ob_end_clean();
     $this->assertEquals(true, $this->model->hasErrors());
 }
Пример #4
0
 /**
  * Returns all indexers
  *
  * @return IndexerInterface[]
  */
 protected function getAllIndexers()
 {
     /** @var Indexer[] $indexers */
     return $this->collectionFactory->create()->getItems();
 }
Пример #5
0
 /**
  * Perform full reindex
  */
 private function reindex()
 {
     foreach ($this->indexerCollectionFactory->create()->getItems() as $indexer) {
         $indexer->reindexAll();
     }
 }