public function testGet() { $actionInterfaceMock = $this->getMockForAbstractClass('Magento\\Indexer\\Model\\ActionInterface', [], '', false); $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Indexer\\Model\\ActionInterface')->will($this->returnValue($actionInterfaceMock)); $this->model->get('Magento\\Indexer\\Model\\ActionInterface'); $this->assertInstanceOf('Magento\\Indexer\\Model\\ActionInterface', $actionInterfaceMock); }
public function testReindexList() { $ids = [1]; $stateMock = $this->getMock('\\Magento\\Indexer\\Model\\Indexer\\State', ['load', 'save'], [], '', false); $actionMock = $this->getMock('Magento\\Indexer\\Model\\ActionInterface', ['executeFull', 'executeList', 'executeRow'], [], '', false); $this->actionFactoryMock->expects($this->once())->method('create')->will($this->returnValue($actionMock)); $this->stateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stateMock)); $stateMock->expects($this->once())->method('save')->will($this->returnSelf()); $actionMock->expects($this->once())->method('executeList')->with($ids)->will($this->returnSelf()); $this->model->reindexList($ids); }
/** * @expectedException \Exception * @expectedExceptionMessage Test exception */ public function testReindexAllWithException() { $indexId = 'indexer_internal_name'; $this->loadIndexer($indexId); $stateMock = $this->getMock('\\Magento\\Indexer\\Model\\Indexer\\State', ['load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save'], [], '', false); $stateMock->expects($this->once())->method('load')->with($indexId, 'indexer_id')->will($this->returnSelf()); $stateMock->expects($this->never())->method('setIndexerId'); $stateMock->expects($this->once())->method('getId')->will($this->returnValue(1)); $stateMock->expects($this->exactly(2))->method('setStatus')->will($this->returnSelf()); $stateMock->expects($this->once())->method('getStatus')->will($this->returnValue('idle')); $stateMock->expects($this->exactly(2))->method('save')->will($this->returnSelf()); $this->stateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stateMock)); $this->viewMock->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); $this->viewMock->expects($this->never())->method('suspend'); $this->viewMock->expects($this->once())->method('resume'); $actionMock = $this->getMock('Magento\\Indexer\\Model\\ActionInterface', ['executeFull', 'executeList', 'executeRow'], [], '', false); $actionMock->expects($this->once())->method('executeFull')->will($this->returnCallback(function () { throw new \Exception('Test exception'); })); $this->actionFactoryMock->expects($this->once())->method('get')->with('Some\\Class\\Name')->will($this->returnValue($actionMock)); $this->model->reindexAll(); }