fileResolverMock = $this->getMockBuilder(\Magento\Framework\Config\FileResolverInterface::class) ->getMockForAbstractClass(); $this->converterMock = $this->getMockBuilder(\Magento\Config\Model\Config\Structure\Converter::class) ->disableOriginalConstructor() ->getMock(); $this->schemaLocatorMock = $this->getMockBuilder(\Magento\Config\Model\Config\SchemaLocator::class) ->disableOriginalConstructor() ->getMock(); $this->validationStateMock = $this->getMockBuilder(\Magento\Framework\Config\ValidationStateInterface::class) ->getMockForAbstractClass(); $this->compilerMock = $this->getMockBuilder( \Magento\Framework\View\TemplateEngine\Xhtml\CompilerInterface::class )->getMockForAbstractClass(); $this->reader = new \Magento\Config\Model\Config\Structure\Reader( $this->fileResolverMock, $this->converterMock, $this->schemaLocatorMock, $this->validationStateMock, $this->compilerMock ); } /** * Test the successful execution of the 'read' method * * @return void */ public function testReadSuccessNotValidatedCase() { $content = ''; $expectedResult = ['result_data']; $fileList = ['file' => $content]; $this->fileResolverMock->expects($this->once()) ->method('get') ->with('system.xml', 'global') ->willReturn($fileList); $this->compilerMock->expects($this->once()) ->method('compile') ->with( $this->isInstanceOf('\DOMElement'), $this->isInstanceOf(\Magento\Framework\DataObject::class), $this->isInstanceOf(\Magento\Framework\DataObject::class) ); $this->converterMock->expects($this->once()) ->method('convert') ->with($this->isInstanceOf('\DOMDocument')) ->willReturn($expectedResult); $this->assertEquals($expectedResult, $this->reader->read()); } /** * Test the execution with the Validation exception of the 'read' method * * @expectedException \Magento\Framework\Exception\LocalizedException * @expectedExceptionMessage Verify the XML and try again. */ public function testReadWithValidationException() { $content = ''; $expectedResult = ['result_data']; $fileList = ['file' => $content]; $this->fileResolverMock->expects($this->once()) ->method('get') ->with('system.xml', 'global') ->willReturn($fileList); $this->assertEquals($expectedResult, $this->reader->read()); } }