![]() 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/module-ui/Test/Unit/Config/Converter/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Ui\Test\Unit\Config\Converter; use Magento\Ui\Config\Converter\HtmlContent; use PHPUnit\Framework\TestCase; class HtmlContentTest extends TestCase { /** * @var HtmlContent */ private $converter; /** * Set up mocks */ protected function setUp(): void { $this->converter = new HtmlContent(); } public function testConvert() { $xml = '<?xml version="1.0"?>' . '<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . '<block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View" name="customer_edit_tab_view" ' . 'template="Magento_Customer::tab/view.phtml">' . '<block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo" ' . 'name="personal_info" template="Magento_Customer::tab/view/personal_info.phtml"/>' . '</block>' . '</layout>'; $expectedResult = [ 'xsi:type' => 'array', 'item' => [ 'layout' => [ 'xsi:type' => 'string', 'name' => 'layout', 'value' => '' ], 'name' => [ 'xsi:type' => 'string', 'name' => 'block', 'value' => 'customer_edit_tab_view', ], ], ]; $dom = new \DOMDocument('1.0', 'UTF-8'); $dom->load(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'testForm.xml'); $domXpath = new \DOMXPath($dom); $node = $domXpath->query('//form/htmlContent/block')->item(0); $actualResult = $this->converter->convert($node, []); $this->assertArrayHasKey('value', $actualResult['item']['layout']); // assert xml structures $this->assertXmlStringEqualsXmlString($xml, $actualResult['item']['layout']['value']); $actualResult['item']['layout']['value'] = ''; // assert that all expected keys in array are exists $this->assertEquals($expectedResult, $actualResult); } }