@@ -27,9 +27,14 @@ public function setUp()
27
27
28
28
public function testConvert ()
29
29
{
30
- $ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
31
- $ dom ->formatOutput = true ;
32
- $ dom ->load (__DIR__ . DIRECTORY_SEPARATOR . '_files ' . DIRECTORY_SEPARATOR . 'expected.xml ' );
30
+ $ xml = '<?xml version="1.0"?> ' .
31
+ '<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ' .
32
+ '<block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View" name="customer_edit_tab_view" ' .
33
+ 'template="Magento_Customer::tab/view.phtml"> ' .
34
+ '<block class="Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo" ' .
35
+ 'name="personal_info" template="Magento_Customer::tab/view/personal_info.phtml"/> ' .
36
+ '</block> ' .
37
+ '</layout> ' ;
33
38
$ expectedResult = [
34
39
'xsi:type ' => 'array ' ,
35
40
'item ' => [
@@ -41,27 +46,23 @@ public function testConvert()
41
46
'name ' => [
42
47
'xsi:type ' => 'string ' ,
43
48
'name ' => 'block ' ,
44
- 'value ' => 'customer_edit_tab_view_content ' ,
49
+ 'value ' => 'customer_edit_tab_view ' ,
45
50
],
46
51
],
47
52
];
48
53
49
54
$ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
50
55
$ dom ->load (dirname (__FILE__ ) . DIRECTORY_SEPARATOR . '_files ' . DIRECTORY_SEPARATOR . 'testForm.xml ' );
51
56
$ domXpath = new \DOMXPath ($ dom );
52
- $ node = $ domXpath ->query ('//form/htmlContent ' )->item (0 );
57
+ $ node = $ domXpath ->query ('//form/htmlContent/block ' )->item (0 );
53
58
54
59
$ actualResult = $ this ->converter ->convert ($ node , []);
55
60
$ this ->assertTrue (isset ($ actualResult ['item ' ]['layout ' ]['value ' ]));
56
61
57
- $ actualDom = $ dom = new \DOMDocument ('1.0 ' , 'UTF-8 ' );
58
- $ actualDom ->formatOutput = true ;
59
- $ actualDom ->loadXML ($ actualResult ['item ' ]['layout ' ]['value ' ]);
62
+ // assert xml structures
63
+ $ this ->assertXmlStringEqualsXmlString ($ xml , $ actualResult ['item ' ]['layout ' ]['value ' ]);
60
64
$ actualResult ['item ' ]['layout ' ]['value ' ] = '' ;
61
65
62
- // assert that expected and actual xml are the same
63
- $ this ->assertSame ($ dom , $ actualDom );
64
-
65
66
// assert that all expected keys in array are exists
66
67
$ this ->assertEquals ($ expectedResult , $ actualResult );
67
68
}
0 commit comments