@@ -336,15 +336,15 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
336
336
if (isset ($ customActionAttributes ['selectorArray ' ])) {
337
337
$ selector = $ customActionAttributes ['selectorArray ' ];
338
338
} elseif (isset ($ customActionAttributes ['selector ' ])) {
339
- $ selector = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['selector ' ]);
339
+ $ selector = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['selector ' ]);
340
340
}
341
341
342
342
if (isset ($ customActionAttributes ['selector1 ' ])) {
343
- $ selector1 = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['selector1 ' ]);
343
+ $ selector1 = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['selector1 ' ]);
344
344
}
345
345
346
346
if (isset ($ customActionAttributes ['selector2 ' ])) {
347
- $ selector2 = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['selector2 ' ]);
347
+ $ selector2 = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['selector2 ' ]);
348
348
}
349
349
350
350
if (isset ($ customActionAttributes ['x ' ])) {
@@ -364,15 +364,15 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
364
364
}
365
365
366
366
if (isset ($ customActionAttributes ['locale ' ])) {
367
- $ locale = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['locale ' ]);
367
+ $ locale = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['locale ' ]);
368
368
}
369
369
370
370
if (isset ($ customActionAttributes ['username ' ])) {
371
- $ username = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['username ' ]);
371
+ $ username = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['username ' ]);
372
372
}
373
373
374
374
if (isset ($ customActionAttributes ['password ' ])) {
375
- $ password = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['password ' ]);
375
+ $ password = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['password ' ]);
376
376
}
377
377
378
378
if (isset ($ customActionAttributes ['width ' ])) {
@@ -384,15 +384,15 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
384
384
}
385
385
386
386
if (isset ($ customActionAttributes ['value ' ])) {
387
- $ value = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['value ' ]);
387
+ $ value = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['value ' ]);
388
388
}
389
389
390
390
if (isset ($ customActionAttributes ['button ' ])) {
391
- $ button = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['button ' ]);
391
+ $ button = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['button ' ]);
392
392
}
393
393
394
394
if (isset ($ customActionAttributes ['parameter ' ])) {
395
- $ parameter = $ this ->wrapWithSingleQuotes ($ customActionAttributes ['parameter ' ]);
395
+ $ parameter = $ this ->wrapWithDoubleQuotes ($ customActionAttributes ['parameter ' ]);
396
396
}
397
397
398
398
switch ($ actionName ) {
@@ -583,7 +583,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
583
583
$ testSteps .= $ this ->wrapFunctionCall ($ actor , $ actionName , $ function );
584
584
break ;
585
585
case "executeJS " :
586
- $ testSteps .= $ this ->wrapFunctionCall ($ actor , $ actionName , $ this ->wrapWithSingleQuotes ($ function ));
586
+ $ testSteps .= $ this ->wrapFunctionCall ($ actor , $ actionName , $ this ->wrapWithDoubleQuotes ($ function ));
587
587
break ;
588
588
case "performOn " :
589
589
case "waitForElementChange " :
@@ -593,7 +593,7 @@ private function generateStepsPhp($stepsObject, $stepsData, $hookObject = false)
593
593
$ testSteps .= $ this ->wrapFunctionCall (
594
594
$ actor ,
595
595
$ actionName ,
596
- $ this ->wrapWithSingleQuotes ($ function ),
596
+ $ this ->wrapWithDoubleQuotes ($ function ),
597
597
$ time
598
598
);
599
599
break ;
@@ -971,31 +971,32 @@ private function addUniquenessFunctionCall($input)
971
971
$ parts [$ i ] = $ this ->stripWrappedQuotes ($ parts [$ i ]);
972
972
}
973
973
if (!empty ($ parts [0 ])) {
974
- $ output = $ this ->wrapWithSingleQuotes ($ parts [0 ]);
974
+ $ output = $ this ->wrapWithDoubleQuotes ($ parts [0 ]);
975
975
}
976
976
$ output .= $ output === '' ? $ matches [0 ] : '. ' . $ matches [0 ];
977
977
if (!empty ($ parts [1 ])) {
978
- $ output .= '. ' . $ this ->wrapWithSingleQuotes ($ parts [1 ]);
978
+ $ output .= '. ' . $ this ->wrapWithDoubleQuotes ($ parts [1 ]);
979
979
}
980
980
} else {
981
- $ output = $ this ->wrapWithSingleQuotes ($ input );
981
+ $ output = $ this ->wrapWithDoubleQuotes ($ input );
982
982
}
983
983
984
984
return $ output ;
985
985
}
986
986
987
987
/**
988
- * Wrap input string with single quotes.
988
+ * Wrap input string with double quotes, and replaces " with \" to prevent broken PHP when generated .
989
989
*
990
990
* @param string $input
991
991
* @return string
992
992
*/
993
- private function wrapWithSingleQuotes ($ input )
993
+ private function wrapWithDoubleQuotes ($ input )
994
994
{
995
995
if (empty ($ input )) {
996
996
return '' ;
997
997
}
998
- $ input = addslashes ($ input );
998
+ //Only replace " with \" so that it doesn't break outer string.
999
+ $ input = str_replace ('" ' , '\" ' , $ input );
999
1000
return sprintf ('"%s" ' , $ input );
1000
1001
}
1001
1002
0 commit comments