Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
XsdTest.php
Go to the documentation of this file.
1 <?php
7 
8 class XsdTest extends \PHPUnit\Framework\TestCase
9 {
14  protected $_xsdSchema;
15 
19  protected $_xsdValidator;
20 
21  protected function setUp()
22  {
23  if (!function_exists('libxml_set_external_entity_loader')) {
24  $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
25  }
26  $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
27  $this->_xsdSchema = $urnResolver->getRealPath('urn:magento:framework:Mview/etc/mview.xsd');
28  $this->_xsdValidator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator();
29  }
30 
36  public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError)
37  {
38  $actualError = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
39  $this->assertEquals($expectedError, $actualError);
40  }
41 
43  {
44  $xmlString = file_get_contents(__DIR__ . '/_files/valid_mview.xml');
45  $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
46 
47  $this->assertEmpty($actualResult);
48  }
49 
54  {
55  return include __DIR__ . '/_files/invalidMviewXmlArray.php';
56  }
57 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError)
Definition: XsdTest.php:36