Skip to content

Commit a7597c9

Browse files
committed
executeInSelenium generation fix #2
1 parent 9359af2 commit a7597c9

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

dev/tests/verification/Resources/ExecuteInSeleniumTest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ class ExecuteInSeleniumTestCest
2727
*/
2828
public function ExecuteInSeleniumTest(AcceptanceTester $I)
2929
{
30-
$I->executeInSelenium(function ($webdriver) { return 'Hello, World!'});
30+
$I->executeInSelenium(function ($webdriver) { return "Hello, World!"});
3131
}
3232
}

dev/tests/verification/TestModule/Test/ExecuteInSeleniumTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
1111
<test name="ExecuteInSeleniumTest">
12-
<executeInSelenium function="function ($webdriver) { return 'Hello, World!'}" stepKey="executeInSeleniumStep"/>
12+
<executeInSelenium function="function ($webdriver) { return &quot;Hello, World!&quot;}" stepKey="executeInSeleniumStep"/>
1313
</test>
1414
</tests>

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,10 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
639639
}
640640

641641
if (isset($customActionAttributes['function'])) {
642-
$function = $this->addUniquenessFunctionCall($customActionAttributes['function']);
642+
$function = $this->addUniquenessFunctionCall(
643+
$customActionAttributes['function'],
644+
$actionObject->getType() !== "executeInSelenium"
645+
);
643646
if (in_array($actionObject->getType(), ActionObject::FUNCTION_CLOSURE_ACTIONS)) {
644647
// Argument must be a closure function, not a string.
645648
$function = trim($function, '"');
@@ -1698,11 +1701,16 @@ private function processPressKey($input)
16981701
* Add uniqueness function call to input string based on regex pattern.
16991702
*
17001703
* @param string $input
1704+
* @param bool $wrapWithDoubleQuotes
17011705
* @return string
17021706
*/
1703-
private function addUniquenessFunctionCall($input)
1707+
private function addUniquenessFunctionCall($input, $wrapWithDoubleQuotes = true)
17041708
{
1705-
$output = $this->wrapWithDoubleQuotes($input);
1709+
if ($wrapWithDoubleQuotes) {
1710+
$output = $this->wrapWithDoubleQuotes($input);
1711+
} else {
1712+
$output = $input;
1713+
}
17061714

17071715
//Match on msq(\"entityName\")
17081716
preg_match_all('/' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\(\\\\"[\w]+\\\\"\)/', $output, $matches);

0 commit comments

Comments
 (0)