Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MergedXsdTest.php
Go to the documentation of this file.
1 <?php
7 
8 class MergedXsdTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_schemaLocator;
14 
19  protected $_xsdSchema;
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->_schemaLocator = new \Magento\Framework\Acl\AclResource\Config\SchemaLocator(
32  new \Magento\Framework\Config\Dom\UrnResolver()
33  );
34  $this->_xsdSchema = $this->_schemaLocator->getSchema();
35  $this->_xsdValidator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator();
36  }
37 
43  public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError)
44  {
45  $actualError = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
46  $this->assertEquals($expectedError, $actualError);
47  }
48 
50  {
51  $xmlString = file_get_contents(__DIR__ . '/_files/valid_merged_acl.xml');
52  $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
53 
54  $this->assertEmpty($actualResult);
55  }
56 
61  {
62  return include __DIR__ . '/_files/invalidMergedAclXmlArray.php';
63  }
64 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60