Skip to content

Commit 8ac2937

Browse files
authored
Merge pull request #348 from zakdma/executeInSelenium2
executeInSelenium generation fix #2
2 parents 5a4909c + 43ffdbb commit 8ac2937

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

dev/tests/verification/Resources/ExecuteInSeleniumTest.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ class ExecuteInSeleniumTestCest
2828
*/
2929
public function ExecuteInSeleniumTest(AcceptanceTester $I)
3030
{
31-
$I->executeInSelenium(function ($webdriver) { return 'Hello, World!'}); // stepKey: executeInSeleniumStep
31+
$I->executeInSelenium(function ($webdriver) { return "Hello, World!"}); // stepKey: executeInSeleniumStep
3232
}
3333
}

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

+1-1
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

+12-4
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,10 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
654654
}
655655

656656
if (isset($customActionAttributes['function'])) {
657-
$function = $this->addUniquenessFunctionCall($customActionAttributes['function']);
657+
$function = $this->addUniquenessFunctionCall(
658+
$customActionAttributes['function'],
659+
$actionObject->getType() !== "executeInSelenium"
660+
);
658661
if (in_array($actionObject->getType(), ActionObject::FUNCTION_CLOSURE_ACTIONS)) {
659662
// Argument must be a closure function, not a string.
660663
$function = trim($function, '"');
@@ -1736,12 +1739,17 @@ private function processPressKey($input)
17361739
/**
17371740
* Add uniqueness function call to input string based on regex pattern.
17381741
*
1739-
* @param string $input
1742+
* @param string $input
1743+
* @param boolean $wrapWithDoubleQuotes
17401744
* @return string
17411745
*/
1742-
private function addUniquenessFunctionCall($input)
1746+
private function addUniquenessFunctionCall($input, $wrapWithDoubleQuotes = true)
17431747
{
1744-
$output = $this->wrapWithDoubleQuotes($input);
1748+
if ($wrapWithDoubleQuotes) {
1749+
$output = $this->wrapWithDoubleQuotes($input);
1750+
} else {
1751+
$output = $input;
1752+
}
17451753

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

0 commit comments

Comments
 (0)