Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit fd2f731

Browse files
Merge forwardport of magento/magento2#12859 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/12859.patch (created by @pmclain) based on commit(s): 1. ab5e153
2 parents 1dcb55d + 0d557dc commit fd2f731

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

app/code/Magento/Config/Model/Config/Structure/Reader.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,18 @@ protected function _readFiles($fileList)
124124
* Processing nodes of the document before merging
125125
*
126126
* @param string $content
127+
* @throws \Magento\Framework\Config\Dom\ValidationException
127128
* @return string
128129
*/
129130
protected function processingDocument($content)
130131
{
131132
$object = new DataObject();
132133
$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+
}
135139
$this->compiler->compile($document->documentElement, $object, $object);
136140

137141
return $document->saveXML();

app/code/Magento/Config/Test/Unit/Model/Config/Structure/ReaderTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,24 @@ public function testReadSuccessNotValidatedCase()
100100

101101
$this->assertEquals($expectedResult, $this->reader->read());
102102
}
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+
}
103123
}

0 commit comments

Comments
 (0)