Skip to content

Commit 486a5be

Browse files
authored
Merge pull request magento#131 from magento/MQE-1011
MQE-1011: Keyword Comment In User Input For Action Group Substitutes Incorrectly
2 parents 621e9c5 + 8d8d856 commit 486a5be

File tree

5 files changed

+82
-2
lines changed

5 files changed

+82
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 ActionGroupContainsStepKeyInArgTextCest
21+
{
22+
/**
23+
* @param AcceptanceTester $I
24+
* @throws \Exception
25+
*/
26+
public function _before(AcceptanceTester $I)
27+
{
28+
$I->see("arg1", ".selector");
29+
}
30+
31+
/**
32+
* @Features({"TestModule"})
33+
* @Parameter(name = "AcceptanceTester", value="$I")
34+
* @param AcceptanceTester $I
35+
* @return void
36+
* @throws \Exception
37+
*/
38+
public function ActionGroupContainsStepKeyInArgText(AcceptanceTester $I)
39+
{
40+
$I->see("arg1", ".selector");
41+
}
42+
}

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

+7
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,11 @@
9898
<requiredEntity createDataKey="createCategory"/>
9999
</createData>
100100
</actionGroup>
101+
102+
<actionGroup name="actionGroupContainsStepKeyInArgValue">
103+
<arguments>
104+
<argument name="sameStepKeyAsArg" type="string" defaultValue="stringLiteral"/>
105+
</arguments>
106+
<see selector=".selector" userInput="{{sameStepKeyAsArg}}" stepKey="arg1" />
107+
</actionGroup>
101108
</actionGroups>

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

+11
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,15 @@
143143
<actionGroup ref="actionGroupWithCreateData" stepKey="Key1"/>
144144
</before>
145145
</test>
146+
147+
<test name="ActionGroupContainsStepKeyInArgText">
148+
<before>
149+
<actionGroup ref="actionGroupContainsStepKeyInArgValue" stepKey="actionGroup">
150+
<argument name="sameStepKeyAsArg" value="arg1"/>
151+
</actionGroup>
152+
</before>
153+
<actionGroup ref="actionGroupContainsStepKeyInArgValue" stepKey="actionGroup">
154+
<argument name="sameStepKeyAsArg" value="arg1"/>
155+
</actionGroup>
156+
</test>
146157
</tests>

dev/tests/verification/Tests/ActionGroupGenerationTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,15 @@ public function testActionGroupWithCreateData()
173173
{
174174
$this->generateAndCompareTest('ActionGroupUsingCreateData');
175175
}
176+
177+
/**
178+
* Test an action group with an arg containing stepKey text
179+
*
180+
* @throws \Exception
181+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
182+
*/
183+
public function testActionGroupWithArgContainingStepKey()
184+
{
185+
$this->generateAndCompareTest('ActionGroupContainsStepKeyInArgText');
186+
}
176187
}

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -1385,9 +1385,18 @@ private function resolveStepKeyReferences($input, $actionGroupOrigin)
13851385
$testInvocationKey = ucfirst($actionGroupOrigin[ActionGroupObject::ACTION_GROUP_ORIGIN_TEST_REF]);
13861386

13871387
foreach ($stepKeys as $stepKey) {
1388-
if (strpos($output, $stepKey)) {
1389-
$output = str_replace($stepKey, $stepKey . $testInvocationKey, $output);
1388+
// MQE-1011
1389+
$stepKeyVarRef = "$" . $stepKey;
1390+
$classVarRef = "\$this->$stepKey";
1391+
1392+
if (strpos($output, $stepKeyVarRef) !== false) {
1393+
$output = str_replace($stepKeyVarRef, $stepKeyVarRef . $testInvocationKey, $output);
1394+
}
1395+
1396+
if (strpos($output, $classVarRef) !== false) {
1397+
$output = str_replace($classVarRef, $classVarRef . $testInvocationKey, $output);
13901398
}
1399+
13911400
}
13921401
return $output;
13931402
}

0 commit comments

Comments
 (0)