Skip to content

Commit 0885226

Browse files
committed
MQE-496: Allow passing multiple ActionGroup arguments into parameterized selector.
- persisted Data fixes to Anthoula's patch.
1 parent f2138fb commit 0885226

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ private function replaceAttributeArgumentInVariable(
172172
$variableName = strstr($variable, '.', true);
173173
// Check if arguments has a mapping for the given variableName
174174

175+
175176
if ($variableName === false) {
176177
$variableName = $variable;
177178
}
@@ -218,11 +219,12 @@ private function replacePersistedArgument($replacement, $attributeValue, $fullVa
218219

219220
// parameter replacements require changing of (arg.field) to ($arg.field$)
220221
if ($isParameter) {
221-
$newAttributeValue = str_replace($fullVariable, $scope . $fullVariable . $scope, $newAttributeValue);
222+
$fullReplacement = str_replace($variable, trim($replacement, '$'), $fullVariable);
223+
$newAttributeValue = str_replace($fullVariable, $scope . $fullReplacement . $scope, $newAttributeValue);
222224
} else {
223225
$newAttributeValue = str_replace('{{', $scope, str_replace('}}', $scope, $newAttributeValue));
226+
$newAttributeValue = str_replace($variable, trim($replacement, '$'), $newAttributeValue);
224227
}
225-
$newAttributeValue = str_replace($variable, trim($replacement, '$'), $newAttributeValue);
226228

227229
return $newAttributeValue;
228230
}

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ private function resolveTestVariable($inputString, $args)
913913
*/
914914
private function replaceMatchesIntoArg($matches, &$outputArg, $delimiter)
915915
{
916+
$matches = array_unique($matches);
916917
foreach ($matches as $match) {
917918
$replacement = null;
918919
$variable = $this->stripAndSplitReference($match, $delimiter);
@@ -953,22 +954,24 @@ private function processQuoteBreaks($match, $argument, $replacement)
953954
$quoteBefore = true;
954955
$quoteAfter = true;
955956

956-
// Prepare replacement with quote breaks if needed
957-
if ($argument[$beforeIndex] != "\"") {
958-
$replacement = '" . ' . $replacement;
957+
// Determine if there is a Single quote before/after the $match, and if there is only 1 quote before/after.
958+
if ($argument[$beforeIndex] != '"' || substr_count($argument, '"', 0, $beforeIndex+1)>1) {
959959
$quoteBefore = false;
960960
}
961-
if ($argument[$afterIndex] != "\"") {
962-
$replacement = $replacement . ' . "';
961+
if ($argument[$afterIndex] != '"' || substr_count($argument, '"', $afterIndex)>1) {
963962
$quoteAfter = false;
964963
}
965-
//Remove quotes at either end of argument if they aren't necessary.
964+
//Remove quotes at either end of argument if they aren't necessary. Add quote breaking if needed
966965
if ($quoteBefore) {
967966
$outputArg = substr($outputArg, 0, $beforeIndex) . substr($outputArg, $beforeIndex+1);
968967
$afterIndex--;
968+
} else {
969+
$replacement = '" . ' . $replacement;
969970
}
970971
if ($quoteAfter) {
971972
$outputArg = substr($outputArg, 0, $afterIndex) . substr($outputArg, $afterIndex+1);
973+
} else {
974+
$replacement = $replacement . ' . "';
972975
}
973976
$outputArg = str_replace($match, $replacement, $outputArg);
974977
return $outputArg;

0 commit comments

Comments
 (0)