markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033'); } $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); $this->_schemaFile = $urnResolver->getRealPath('urn:magento:module:Magento_Customer:etc/address_formats.xsd'); } /** * @param string $fixtureXml * @param array $expectedErrors * @dataProvider exemplarXmlDataProvider */ public function testExemplarXml($fixtureXml, array $expectedErrors) { $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class); $validationStateMock->method('isValidationRequired') ->willReturn(true); $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, '%message%'); $actualResult = $dom->validate($this->_schemaFile, $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult); $this->assertEquals($expectedErrors, $actualErrors); } /** * @return array */ public function exemplarXmlDataProvider() { return [ 'valid' => ['', []], 'valid with optional attributes' => [ '', [], ], 'empty root node' => [ '', ["Element 'config': Missing child element(s). Expected is ( format )."], ], 'irrelevant root node' => [ '', ["Element 'attribute': No matching global declaration available for the validation root."], ], 'irrelevant node' => [ '', ["Element 'invalid': This element is not expected. Expected is ( format )."], ], 'non empty node "format"' => [ '', ["Element 'format': Element content is not allowed, because the content type is empty."], ], 'node "format" without attribute "code"' => [ '', ["Element 'format': The attribute 'code' is required but missing."], ], 'node "format" without attribute "title"' => [ '', ["Element 'format': The attribute 'title' is required but missing."], ], 'node "format" with invalid attribute' => [ '', ["Element 'format', attribute 'invalid': The attribute 'invalid' is not allowed."], ], 'attribute "escapeHtml" with invalid type' => [ '', [ "Element 'format', attribute 'escapeHtml': 'invalid' is not a valid value of the atomic type" . " 'xs:boolean'." ], ] ]; } }