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 {
16  public function testInvalidXmlFile($xsdFile, $invalidXmlFile, $expectedErrorsQty)
17  {
18  if (!function_exists('libxml_set_external_entity_loader')) {
19  $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
20  }
21  $dom = new \DOMDocument();
22  $dom->load(__DIR__ . "/_files/{$invalidXmlFile}");
23  $schema = __DIR__ . "/../../etc/{$xsdFile}";
24 
25  libxml_use_internal_errors(true);
27  $errorsQty = count($result);
28  libxml_use_internal_errors(false);
29 
30  if ($expectedErrorsQty > 0) {
31  $this->assertNotEmpty($result);
32  }
33  $this->assertEquals($expectedErrorsQty, $errorsQty);
34  }
35 
39  public function invalidXmlFileDataProvider()
40  {
41  return [['view.xsd', 'view_invalid.xml', 8], ['theme.xsd', 'theme_invalid.xml', 1]];
42  }
43 }
static validateDomDocument(\DOMDocument $dom, $schema, $errorFormat=self::ERROR_FORMAT_DEFAULT)
Definition: Dom.php:301
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
testInvalidXmlFile($xsdFile, $invalidXmlFile, $expectedErrorsQty)
Definition: XsdTest.php:16