Skip to content

Commit 05190b1

Browse files
KevinBKozanjilu1
authored andcommitted
MQE-359
Removed addslashes, added replace of " to \" since " is read in a " via the xml parser. Rename wrapWithSingleQuotes to wrapWithDoubleQuotes, and fixed PHP Doc for the function. (cherry picked from commit 1f81574)
1 parent 3ef29c8 commit 05190b1

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,15 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
336336
if (isset($customActionAttributes['selectorArray'])) {
337337
$selector = $customActionAttributes['selectorArray'];
338338
} elseif (isset($customActionAttributes['selector'])) {
339-
$selector = $this->wrapWithSingleQuotes($customActionAttributes['selector']);
339+
$selector = $this->wrapWithDoubleQuotes($customActionAttributes['selector']);
340340
}
341341

342342
if (isset($customActionAttributes['selector1'])) {
343-
$selector1 = $this->wrapWithSingleQuotes($customActionAttributes['selector1']);
343+
$selector1 = $this->wrapWithDoubleQuotes($customActionAttributes['selector1']);
344344
}
345345

346346
if (isset($customActionAttributes['selector2'])) {
347-
$selector2 = $this->wrapWithSingleQuotes($customActionAttributes['selector2']);
347+
$selector2 = $this->wrapWithDoubleQuotes($customActionAttributes['selector2']);
348348
}
349349

350350
if (isset($customActionAttributes['x'])) {
@@ -364,15 +364,15 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
364364
}
365365

366366
if (isset($customActionAttributes['locale'])) {
367-
$locale = $this->wrapWithSingleQuotes($customActionAttributes['locale']);
367+
$locale = $this->wrapWithDoubleQuotes($customActionAttributes['locale']);
368368
}
369369

370370
if (isset($customActionAttributes['username'])) {
371-
$username = $this->wrapWithSingleQuotes($customActionAttributes['username']);
371+
$username = $this->wrapWithDoubleQuotes($customActionAttributes['username']);
372372
}
373373

374374
if (isset($customActionAttributes['password'])) {
375-
$password = $this->wrapWithSingleQuotes($customActionAttributes['password']);
375+
$password = $this->wrapWithDoubleQuotes($customActionAttributes['password']);
376376
}
377377

378378
if (isset($customActionAttributes['width'])) {
@@ -384,15 +384,15 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
384384
}
385385

386386
if (isset($customActionAttributes['value'])) {
387-
$value = $this->wrapWithSingleQuotes($customActionAttributes['value']);
387+
$value = $this->wrapWithDoubleQuotes($customActionAttributes['value']);
388388
}
389389

390390
if (isset($customActionAttributes['button'])) {
391-
$button = $this->wrapWithSingleQuotes($customActionAttributes['button']);
391+
$button = $this->wrapWithDoubleQuotes($customActionAttributes['button']);
392392
}
393393

394394
if (isset($customActionAttributes['parameter'])) {
395-
$parameter = $this->wrapWithSingleQuotes($customActionAttributes['parameter']);
395+
$parameter = $this->wrapWithDoubleQuotes($customActionAttributes['parameter']);
396396
}
397397

398398
switch ($actionName) {
@@ -584,7 +584,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
584584
$testSteps .= $this->wrapFunctionCall($actor, $actionName, $function);
585585
break;
586586
case "executeJS":
587-
$testSteps .= $this->wrapFunctionCall($actor, $actionName, $this->wrapWithSingleQuotes($function));
587+
$testSteps .= $this->wrapFunctionCall($actor, $actionName, $this->wrapWithDoubleQuotes($function));
588588
break;
589589
case "performOn":
590590
case "waitForElementChange":
@@ -594,7 +594,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
594594
$testSteps .= $this->wrapFunctionCall(
595595
$actor,
596596
$actionName,
597-
$this->wrapWithSingleQuotes($function),
597+
$this->wrapWithDoubleQuotes($function),
598598
$time
599599
);
600600
break;
@@ -972,26 +972,26 @@ private function addUniquenessFunctionCall($input)
972972
$parts[$i] = $this->stripWrappedQuotes($parts[$i]);
973973
}
974974
if (!empty($parts[0])) {
975-
$output = $this->wrapWithSingleQuotes($parts[0]);
975+
$output = $this->wrapWithDoubleQuotes($parts[0]);
976976
}
977977
$output .= $output === '' ? $matches[0] : '.' . $matches[0];
978978
if (!empty($parts[1])) {
979-
$output .= '.' . $this->wrapWithSingleQuotes($parts[1]);
979+
$output .= '.' . $this->wrapWithDoubleQuotes($parts[1]);
980980
}
981981
} else {
982-
$output = $this->wrapWithSingleQuotes($input);
982+
$output = $this->wrapWithDoubleQuotes($input);
983983
}
984984

985985
return $output;
986986
}
987987

988988
/**
989-
* Wrap input string with single quotes.
989+
* Wrap input string with double quotes, and replaces " with \" to prevent broken PHP when generated.
990990
*
991991
* @param string $input
992992
* @return string
993993
*/
994-
private function wrapWithSingleQuotes($input)
994+
private function wrapWithDoubleQuotes($input)
995995
{
996996
if (empty($input)) {
997997
return '';

0 commit comments

Comments
 (0)