Skip to content

Commit af17d02

Browse files
committed
MQE-683: [Deprecation] Only use more nested assertion syntax
- Cleanup
1 parent 3a901e3 commit af17d02

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/Magento/FunctionalTestingFramework/Upgrade/UpdateAssertionSchema.php

+4-18
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class UpdateAssertionSchema implements UpgradeInterface
3131
private $errors = [];
3232

3333
/**
34-
* Upgrades all test xml files, changing <assert> actions to be nested
34+
* Upgrades all test xml files, changing as many <assert> actions to be nested as possible
35+
* WILL NOT CATCH cases where style is a mix of old and new
3536
*
3637
* @param InputInterface $input
3738
* @return string
@@ -45,12 +46,9 @@ public function execute(InputInterface $input)
4546
$fileSystem = new Filesystem();
4647
$testsUpdated = 0;
4748
foreach ($finder->files() as $file) {
48-
// if (!$this->detectOldAttributes($file)) {
49-
// continue;
50-
// }
5149
$this->currentFile = $file->getFilename();
5250
$contents = $file->getContents();
53-
// Isolate <assert ... /> but not <assert> ... </assert>
51+
// Isolate <assert ... /> but never <assert> ... </assert>
5452
preg_match_all('/<assert[^>]*\/>/', $contents, $potentialAssertions);
5553
$newAssertions = [];
5654
$index = 0;
@@ -98,7 +96,6 @@ private function convertOldAssertionToNew($assertion)
9896
{
9997
// <assertSomething => assertSomething
10098
$assertType = ltrim(explode(' ', $assertion)[0], '<');
101-
$stepKey = "";
10299

103100
// regex to grab values
104101
$grabValueRegex = '/(stepKey|actual|actualType|expected|expectedType|delta|message|selector|attribute|expectedValue|before|after|remove)=(\'[^\']*\'|"[^"]*")/';
@@ -130,9 +127,6 @@ private function convertOldAssertionToNew($assertion)
130127
}
131128
$trimmedParts[$type] = $value;
132129
if (in_array($type, ["stepKey", "delta", "message", "before", "after", "remove"])) {
133-
if ($type == "stepKey") {
134-
$stepKey = $value;
135-
}
136130
$newString .= " $type=\"$value\"";
137131
continue;
138132
}
@@ -154,7 +148,7 @@ private function convertOldAssertionToNew($assertion)
154148
if (isset($subElements["expected"]['value']) && !isset($subElements["expected"]['type'])) {
155149
$subElements["expected"]['type'] = "const";
156150
}
157-
// Massage subElements with data for edge cases
151+
// Massage subElements with data for edge case
158152
if ($assertType == 'assertElementContainsAttribute') {
159153
// Assert type is very edge-cased, completely different schema
160154
$value = $subElements['expected']['value'] ?? "";
@@ -174,12 +168,4 @@ private function convertOldAssertionToNew($assertion)
174168
$newString .= " </$assertType>";
175169
return $newString;
176170
}
177-
178-
private function guessValueType($string) {
179-
preg_match('/\$[a-zA-Z0-9]*/', $string, $matches);
180-
if (isset($matches[0]) && $matches[0] == $string) {
181-
return "variable";
182-
}
183-
return "string";
184-
}
185171
}

0 commit comments

Comments
 (0)