6
6
7
7
namespace Magento \Customer \Test \Unit \CustomerData ;
8
8
9
+ use Magento \Framework \App \Arguments \ValidationState ;
9
10
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager as ObjectManagerHelper ;
10
11
11
12
class SectionConfigConverterTest extends \PHPUnit \Framework \TestCase
@@ -19,28 +20,66 @@ class SectionConfigConverterTest extends \PHPUnit\Framework\TestCase
19
20
/** @var \DOMDocument */
20
21
protected $ source ;
21
22
23
+ /** @var \Magento\Framework\Config\Dom config merger */
24
+ private $ configMergerClass ;
25
+
26
+ /** @var ValidationState */
27
+ private $ validationStateMock ;
28
+
22
29
protected function setUp ()
23
30
{
24
31
$ this ->source = new \DOMDocument ();
25
32
$ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
26
33
$ this ->converter = $ this ->objectManagerHelper ->getObject (
27
34
\Magento \Customer \CustomerData \SectionConfigConverter::class
28
35
);
36
+ $ this ->validationStateMock = $ this ->createMock (ValidationState::class);
37
+ }
38
+
39
+ /**
40
+ * Return newly created instance of a config merger
41
+ *
42
+ * @param string $mergerClass
43
+ * @param string $initialContents
44
+ * @return \Magento\Framework\Config\Dom
45
+ * @throws \UnexpectedValueException
46
+ */
47
+ private function createConfig ($ mergerClass , $ initialContents )
48
+ {
49
+ $ this ->validationStateMock ->method ('isValidationRequired ' )->willReturn (\false);
50
+ return new $ mergerClass (
51
+ $ initialContents ,
52
+ $ this ->validationStateMock ,
53
+ [
54
+ '/config/action ' => 'name ' ,
55
+ '/config/action/section ' => 'name ' ,
56
+ ],
57
+ null ,
58
+ null
59
+ );
29
60
}
30
61
31
62
public function testConvert ()
32
63
{
33
64
$ this ->source ->loadXML (file_get_contents (__DIR__ . '/_files/sections.xml ' ));
34
65
66
+ $ this ->configMergerClass = $ this ->createConfig (
67
+ 'Magento\Framework\Config\Dom ' ,
68
+ file_get_contents (__DIR__ . '/_files/sections.xml ' )
69
+ );
70
+
71
+ $ this ->configMergerClass ->merge (file_get_contents (__DIR__ . '/_files/sections2.xml ' ));
72
+
35
73
$ this ->assertEquals (
36
74
[
37
75
'sections ' => [
38
76
'customer/account/logout ' => ['* ' ],
77
+ 'empty/test ' => ['account ' ],
39
78
'customer/account/editpost ' => ['account ' ],
40
79
'customer/account/createpost ' => ['account ' , 'acc ' ],
41
80
],
42
81
],
43
- $ this ->converter ->convert ($ this ->source )
82
+ $ this ->converter ->convert ($ this ->configMergerClass -> getDom () )
44
83
);
45
84
}
46
85
}
0 commit comments