Skip to content

Commit fd8c278

Browse files
committed
Fixed quotes issue.
1 parent 1c7be1b commit fd8c278

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

src/Magento/AcceptanceTestFramework/Util/TestGenerator.php

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -293,30 +293,6 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
293293
$button = null;
294294
$parameter = null;
295295

296-
//Resolve $input$ and $$input$$ replacement in url, selector, and userInput.
297-
if (isset($customActionAttributes['url'])) {
298-
$customActionAttributes['url'] = $this->resolveTestVariable(
299-
$customActionAttributes['url'],
300-
true
301-
);
302-
}
303-
304-
if (isset($customActionAttributes['userInput'])) {
305-
$customActionAttributes['userInput'] = $this->resolveTestVariable(
306-
$customActionAttributes['userInput'],
307-
true
308-
);
309-
}
310-
311-
if (isset($customActionAttributes['selector'])) {
312-
$customActionAttributes['selector'] = $this->resolveTestVariable(
313-
$customActionAttributes['selector'],
314-
true
315-
);
316-
}
317-
318-
//Resume step building
319-
320296
if (isset($customActionAttributes['returnVariable'])) {
321297
$returnVariable = $customActionAttributes['returnVariable'];
322298
}
@@ -754,7 +730,7 @@ private function resolveTestVariable($inputString, $quoteBreak = false)
754730
}
755731
$replacement = sprintf("\$this->%s->getCreatedDataByName('%s')", $variable[0], $variable[1]);
756732
if ($quoteBreak) {
757-
$replacement = "' . " . $replacement . " . '";
733+
$replacement = '" . ' . $replacement . ' . "';
758734
}
759735
$outputString = str_replace($match, $replacement, $outputString);
760736
$replaced = true;
@@ -773,7 +749,7 @@ private function resolveTestVariable($inputString, $quoteBreak = false)
773749
}
774750
$replacement = sprintf("$%s->getCreatedDataByName('%s')", $variable[0], $variable[1]);
775751
if ($quoteBreak) {
776-
$replacement = "' . " . $replacement . " . '";
752+
$replacement = '" . ' . $replacement . ' . "';
777753
}
778754
$outputString = str_replace($match, $replacement, $outputString);
779755
$replaced = true;
@@ -1002,7 +978,8 @@ private function addUniquenessFunctionCall($input)
1002978
*/
1003979
private function wrapWithSingleQuotes($input)
1004980
{
1005-
return sprintf("'%s'", $input);
981+
$input = addslashes($input);
982+
return sprintf('"%s"', $input);
1006983
}
1007984

1008985
/**
@@ -1057,7 +1034,10 @@ private function wrapFunctionCall($actor, $action, ...$args)
10571034
$isFirst = false;
10581035
}
10591036
$output .= ");\n";
1060-
return $output;
1037+
1038+
// TODO put in condiional to prevent unncessary quote break (i.e. there are no strings to be appended to
1039+
// variable call.
1040+
return $this->resolveTestVariable($output, true);
10611041
}
10621042

10631043
/**
@@ -1084,7 +1064,10 @@ private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $actio
10841064
$isFirst = false;
10851065
}
10861066
$output .= ");\n";
1087-
return $output;
1067+
1068+
// TODO put in condiional to prevent unncessary quote break (i.e. there are no strings to be appended to
1069+
// variable call.
1070+
return $output = $this->resolveTestVariable($output, true);
10881071
}
10891072
// @codingStandardsIgnoreEnd
10901073
}

0 commit comments

Comments
 (0)