Skip to content

Commit 12d98e7

Browse files
committed
MQE-683: [Deprecation] Only use more nested assertion syntax
- Fixed Ugprade script to use new format
1 parent ca1cbdc commit 12d98e7

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

src/Magento/FunctionalTestingFramework/Upgrade/UpdateAssertionSchema.php

+29-22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\FunctionalTestingFramework\Upgrade;
88

9+
use Magento\FunctionalTestingFramework\Util\Script\ScriptUtil;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Output\OutputInterface;
1112
use Symfony\Component\Filesystem\Filesystem;
@@ -27,33 +28,39 @@ class UpdateAssertionSchema implements UpgradeInterface
2728
*/
2829
public function execute(InputInterface $input, OutputInterface $output)
2930
{
30-
$testsPath = $input->getArgument('path');
31-
$finder = new Finder();
32-
$finder->files()->in($testsPath)->name("*.xml");
31+
$testPaths[] = $input->getArgument('path');
32+
if (empty($testPaths[0])) {
33+
$testPaths = ScriptUtil::getAllModulePaths();
34+
}
3335

34-
$fileSystem = new Filesystem();
3536
$testsUpdated = 0;
36-
foreach ($finder->files() as $file) {
37-
$contents = $file->getContents();
38-
// Isolate <assert ... /> but never <assert> ... </assert>, stops after finding first />
39-
preg_match_all('/<assert.*\/>/', $contents, $potentialAssertions);
40-
$newAssertions = [];
41-
$index = 0;
42-
if (empty($potentialAssertions[0])) {
43-
continue;
44-
}
45-
foreach ($potentialAssertions[0] as $potentialAssertion) {
46-
$newAssertions[$index] = $this->convertOldAssertionToNew($potentialAssertion);
47-
$index++;
48-
}
49-
foreach ($newAssertions as $currentIndex => $replacements) {
50-
$contents = str_replace($potentialAssertions[0][$currentIndex], $replacements, $contents);
37+
foreach ($testPaths as $testsPath) {
38+
$finder = new Finder();
39+
$finder->files()->in($testsPath)->name("*.xml");
40+
41+
$fileSystem = new Filesystem();
42+
foreach ($finder->files() as $file) {
43+
$contents = $file->getContents();
44+
// Isolate <assert ... /> but never <assert> ... </assert>, stops after finding first />
45+
preg_match_all('/<assert.*\/>/', $contents, $potentialAssertions);
46+
$newAssertions = [];
47+
$index = 0;
48+
if (empty($potentialAssertions[0])) {
49+
continue;
50+
}
51+
foreach ($potentialAssertions[0] as $potentialAssertion) {
52+
$newAssertions[$index] = $this->convertOldAssertionToNew($potentialAssertion);
53+
$index++;
54+
}
55+
foreach ($newAssertions as $currentIndex => $replacements) {
56+
$contents = str_replace($potentialAssertions[0][$currentIndex], $replacements, $contents);
57+
}
58+
$fileSystem->dumpFile($file->getRealPath(), $contents);
59+
$testsUpdated++;
5160
}
52-
$fileSystem->dumpFile($file->getRealPath(), $contents);
53-
$testsUpdated++;
5461
}
5562

56-
return ("Assertion Syntax updated in {$testsUpdated} file(s).\n");
63+
return ("Assertion Syntax updated in {$testsUpdated} file(s).");
5764
}
5865

5966
/**

0 commit comments

Comments
 (0)