Skip to content

MQE-914: Multiple Uniqueness References On Same Entity Generates Incorrectly #96

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 3 commits into from
Apr 16, 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
Expand Up @@ -29,6 +29,6 @@ class ActionGroupWithPassedArgumentAndStringSelectorParamCest
*/
public function ActionGroupWithPassedArgumentAndStringSelectorParam(AcceptanceTester $I)
{
$I->see("John".msq("UniquePerson"), "#element .test1");
$I->see("John" . msq("UniquePerson"), "#element .test1");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ class ActionGroupWithSingleParameterSelectorFromPassedArgumentCest
*/
public function ActionGroupWithSingleParameterSelectorFromPassedArgument(AcceptanceTester $I)
{
$I->see("Doe", "#element .John".msq("UniquePerson"));
$I->see("Doe", "#element .John" . msq("UniquePerson"));
}
}
30 changes: 16 additions & 14 deletions dev/tests/verification/Resources/DataReplacementTest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,22 @@ class DataReplacementTestCest
$I->conditionalClick("Doe", "#John", true);
$I->amOnUrl("John.html");
$I->searchAndMultiSelectOption("#selector", ["John", "Doe"]);
$I->fillField("#selector", "StringBefore ".msq("uniqueData")."John StringAfter");
$I->fillField("#".msq("uniqueData")."John", "input");
$I->dragAndDrop("#".msq("uniqueData")."John", msq("uniqueData")."John");
$I->conditionalClick(msq("uniqueData")."John", "#".msq("uniqueData")."John", true);
$I->amOnUrl(msq("uniqueData")."John.html");
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData")."John", "Doe"]);
$I->fillField("#selector", "StringBefore Doe".msq("uniqueData")." StringAfter");
$I->fillField("#Doe".msq("uniqueData"), "input");
$I->dragAndDrop("#Doe".msq("uniqueData"), "Doe".msq("uniqueData"));
$I->conditionalClick("Doe".msq("uniqueData"), "#Doe".msq("uniqueData"), true);
$I->amOnUrl("Doe".msq("uniqueData").".html");
$I->searchAndMultiSelectOption("#selector", ["John", "Doe".msq("uniqueData")]);
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData")."John", "Doe".msq("uniqueData")]);
$I->selectMultipleOptions("#Doe".msq("uniqueData"), "#element", [msq("uniqueData")."John", "Doe".msq("uniqueData")]);
$I->fillField("#selector", "StringBefore " . msq("uniqueData") . "John StringAfter");
$I->fillField("#" . msq("uniqueData") . "John", "input");
$I->dragAndDrop("#" . msq("uniqueData") . "John", msq("uniqueData") . "John");
$I->conditionalClick(msq("uniqueData") . "John", "#" . msq("uniqueData") . "John", true);
$I->amOnUrl(msq("uniqueData") . "John.html");
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData") . "John", "Doe"]);
$I->click("#" . msq("uniqueData") . "John#" . msq("uniqueData") . "John");
$I->click("#Doe" . msq("uniqueData") . "#Doe" . msq("uniqueData"));
$I->fillField("#selector", "StringBefore Doe" . msq("uniqueData") . " StringAfter");
$I->fillField("#Doe" . msq("uniqueData"), "input");
$I->dragAndDrop("#Doe" . msq("uniqueData"), "Doe" . msq("uniqueData"));
$I->conditionalClick("Doe" . msq("uniqueData"), "#Doe" . msq("uniqueData"), true);
$I->amOnUrl("Doe" . msq("uniqueData") . ".html");
$I->searchAndMultiSelectOption("#selector", ["John", "Doe" . msq("uniqueData")]);
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]);
$I->selectMultipleOptions("#Doe" . msq("uniqueData"), "#element", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]);
$I->fillField(".selector", "0");
}
}
12 changes: 6 additions & 6 deletions dev/tests/verification/Resources/ParameterArrayTest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ class ParameterArrayTestCest
$simpleDataKey = new DataPersistenceHandler($simpleParamData, []);
$simpleDataKey->createEntity();
$I->searchAndMultiSelectOption("#selector", ["name"]);
$I->searchAndMultiSelectOption("#selector", [msq("simpleParamData")."prename"]);
$I->searchAndMultiSelectOption("#selector", ["postname".msq("simpleParamData")]);
$I->searchAndMultiSelectOption("#selector", [msq("simpleParamData") . "prename"]);
$I->searchAndMultiSelectOption("#selector", ["postname" . msq("simpleParamData")]);
$I->searchAndMultiSelectOption("#selector", [$simpleDataKey->getCreatedDataByName('name')]);
$I->searchAndMultiSelectOption("#selector", ["name", $simpleDataKey->getCreatedDataByName('name')]);
$I->searchAndMultiSelectOption("#selector", ['someKey' => $simpleDataKey->getCreatedDataByName('name')]);
$I->searchAndMultiSelectOption("#selector", ['someKey' => "name"]);
$I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData")."prename"]);
$I->searchAndMultiSelectOption("#selector", ['someKey' => "postname".msq("simpleParamData")]);
$I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData") . "prename"]);
$I->searchAndMultiSelectOption("#selector", ['someKey' => "postname" . msq("simpleParamData")]);
$I->unselectOption("#selector", ['foo']);
$I->unselectOption("#selector", ['foo', 'bar']);
$I->unselectOption("#selector", ["name"]);
$I->unselectOption("#selector", [msq("simpleParamData")."prename"]);
$I->unselectOption("#selector", ["postname".msq("simpleParamData")]);
$I->unselectOption("#selector", [msq("simpleParamData") . "prename"]);
$I->unselectOption("#selector", ["postname" . msq("simpleParamData")]);
$I->unselectOption("#selector", [$simpleDataKey->getCreatedDataByName('name')]);
$I->unselectOption("#selector", ["name", $simpleDataKey->getCreatedDataByName('name')]);
}
Expand Down
20 changes: 10 additions & 10 deletions dev/tests/verification/Resources/SectionReplacementTest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ class SectionReplacementTestCest
$I->click("#John .Doe");
$I->click("#John-Doe .Tiberius");
$I->click("#John-Doe .John [Tiberius]");
$I->click("#element .".msq("uniqueData")."John");
$I->click("#".msq("uniqueData")."John .stringLiteral2");
$I->click("#".msq("uniqueData")."John-stringLiteral2 .stringLiteral3");
$I->click("#".msq("uniqueData")."John-stringLiteral2 .");
$I->click("#element .Doe".msq("uniqueData"));
$I->click("#Doe".msq("uniqueData")." .stringLiteral2");
$I->click("#Doe".msq("uniqueData")."-stringLiteral2 .stringLiteral3");
$I->click("#Doe".msq("uniqueData")."-stringLiteral2 .Doe");
$I->click("#element ." . msq("uniqueData") . "John");
$I->click("#" . msq("uniqueData") . "John .stringLiteral2");
$I->click("#" . msq("uniqueData") . "John-stringLiteral2 .stringLiteral3");
$I->click("#" . msq("uniqueData") . "John-stringLiteral2 ." . msq("uniqueData") . "John [stringLiteral3]");
$I->click("#element .Doe" . msq("uniqueData"));
$I->click("#Doe" . msq("uniqueData") . " .stringLiteral2");
$I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .stringLiteral3");
$I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .Doe" . msq("uniqueData") . " [stringLiteral3]");
$I->amGoingTo("create entity that has the stepKey: createdData");
$simpleData = DataObjectHandler::getInstance()->getObject("simpleData");
$createdData = new DataPersistenceHandler($simpleData, []);
Expand All @@ -60,7 +60,7 @@ class SectionReplacementTestCest
$I->click("#John-Doe .John [Tiberius]");
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .John");
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .{$data}");
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .".msq("uniqueData")."John");
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .Doe".msq("uniqueData"));
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " ." . msq("uniqueData") . "John");
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .Doe" . msq("uniqueData"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<conditionalClick stepKey="dependentSelectorReplaceMSQPrefix" dependentSelector="#{{uniqueData.firstname}}" selector="{{uniqueData.firstname}}" visible="true"/>
<amOnUrl stepKey="urlReplaceMSQPrefix" url="{{uniqueData.firstname}}.html"/>
<searchAndMultiSelectOption stepKey="parameterArrayReplacementMSQPrefix" selector="#selector" parameterArray="[{{uniqueData.firstname}}, {{simpleData.lastname}}]"/>
<click stepKey="selectorReplaceDupedMSQPrefix" selector="#{{uniqueData.firstname}}#{{uniqueData.firstname}}"/>
<click stepKey="selectorReplaceDupedMSQSuffix" selector="#{{uniqueData.lastname}}#{{uniqueData.lastname}}"/>

<fillField stepKey="inputReplaceMSQSuffix" selector="#selector" userInput="StringBefore {{uniqueData.lastname}} StringAfter"/>
<fillField stepKey="selectorReplaceMSQSuffix" selector="#{{uniqueData.lastname}}" userInput="input"/>
Expand Down
29 changes: 10 additions & 19 deletions src/Magento/FunctionalTestingFramework/Util/TestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1576,26 +1576,17 @@ private function addUniquenessToParamArray($input)
*/
private function addUniquenessFunctionCall($input)
{
$output = '';

preg_match('/' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\("[\w]+"\)/', $input, $matches);
if (!empty($matches)) {
$parts = preg_split('/' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\("[\w]+"\)/', $input, -1);
for ($i = 0; $i < count($parts); $i++) {
$parts[$i] = $this->stripWrappedQuotes($parts[$i]);
}
if (!empty($parts[0])) {
$output = $this->wrapWithDoubleQuotes($parts[0]);
}
$output .= $output === '' ? $matches[0] : '.' . $matches[0];
if (!empty($parts[1])) {
$output .= '.' . $this->wrapWithDoubleQuotes($parts[1]);
}
} else {
$output = $this->wrapWithDoubleQuotes($input);
$output = $this->wrapWithDoubleQuotes($input);

//Match on msq(\"entityName\")
preg_match_all('/' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\(\\\\"[\w]+\\\\"\)/', $output, $matches);
foreach (array_unique($matches[0]) as $match) {
preg_match('/\\\\"([\w]+)\\\\"/', $match, $entityMatch);
$entity = $entityMatch[1];
$output = str_replace($match, '" . msq("' . $entity . '") . "', $output);
}

return $output;
// trim unnecessary "" . and . ""
return preg_replace('/(?(?<![\\\\])"" \. )| \. ""/', "", $output);
}

/**
Expand Down