This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree 2 files changed +26
-2
lines changed
Test/Unit/Model/Config/Structure
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -124,14 +124,18 @@ protected function _readFiles($fileList)
124
124
* Processing nodes of the document before merging
125
125
*
126
126
* @param string $content
127
+ * @throws \Magento\Framework\Config\Dom\ValidationException
127
128
* @return string
128
129
*/
129
130
protected function processingDocument ($ content )
130
131
{
131
132
$ object = new DataObject ();
132
133
$ document = new \DOMDocument ();
133
-
134
- $ document ->loadXML ($ content );
134
+ try {
135
+ $ document ->loadXML ($ content );
136
+ } catch (\Exception $ e ) {
137
+ throw new \Magento \Framework \Config \Dom \ValidationException ($ e ->getMessage ());
138
+ }
135
139
$ this ->compiler ->compile ($ document ->documentElement , $ object , $ object );
136
140
137
141
return $ document ->saveXML ();
Original file line number Diff line number Diff line change @@ -100,4 +100,24 @@ public function testReadSuccessNotValidatedCase()
100
100
101
101
$ this ->assertEquals ($ expectedResult , $ this ->reader ->read ());
102
102
}
103
+
104
+ /**
105
+ * Test the execution with the Validation exception of the 'read' method
106
+ *
107
+ * @expectedException \Magento\Framework\Exception\LocalizedException
108
+ * @expectedExceptionMessage Invalid XML in file file:
109
+ */
110
+ public function testReadWithValidationException ()
111
+ {
112
+ $ content = '<config><item name="test1"></item><wrong></config> ' ;
113
+ $ expectedResult = ['result_data ' ];
114
+ $ fileList = ['file ' => $ content ];
115
+
116
+ $ this ->fileResolverMock ->expects ($ this ->once ())
117
+ ->method ('get ' )
118
+ ->with ('system.xml ' , 'global ' )
119
+ ->willReturn ($ fileList );
120
+
121
+ $ this ->assertEquals ($ expectedResult , $ this ->reader ->read ());
122
+ }
103
123
}
You can’t perform that action at this time.
0 commit comments