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 $urnResolver;
20 
24  protected $_xsdValidator;
25 
26  protected function setUp()
27  {
28  if (!function_exists('libxml_set_external_entity_loader')) {
29  $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
30  }
31  $this->urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
32  $this->_xsdSchema = $this->urnResolver->getRealPath('urn:magento:framework:Indexer/etc/indexer.xsd');
33  $this->_xsdValidator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator();
34  }
35 
41  public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError)
42  {
43  $actualError = $this->_xsdValidator->validate(
44  $this->urnResolver->getRealPath('urn:magento:framework:Indexer/etc/indexer_merged.xsd'),
45  $xmlString
46  );
47  $this->assertEquals($expectedError, $actualError);
48  }
49 
51  {
52  $xmlString = file_get_contents(__DIR__ . '/_files/valid_indexer.xml');
53  $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
54 
55  $this->assertEmpty($actualResult);
56  }
57 
62  {
63  return include __DIR__ . '/_files/invalidIndexerXmlArray.php';
64  }
65 }
testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError)
Definition: XsdTest.php:41
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60