Skip to content

Commit a75d1f4

Browse files
committed
Merge branch 'bug-fixes' of github.com:magento/magento2-functional-testing-framework into develop
2 parents cfb142b + c71b417 commit a75d1f4

File tree

6 files changed

+29
-22
lines changed

6 files changed

+29
-22
lines changed

dev/tests/verification/Resources/BasicFunctionalTest.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class BasicFunctionalTestCest
6060
*/
6161
public function BasicFunctionalTest(AcceptanceTester $I)
6262
{
63+
$I->comment("");
64+
$I->comment("");
6365
$someVarDefinition = $I->grabValueFrom();
6466
$I->acceptPopup();
6567
$I->amOnPage("/test/url");
@@ -70,6 +72,8 @@ class BasicFunctionalTestCest
7072
$I->click(".functionalTestSelector");
7173
$I->clickWithLeftButton(".functionalTestSelector");
7274
$I->clickWithRightButton(".functionalTestSelector");
75+
$I->clickWithLeftButton("#element#element .200", 200, 300);
76+
$I->clickWithRightButton("#element .4123#element", 200, 300);
7377
$I->closeTab();
7478
$I->conditionalClick(".functionalTestSelector", ".functionalDependentTestSelector", true);
7579
$I->dontSee("someInput", ".functionalTestSelector");

dev/tests/verification/TestModule/Data/ReplacementData.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@
2626
<data key="sampleField2">moreData</data>
2727
<requiredEntity type="test2">originalValue2</requiredEntity>
2828
</entity>
29+
<entity name="offset" type="simpleData">
30+
<data key="x">200</data>
31+
<data key="y">300</data>
32+
</entity>
33+
<entity name="emptyData" type="backend">
34+
<data key="noData"></data>
35+
<data key="definitelyNoData"/>
36+
</entity>
2937
</entities>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<after>
2323
<amOnPage url="/afterUrl" stepKey="afterAmOnPageKey"/>
2424
</after>
25+
<comment stepKey="basicCommentWithNoData" userInput="{{emptyData.noData}}"/>
26+
<comment stepKey="basicCommentWithDefinitelyNoData" userInput="{{emptyData.definitelyNoData}}"/>
2527
<grabValueFrom stepKey="someVarDefinition"/>
2628
<acceptPopup stepKey="acceptPopupKey1"/>
2729
<amOnPage stepKey="amOnPageKey1" url="/test/url"/>
@@ -32,6 +34,8 @@
3234
<click selector=".functionalTestSelector" stepKey="clickKey1"/>
3335
<clickWithLeftButton selector=".functionalTestSelector" stepKey="clickWithLeftButtonKey1"/>
3436
<clickWithRightButton selector=".functionalTestSelector" stepKey="clickWithRightButtonKey1"/>
37+
<clickWithLeftButton selector="{{SampleSection.simpleElement}}{{SampleSection.simpleElementOneParam(offset.x)}}" x="{{offset.x}}" y="{{offset.y}}" stepKey="clickWithLeftButtonKeyXY1" />
38+
<clickWithRightButton selector="{{SampleSection.simpleElementOneParam('4123')}}{{SampleSection.simpleElement}}" x="{{offset.x}}" y="{{offset.y}}" stepKey="clickWithRightButtonKeyXY1" />
3539
<closeTab stepKey="closeTabKey1"/>
3640
<conditionalClick selector=".functionalTestSelector" dependentSelector=".functionalDependentTestSelector" visible="true" stepKey="conditionalClickKey1"/>
3741
<dontSee userInput="someInput" selector=".functionalTestSelector" stepKey="dontSeeKey1" />

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private function resolveUrlReference($urlIn, $entityObjects)
206206
EntityDataObject::CEST_UNIQUE_VALUE
207207
);
208208
if (null !== $param) {
209-
$urlOut = str_replace($paramValue, $param, $urlIn);
209+
$urlOut = str_replace($paramValue, $param, $urlOut);
210210
continue;
211211
}
212212
}

src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class ActionObject
2121
{
2222
const __ENV = "_ENV";
23-
const DATA_ENABLED_ATTRIBUTES = ["userInput", "parameterArray", "expected", "actual"];
23+
const DATA_ENABLED_ATTRIBUTES = ["userInput", "parameterArray", "expected", "actual", "x", "y"];
2424
const SELECTOR_ENABLED_ATTRIBUTES = [
2525
'selector',
2626
'dependentSelector',
@@ -40,8 +40,7 @@ class ActionObject
4040
const ACTION_ATTRIBUTE_URL = 'url';
4141
const ACTION_ATTRIBUTE_SELECTOR = 'selector';
4242
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PARAMETER = '/\(.+\)/';
43-
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/{{[\w]+\.[\w\[\]]+}}/';
44-
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN_WITH_PARAMS= '/{{[\w]+\.[\w]+\(.+\)}}/';
43+
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/({{[\w]+\.[\w\[\]]+}})|({{[\w]+\.[\w]+\(.+\)}})/';
4544

4645
/**
4746
* The unique identifier for the action
@@ -371,7 +370,7 @@ private function resolveDataInputReferences()
371370
foreach ($relevantDataAttributes as $dataAttribute) {
372371
$varInput = $this->actionAttributes[$dataAttribute];
373372
$replacement = $this->findAndReplaceReferences(DataObjectHandler::getInstance(), $varInput);
374-
if ($replacement != null) {
373+
if ($replacement !== null) {
375374
$this->resolvedCustomAttributes[$dataAttribute] = $replacement;
376375
}
377376
}
@@ -444,7 +443,7 @@ private function stripAndReturnParameters($reference)
444443
private function findAndReplaceReferences($objectHandler, $inputString)
445444
{
446445
//look for parameter area, if so use different regex
447-
$regex = $this->resolveRegexPatternForReference($inputString);
446+
$regex = ActionObject::ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN;
448447

449448
preg_match_all($regex, $inputString, $matches);
450449

@@ -482,7 +481,7 @@ private function findAndReplaceReferences($objectHandler, $inputString)
482481
$replacement = $this->resolveEntityDataObjectReference($obj, $match);
483482
}
484483

485-
if ($replacement == null) {
484+
if ($replacement === null) {
486485
if (get_class($objectHandler) != DataObjectHandler::class) {
487486
return $this->findAndReplaceReferences(DataObjectHandler::getInstance(), $outputString);
488487
} else {
@@ -514,20 +513,6 @@ private function validateUrlAreaAgainstActionType($obj)
514513
}
515514
}
516515

517-
/**
518-
* Determines whether the given $inputString has (params), and returns the appropriate regex for use in matching.
519-
* @param string $inputString
520-
* @return string
521-
*/
522-
private function resolveRegexPatternForReference($inputString)
523-
{
524-
if (preg_match(ActionObject::ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN_WITH_PARAMS, $inputString) === 1) {
525-
return ActionObject::ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN_WITH_PARAMS;
526-
} else {
527-
return ActionObject::ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN;
528-
}
529-
}
530-
531516
/**
532517
* Gets the object's dataByName with given $match, differentiating behavior between <array> and <data> nodes.
533518
* @param string $obj

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
839839
break;
840840
case "switchToNextTab":
841841
case "switchToPreviousTab":
842-
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $this->stripWrappedQuotes($input));
842+
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input);
843843
break;
844844
case "clickWithLeftButton":
845845
case "clickWithRightButton":
@@ -1595,6 +1595,9 @@ private function wrapFunctionCall($actor, $action, ...$args)
15951595
if (!$isFirst) {
15961596
$output .= ', ';
15971597
}
1598+
if ($args[$i] === "") {
1599+
$args[$i] = '"' . $args[$i] . '"';
1600+
}
15981601
$output .= $args[$i];
15991602
$isFirst = false;
16001603
}
@@ -1626,6 +1629,9 @@ private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $actio
16261629
if (!$isFirst) {
16271630
$output .= ', ';
16281631
}
1632+
if ($args[$i] === "") {
1633+
$args[$i] = '"' . $args[$i] . '"';
1634+
}
16291635
$output .= $args[$i];
16301636
$isFirst = false;
16311637
}

0 commit comments

Comments
 (0)