markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
}
$urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
$schemaFile = $urnResolver->getRealPath('urn:magento:module:Magento_Email:etc/email_templates.xsd');
$this->_testXmlAgainstXsd($fixtureXml, $schemaFile, $expectedErrors);
}
/**
* @return array
*/
public function mergedXmlDataProvider()
{
// @codingStandardsIgnoreStart
return [
'valid' => [
'',
[],
],
'empty root node' => [
'',
["Element 'config': Missing child element(s). Expected is ( template )."],
],
'irrelevant root node' => [
'',
["Element 'template': No matching global declaration available for the validation root."],
],
'invalid node' => [
'',
["Element 'invalid': This element is not expected. Expected is ( template )."],
],
'node "template" with value' => [
'
invalid
',
["Element 'template': Character content is not allowed, because the content type is empty."],
],
'node "template" with children' => [
'
',
["Element 'template': Element content is not allowed, because the content type is empty."],
],
'node "template" without attribute "id"' => [
'',
["Element 'template': The attribute 'id' is required but missing."],
],
'node "template" without attribute "label"' => [
'',
["Element 'template': The attribute 'label' is required but missing."],
],
'node "template" without attribute "file"' => [
'',
["Element 'template': The attribute 'file' is required but missing."],
],
'node "template" without attribute "type"' => [
'',
["Element 'template': The attribute 'type' is required but missing."],
],
'node "template" with invalid attribute "type"' => [
'',
[
"Element 'template', attribute 'type': " .
"[facet 'enumeration'] The value 'invalid' is not an element of the set {'html', 'text'}.",
"Element 'template', attribute 'type': " .
"'invalid' is not a valid value of the atomic type 'emailTemplateFormatType'."
],
],
'node "template" without attribute "area"' => [
'',
["Element 'template': The attribute 'area' is required but missing."],
],
'node "template" with invalid attribute "area"' => [
'',
[
"Element 'template', attribute 'area': " .
"[facet 'enumeration'] The value 'invalid' is not an element of the set {'frontend', 'adminhtml'}.",
"Element 'template', attribute 'area': " .
"'invalid' is not a valid value of the atomic type 'areaType'."
],
],
'node "template" with unknown attribute' => [
'
',
["Element 'template', attribute 'unknown': The attribute 'unknown' is not allowed."],
]
];
// @codingStandardsIgnoreEnd
}
/**
* Test that XSD schema validates fixture XML contents producing expected results
*
* @param string $fixtureXml
* @param string $schemaFile
* @param array $expectedErrors
*/
protected function _testXmlAgainstXsd($fixtureXml, $schemaFile, 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($schemaFile, $actualErrors);
$this->assertEquals(empty($expectedErrors), $actualResult);
$this->assertEquals($expectedErrors, $actualErrors);
}
}