Skip to content

MQE-1011: Keyword Comment In User Input For Action Group Substitutes Incorrectly #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
namespace Magento\AcceptanceTest\_default\Backend;

use Magento\FunctionalTestingFramework\AcceptanceTester;
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
use \Codeception\Util\Locator;
use Yandex\Allure\Adapter\Annotation\Features;
use Yandex\Allure\Adapter\Annotation\Stories;
use Yandex\Allure\Adapter\Annotation\Title;
use Yandex\Allure\Adapter\Annotation\Description;
use Yandex\Allure\Adapter\Annotation\Parameter;
use Yandex\Allure\Adapter\Annotation\Severity;
use Yandex\Allure\Adapter\Model\SeverityLevel;
use Yandex\Allure\Adapter\Annotation\TestCaseId;

/**
*/
class ActionGroupContainsStepKeyInArgTextCest
{
/**
* @param AcceptanceTester $I
* @throws \Exception
*/
public function _before(AcceptanceTester $I)
{
$I->see("arg1", ".selector");
}

/**
* @Features({"TestModule"})
* @Parameter(name = "AcceptanceTester", value="$I")
* @param AcceptanceTester $I
* @return void
* @throws \Exception
*/
public function ActionGroupContainsStepKeyInArgText(AcceptanceTester $I)
{
$I->see("arg1", ".selector");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,11 @@
<requiredEntity createDataKey="createCategory"/>
</createData>
</actionGroup>

<actionGroup name="actionGroupContainsStepKeyInArgValue">
<arguments>
<argument name="sameStepKeyAsArg" type="string" defaultValue="stringLiteral"/>
</arguments>
<see selector=".selector" userInput="{{sameStepKeyAsArg}}" stepKey="arg1" />
</actionGroup>
</actionGroups>
11 changes: 11 additions & 0 deletions dev/tests/verification/TestModule/Test/ActionGroupTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,15 @@
<actionGroup ref="actionGroupWithCreateData" stepKey="Key1"/>
</before>
</test>

<test name="ActionGroupContainsStepKeyInArgText">
<before>
<actionGroup ref="actionGroupContainsStepKeyInArgValue" stepKey="actionGroup">
<argument name="sameStepKeyAsArg" value="arg1"/>
</actionGroup>
</before>
<actionGroup ref="actionGroupContainsStepKeyInArgValue" stepKey="actionGroup">
<argument name="sameStepKeyAsArg" value="arg1"/>
</actionGroup>
</test>
</tests>
11 changes: 11 additions & 0 deletions dev/tests/verification/Tests/ActionGroupGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,15 @@ public function testActionGroupWithCreateData()
{
$this->generateAndCompareTest('ActionGroupUsingCreateData');
}

/**
* Test an action group with an arg containing stepKey text
*
* @throws \Exception
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
*/
public function testActionGroupWithArgContainingStepKey()
{
$this->generateAndCompareTest('ActionGroupContainsStepKeyInArgText');
}
}
13 changes: 11 additions & 2 deletions src/Magento/FunctionalTestingFramework/Util/TestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1385,9 +1385,18 @@ private function resolveStepKeyReferences($input, $actionGroupOrigin)
$testInvocationKey = ucfirst($actionGroupOrigin[ActionGroupObject::ACTION_GROUP_ORIGIN_TEST_REF]);

foreach ($stepKeys as $stepKey) {
if (strpos($output, $stepKey)) {
$output = str_replace($stepKey, $stepKey . $testInvocationKey, $output);
// MQE-1011
$stepKeyVarRef = "$" . $stepKey;
$classVarRef = "\$this->$stepKey";

if (strpos($output, $stepKeyVarRef) !== false) {
$output = str_replace($stepKeyVarRef, $stepKeyVarRef . $testInvocationKey, $output);
}

if (strpos($output, $classVarRef) !== false) {
$output = str_replace($classVarRef, $classVarRef . $testInvocationKey, $output);
}

}
return $output;
}
Expand Down