Skip to content

Commit 097ebe8

Browse files
authored
MQE-991: The second data entity replacement is not correct when there are two in the same action inside an action group
- usecase fixed, added verification test around new case
1 parent 1038869 commit 097ebe8

File tree

5 files changed

+61
-2
lines changed

5 files changed

+61
-2
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
7+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
9+
use Yandex\Allure\Adapter\Annotation\Features;
10+
use Yandex\Allure\Adapter\Annotation\Stories;
11+
use Yandex\Allure\Adapter\Annotation\Title;
12+
use Yandex\Allure\Adapter\Annotation\Description;
13+
use Yandex\Allure\Adapter\Annotation\Parameter;
14+
use Yandex\Allure\Adapter\Annotation\Severity;
15+
use Yandex\Allure\Adapter\Model\SeverityLevel;
16+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
17+
18+
/**
19+
*/
20+
class PersistedAndXmlEntityArgumentsCest
21+
{
22+
/**
23+
* @Parameter(name = "AcceptanceTester", value="$I")
24+
* @param AcceptanceTester $I
25+
* @return void
26+
* @throws \Exception
27+
*/
28+
public function PersistedAndXmlEntityArguments(AcceptanceTester $I)
29+
{
30+
$I->seeInCurrentUrl("/" . $persistedInTest->getCreatedDataByName('urlKey') . ".html?___store=" . msq("uniqueData") . "John");
31+
}
32+
}

dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,11 @@
5050
<grabTextFrom selector=".class" stepKey="grabTextData"/>
5151
<fillField stepKey="fill1" selector=".{$grabTextData}" userInput="$createSimpleData.field$"/>
5252
</actionGroup>
53+
<actionGroup name="FunctionalActionGroupWithXmlAndPersistedData">
54+
<arguments>
55+
<argument name="xmlData" defaultValue="uniqueData"/>
56+
<argument name="persistedData"/>
57+
</arguments>
58+
<seeInCurrentUrl url="/{{persistedData.urlKey}}.html?___store={{xmlData.firstname}}" stepKey="checkUrl"/>
59+
</actionGroup>
5360
</actionGroups>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,9 @@
182182
<actionGroup ref="FunctionalActionGroup" stepKey="afterGroup"/>
183183
</after>
184184
</test>
185+
<test name="PersistedAndXmlEntityArguments">
186+
<actionGroup ref="FunctionalActionGroupWithXmlAndPersistedData" stepKey="afterGroup">
187+
<argument name="persistedData" value="$persistedInTest$"/>
188+
</actionGroup>
189+
</test>
185190
</tests>

dev/tests/verification/Tests/ActionGroupGenerationTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,15 @@ public function testActionGroupWithNestedArgument()
118118
{
119119
$this->generateAndCompareTest('ActionGroupUsingNestedArgument');
120120
}
121+
122+
/**
123+
* Test generation of a test referencing an action group that uses stepKey references (grabFrom/CreateData)
124+
*
125+
* @throws \Exception
126+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
127+
*/
128+
public function testActionGroupWithPersistedAndXmlEntityArguments()
129+
{
130+
$this->generateAndCompareTest('PersistedAndXmlEntityArguments');
131+
}
121132
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,12 @@ private function replacePersistedArgument($replacement, $attributeValue, $fullVa
332332
$fullReplacement = str_replace($variable, trim($replacement, '$'), trim($fullVariable, "'"));
333333
$newAttributeValue = str_replace($fullVariable, $scope . $fullReplacement . $scope, $newAttributeValue);
334334
} else {
335-
$newAttributeValue = str_replace('{{', $scope, str_replace('}}', $scope, $newAttributeValue));
336-
$newAttributeValue = str_replace($variable, trim($replacement, '$'), $newAttributeValue);
335+
$fullReplacement = str_replace($variable, trim($replacement, '$'), $fullVariable);
336+
$newAttributeValue = str_replace(
337+
'{{' . $fullVariable . '}}',
338+
$scope . $fullReplacement . $scope,
339+
$newAttributeValue
340+
);
337341
}
338342

339343
return $newAttributeValue;

0 commit comments

Comments
 (0)