Example #1
0
 /**
  * Delete all states that are not in configuration
  *
  * @return void
  */
 protected function deleteNonexistentStates()
 {
     foreach ($this->stateCollection->getItems() as $state) {
         /** @var \Magento\Indexer\Model\Indexer\State $state */
         if (!isset($this->_data[$state->getIndexerId()])) {
             $state->delete();
         }
     }
 }
Example #2
0
 public function testConstructorWithoutCache()
 {
     $this->cache->expects($this->once())->method('test')->with($this->cacheId)->will($this->returnValue(false));
     $this->cache->expects($this->once())->method('load')->with($this->cacheId)->will($this->returnValue(false));
     $this->reader->expects($this->once())->method('read')->will($this->returnValue($this->indexers));
     $stateExistent = $this->getMock('Magento\\Indexer\\Model\\Indexer\\State', ['getIndexerId', '__wakeup', 'delete'], [], '', false);
     $stateExistent->expects($this->once())->method('getIndexerId')->will($this->returnValue('indexer1'));
     $stateExistent->expects($this->never())->method('delete');
     $stateNonexistent = $this->getMock('Magento\\Indexer\\Model\\Indexer\\State', ['getIndexerId', '__wakeup', 'delete'], [], '', false);
     $stateNonexistent->expects($this->once())->method('getIndexerId')->will($this->returnValue('indexer2'));
     $stateNonexistent->expects($this->once())->method('delete');
     $states = [$stateExistent, $stateNonexistent];
     $this->stateCollection->expects($this->once())->method('getItems')->will($this->returnValue($states));
     $this->model = new \Magento\Indexer\Model\Config\Data($this->reader, $this->cache, $this->stateCollection, $this->cacheId);
 }
 public function testConstruct()
 {
     $entityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactoryInterface');
     $loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface');
     $managerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
     $resourceMock = $this->getMock('Magento\\Framework\\Flag\\Resource', [], [], '', false);
     $resourceMock->expects($this->any())->method('getReadConnection')->will($this->returnValue($connectionMock));
     $selectMock = $this->getMock('Zend_Db_Select', ['getPart', 'setPart', 'from', 'columns'], [$connectionMock]);
     $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
     $this->model = new \Magento\Indexer\Model\Resource\Indexer\State\Collection($entityFactoryMock, $loggerMock, $fetchStrategyMock, $managerMock, $connectionMock, $resourceMock);
     $this->assertInstanceOf('Magento\\Indexer\\Model\\Resource\\Indexer\\State\\Collection', $this->model);
     $this->assertEquals('Magento\\Indexer\\Model\\Indexer\\State', $this->model->getModelName());
     $this->assertEquals('Magento\\Indexer\\Model\\Resource\\Indexer\\State', $this->model->getResourceModelName());
 }