@@ -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 ) {
@@ -583,7 +583,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
583583 $ testSteps .= $ this ->wrapFunctionCall ($ actor , $ actionName , $ function );
584584 break ;
585585 case "executeJS " :
586- $ testSteps .= $ this ->wrapFunctionCall ($ actor , $ actionName , $ this ->wrapWithSingleQuotes ($ function ));
586+ $ testSteps .= $ this ->wrapFunctionCall ($ actor , $ actionName , $ this ->wrapWithDoubleQuotes ($ function ));
587587 break ;
588588 case "performOn " :
589589 case "waitForElementChange " :
@@ -593,7 +593,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
593593 $ testSteps .= $ this ->wrapFunctionCall (
594594 $ actor ,
595595 $ actionName ,
596- $ this ->wrapWithSingleQuotes ($ function ),
596+ $ this ->wrapWithDoubleQuotes ($ function ),
597597 $ time
598598 );
599599 break ;
@@ -971,31 +971,32 @@ private function addUniquenessFunctionCall($input)
971971 $ parts [$ i ] = $ this ->stripWrappedQuotes ($ parts [$ i ]);
972972 }
973973 if (!empty ($ parts [0 ])) {
974- $ output = $ this ->wrapWithSingleQuotes ($ parts [0 ]);
974+ $ output = $ this ->wrapWithDoubleQuotes ($ parts [0 ]);
975975 }
976976 $ output .= $ output === '' ? $ matches [0 ] : '. ' . $ matches [0 ];
977977 if (!empty ($ parts [1 ])) {
978- $ output .= '. ' . $ this ->wrapWithSingleQuotes ($ parts [1 ]);
978+ $ output .= '. ' . $ this ->wrapWithDoubleQuotes ($ parts [1 ]);
979979 }
980980 } else {
981- $ output = $ this ->wrapWithSingleQuotes ($ input );
981+ $ output = $ this ->wrapWithDoubleQuotes ($ input );
982982 }
983983
984984 return $ output ;
985985 }
986986
987987 /**
988- * Wrap input string with single quotes.
988+ * Wrap input string with double quotes, and replaces " with \" to prevent broken PHP when generated .
989989 *
990990 * @param string $input
991991 * @return string
992992 */
993- private function wrapWithSingleQuotes ($ input )
993+ private function wrapWithDoubleQuotes ($ input )
994994 {
995995 if (empty ($ input )) {
996996 return '' ;
997997 }
998- $ input = addslashes ($ input );
998+ //Only replace " with \" so that it doesn't break outer string.
999+ $ input = str_replace ('" ' , '\" ' , $ input );
9991000 return sprintf ('"%s" ' , $ input );
10001001 }
10011002
0 commit comments