Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ParserTest.php
Go to the documentation of this file.
1 <?php
8 
9 class ParserTest extends \PHPUnit\Framework\TestCase
10 {
12  protected $parser;
13 
14  protected function setUp()
15  {
16  if (!function_exists('libxml_set_external_entity_loader')) {
17  $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
18  }
19  $this->parser = new \Magento\Framework\Xml\Parser();
20  }
21 
22  public function testGetXml()
23  {
24  $this->assertEquals(
25  ['data' => [
26  'nodes' => [
27  'text' => ' some text ',
28  'trim_spaces' => '',
29  'cdata' => ' Some data here <strong>html</strong> tags are <i>allowed</i> ',
30  'zero' => '0',
31  'null' => null,
32  ]
33  ]],
34  $this->parser->load(__DIR__ . '/_files/data.xml')->xmlToArray()
35  );
36  }
37 
42  public function testLoadXmlInvalid()
43  {
44  $sampleInvalidXml = '<?xml version="1.0"?><config></onfig>';
45  $this->parser->initErrorHandler();
46  $this->parser->loadXML($sampleInvalidXml);
47  }
48 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60