Skip to content

Commit 35818bb

Browse files
committed
MQE-683: [Deprecation] Only use more nested assertion syntax
- static check fixes
1 parent 61027d9 commit 35818bb

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/Magento/FunctionalTestingFramework/Upgrade/UpdateAssertionSchema.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@ class UpdateAssertionSchema implements UpgradeInterface
1818
{
1919
const OLD_ASSERTION_ATTRIBUTES = ["expected", "expectedType", "actual", "actualType"];
2020

21+
/**
22+
* Current file being inspected, for error messaging
23+
* @var string
24+
*/
2125
private $currentFile;
26+
27+
/**
28+
* Potential errors reported during replacement.
29+
* @var array
30+
*/
2231
private $errors = [];
32+
2333
/**
2434
* Upgrades all test xml files, changing <assert> actions to be nested
2535
*
@@ -40,7 +50,7 @@ public function execute(InputInterface $input)
4050
}
4151
$this->currentFile = $file->getFilename();
4252
$contents = $file->getContents();
43-
// Isolate <assert ... /> but not <assert ... >
53+
// Isolate <assert ... /> but not <assert> ... </assert>
4454
preg_match_all('/<assert[^>]*\/>/', $contents, $potentialAssertions);
4555
$newAssertions = [];
4656
$index = 0;
@@ -58,6 +68,12 @@ public function execute(InputInterface $input)
5868
return ("Assertion Syntax updated in {$testsUpdated} file(s).\n" . implode("\n\t", $this->errors));
5969
}
6070

71+
/**
72+
* Detects present of attributes in file
73+
*
74+
* @param string $file
75+
* @return boolean
76+
*/
6177
private function detectOldAttributes($file)
6278
{
6379
foreach (self::OLD_ASSERTION_ATTRIBUTES as $OLD_ASSERTION_ATTRIBUTE) {
@@ -68,6 +84,13 @@ private function detectOldAttributes($file)
6884
return false;
6985
}
7086

87+
/**
88+
* Takes given string and attempts to convert it from single line to multi-line
89+
*
90+
* @param string $assertion
91+
* @return string
92+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
93+
*/
7194
private function convertOldAssertionToNew($assertion)
7295
{
7396
// <assertSomething => assertSomething
@@ -112,7 +135,8 @@ private function convertOldAssertionToNew($assertion)
112135
foreach ($subElements as $type => $subElement) {
113136
if (!isset($subElement['value']) || !isset($subElement['type'])) {
114137
//don't have all the info we need to rebuild
115-
$this->errors[] = "UNABLE TO FULLY REBUILD ASSERTION, PLEASE MANUALLY CHECK FORMAT ($assertType \"$stepKey\" in $this->currentFile)";
138+
$this->errors[] = "UNABLE TO FULLY REBUILD ASSERTION, PLEASE MANUALLY CHECK FORMAT " .
139+
"($assertType \"$stepKey\" in $this->currentFile)";
116140
continue;
117141
}
118142
$value = $subElement['value'];
@@ -122,5 +146,4 @@ private function convertOldAssertionToNew($assertion)
122146
$newString .= "</$assertType>";
123147
return $newString;
124148
}
125-
126149
}

0 commit comments

Comments
 (0)