Skip to content

Commit f1b41c9

Browse files
committed
MQE-1118: Handle XML merge failures gracefully
- Added filename to error messages for loadXML usage in initDom
1 parent 174a947 commit f1b41c9

File tree

7 files changed

+15
-8
lines changed

7 files changed

+15
-8
lines changed

src/Magento/FunctionalTestingFramework/Config/Dom.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\FunctionalTestingFramework\Config;
88

9+
use Magento\FunctionalTestingFramework\Config\Dom\ValidationException;
10+
911
/**
1012
* Magento configuration XML DOM utility
1113
*/
@@ -354,13 +356,18 @@ public function getDom()
354356
* Create DOM document based on $xml parameter
355357
*
356358
* @param string $xml
359+
* @param string $filename
357360
* @return \DOMDocument
358361
* @throws \Magento\FunctionalTestingFramework\Config\Dom\ValidationException
359362
*/
360-
protected function initDom($xml)
363+
protected function initDom($xml, $filename = null)
361364
{
362365
$dom = new \DOMDocument();
363-
$dom->loadXML($xml);
366+
try {
367+
$dom->loadXML($xml);
368+
} catch (\Exception $exception) {
369+
throw new ValidationException($filename . "\n");
370+
}
364371
if ($this->schemaFile) {
365372
$errors = self::validateDomDocument($dom, $this->schemaFile, $this->errorFormat);
366373
if (count($errors)) {

src/Magento/FunctionalTestingFramework/DataGenerator/Config/Dom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __construct(
6565
*/
6666
public function initDom($xml, $filename = null)
6767
{
68-
$dom = parent::initDom($xml);
68+
$dom = parent::initDom($xml, $filename);
6969

7070
if (strpos($filename, self::DATA_FILE_NAME_ENDING)) {
7171
$entityNodes = $dom->getElementsByTagName('entity');

src/Magento/FunctionalTestingFramework/DataGenerator/Config/OperationDom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __construct(
6565
*/
6666
public function initDom($xml, $filename = null)
6767
{
68-
$dom = parent::initDom($xml);
68+
$dom = parent::initDom($xml, $filename);
6969

7070
if (strpos($filename, self::METADATA_FILE_NAME_ENDING)) {
7171
$operationNodes = $dom->getElementsByTagName('operation');

src/Magento/FunctionalTestingFramework/Page/Config/Dom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function __construct(
7676
*/
7777
public function initDom($xml, $filename = null)
7878
{
79-
$dom = parent::initDom($xml);
79+
$dom = parent::initDom($xml, $filename);
8080

8181
$pagesNode = $dom->getElementsByTagName('pages')->item(0);
8282
$this->validationUtil->validateChildUniqueness($pagesNode, $filename);

src/Magento/FunctionalTestingFramework/Page/Config/SectionDom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __construct(
6767
*/
6868
public function initDom($xml, $filename = null)
6969
{
70-
$dom = parent::initDom($xml);
70+
$dom = parent::initDom($xml, $filename);
7171
$sectionNodes = $dom->getElementsByTagName('section');
7272
foreach ($sectionNodes as $sectionNode) {
7373
$sectionNode->setAttribute(self::SECTION_META_FILENAME_ATTRIBUTE, $filename);

src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ActionGroupDom extends Dom
2626
*/
2727
public function initDom($xml, $filename = null)
2828
{
29-
$dom = parent::initDom($xml);
29+
$dom = parent::initDom($xml, $filename);
3030

3131
if (strpos($filename, self::ACTION_GROUP_FILE_NAME_ENDING)) {
3232
$actionGroupNodes = $dom->getElementsByTagName('actionGroup');

src/Magento/FunctionalTestingFramework/Test/Config/Dom.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(
7979
*/
8080
public function initDom($xml, $filename = null)
8181
{
82-
$dom = parent::initDom($xml);
82+
$dom = parent::initDom($xml, $filename);
8383

8484
if (strpos($filename, self::TEST_FILE_NAME_ENDING)) {
8585
$testNodes = $dom->getElementsByTagName('test');

0 commit comments

Comments
 (0)