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->views)); $stateExistent = $this->getMock('Magento\\Framework\\Mview\\Indexer\\State', ['getViewId', '__wakeup', 'delete'], [], '', false); $stateExistent->expects($this->once())->method('getViewId')->will($this->returnValue('view1')); $stateExistent->expects($this->never())->method('delete'); $stateNonexistent = $this->getMock('Magento\\Framework\\Mview\\Indexer\\State', ['getViewId', '__wakeup', 'delete'], [], '', false); $stateNonexistent->expects($this->once())->method('getViewId')->will($this->returnValue('view2')); $stateNonexistent->expects($this->once())->method('delete'); $states = [$stateExistent, $stateNonexistent]; $this->stateCollection->expects($this->once())->method('getItems')->will($this->returnValue($states)); $this->model = new \Magento\Framework\Mview\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('mview.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')); }