/** * @param bool $value * @dataProvider executeDataProvider */ public function testLaunch($value) { $process = $this->getMock('Magento\\Index\\Model\\Process', array('getIndexer', 'reindexEverything', '__wakeup'), array(), '', false); $indexer = $this->getMock('Magento\\Index\\Model\\Indexer', array('getProcessesCollection'), array(), '', false); $indexerInterface = $this->getMock('Magento\\Index\\Model\\IndexerInterface'); $this->_indexFactoryMock->expects($this->once())->method('create')->will($this->returnValue($indexer)); $indexer->expects($this->once())->method('getProcessesCollection')->will($this->returnValue(array($process))); $process->expects($this->any())->method('getIndexer')->will($this->returnValue($indexerInterface)); if ($value) { $indexerInterface->expects($this->once())->method('isVisible')->will($this->returnValue(true)); $process->expects($this->once())->method('reindexEverything'); } else { $indexerInterface->expects($this->once())->method('isVisible')->will($this->returnValue(false)); $process->expects($this->never())->method('reindexEverything'); } $this->assertEquals($this->_responseMock, $this->_entryPoint->launch()); }
/** * @param bool $value * @dataProvider executeDataProvider */ public function testLaunch($value) { $dir = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false); $dir->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0)); $this->_filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($dir)); $process = $this->getMock('Magento\\Index\\Model\\Process', ['getIndexer', 'reindexEverything', '__wakeup'], [], '', false); $indexer = $this->getMock('Magento\\Index\\Model\\Indexer', array('getProcessesCollection'), [], '', false); $indexerInterface = $this->getMock('Magento\\Index\\Model\\IndexerInterface'); $this->_indexFactory->expects($this->once())->method('create')->will($this->returnValue($indexer)); $indexer->expects($this->once())->method('getProcessesCollection')->will($this->returnValue(array($process))); $process->expects($this->any())->method('getIndexer')->will($this->returnValue($indexerInterface)); if ($value) { $indexerInterface->expects($this->once())->method('isVisible')->will($this->returnValue(true)); $process->expects($this->once())->method('reindexEverything'); } else { $indexerInterface->expects($this->once())->method('isVisible')->will($this->returnValue(false)); $process->expects($this->never())->method('reindexEverything'); } $this->assertEquals($this->_response, $this->_entryPoint->launch()); }