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); }
/** * @dataProvider readerDataProvider */ public function testReadValidConfig($files, $expectedFile) { $this->_fileResolverMock->expects($this->once())->method('get')->with('indexer.xml', 'scope')->will($this->returnValue($files)); $constraint = function (\DOMDocument $actual) use($expectedFile) { try { $expected = file_get_contents(__DIR__ . '/../_files/' . $expectedFile); \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expected, $actual->saveXML()); return true; } catch (\PHPUnit_Framework_AssertionFailedError $e) { return false; } }; $expectedResult = new \stdClass(); $this->_converter->expects($this->once())->method('convert')->with($this->callback($constraint))->will($this->returnValue($expectedResult)); $this->assertSame($expectedResult, $this->_model->read('scope')); }