![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/TestFramework/Test/Unit/Unit/Utility/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Framework\TestFramework\Test\Unit\Unit\Utility; use Magento\Framework\TestFramework\Unit\Utility\XsdValidator; use PHPUnit\Framework\TestCase; class XsdValidatorTest extends TestCase { /** * @var XsdValidator */ protected $_validator; /** * Path to xsd schema file * @var string */ protected $_xsdSchema; protected function setUp(): void { if (!function_exists('libxml_set_external_entity_loader')) { $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033'); } $this->_validator = new XsdValidator(); $this->_xsdSchema = realpath(__DIR__ . '/_files/valid.xsd'); } public function testValidXml() { $xmlFile = realpath(__DIR__ . '/_files/valid.xml'); $xmlString = file_get_contents($xmlFile); $this->assertEquals([], $this->_validator->validate($this->_xsdSchema, $xmlString)); } public function testInvalidXml() { $xmlFile = realpath(__DIR__ . '/_files/invalid.xml'); $expected = [ "Element 'block', attribute 'type': The attribute 'type' is not allowed.\nLine: 9\n", "Element 'actions': This element is not expected. Expected is ( property ).\nLine: 10\n", ]; $xmlString = file_get_contents($xmlFile); $this->assertEquals($expected, $this->_validator->validate($this->_xsdSchema, $xmlString)); } }