Skip to content

Commit 5e9359d

Browse files
committed
MQE-1963: Update XSD Schema to verify that file has only single entity
1 parent f0c174c commit 5e9359d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Magento/FunctionalTestingFramework/Upgrade/RemoveModuleFileInSuiteFiles.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ class RemoveModuleFileInSuiteFiles implements UpgradeInterface
4747
*/
4848
private $testsUpdated = 0;
4949

50+
/**
51+
* Indicate if a match and replace has happened
52+
*
53+
* @var boolean
54+
*/
55+
private $replaced = false;
56+
5057
/**
5158
* Scan all suite xml files, remove <module file="".../> node, and print update message
5259
*
@@ -82,7 +89,12 @@ private function processXmlFiles($xmlFiles)
8289
foreach ($xmlFiles as $file) {
8390
$contents = $file->getContents();
8491
$filePath = $file->getRealPath();
85-
file_put_contents($filePath, $this->removeModuleFileAttributeInSuite($contents, $filePath));
92+
$this->replaced = false;
93+
$contents = $this->removeModuleFileAttributeInSuite($contents, $filePath);
94+
if ($this->replaced) {
95+
file_put_contents($filePath, $contents);
96+
$this->testsUpdated++;
97+
}
8698
}
8799
}
88100

@@ -112,9 +124,9 @@ function ($matches) use ($file) {
112124
. '"' . trim($matches[0]) . '"' . PHP_EOL
113125
. 'is commented out from file: ' . $file . PHP_EOL
114126
);
115-
$this->testsUpdated += 1;
116127
$result = str_replace('<module', '<!--module', $matches[0]);
117128
$result = str_replace('>', '--> <!-- Please replace with <test name="" -->', $result);
129+
$this->replaced = true;
118130
return $result;
119131
},
120132
$contents

0 commit comments

Comments
 (0)