From fccb25262b037cd6b8e23f70cbf480fc73be5e1d Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Mon, 9 Apr 2018 13:14:40 -0500 Subject: [PATCH 1/2] MQE-914: Multiple Uniqueness References On Same Entity Generates Incorrectly - refactored uniquenessFunctionCall in TestGenerator; fixes bug. - updated verification tests to catch test case. --- ...thPassedArgumentAndStringSelectorParam.txt | 2 +- ...gleParameterSelectorFromPassedArgument.txt | 2 +- .../Resources/DataReplacementTest.txt | 28 +++++++++--------- .../Resources/ParameterArrayTest.txt | 12 ++++---- .../Resources/SectionReplacementTest.txt | 20 ++++++------- .../Util/TestGenerator.php | 29 +++++++------------ 6 files changed, 42 insertions(+), 51 deletions(-) diff --git a/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt b/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt index c16a6a26e..043a71c94 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt @@ -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"); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt index 98c561e3c..fb10e7847 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt @@ -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")); } } diff --git a/dev/tests/verification/Resources/DataReplacementTest.txt b/dev/tests/verification/Resources/DataReplacementTest.txt index a6d620a2c..0d2a91ae4 100644 --- a/dev/tests/verification/Resources/DataReplacementTest.txt +++ b/dev/tests/verification/Resources/DataReplacementTest.txt @@ -33,20 +33,20 @@ 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->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"); } } diff --git a/dev/tests/verification/Resources/ParameterArrayTest.txt b/dev/tests/verification/Resources/ParameterArrayTest.txt index 2e196225d..f60478037 100644 --- a/dev/tests/verification/Resources/ParameterArrayTest.txt +++ b/dev/tests/verification/Resources/ParameterArrayTest.txt @@ -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')]); } diff --git a/dev/tests/verification/Resources/SectionReplacementTest.txt b/dev/tests/verification/Resources/SectionReplacementTest.txt index b89eb130b..07a8e7400 100644 --- a/dev/tests/verification/Resources/SectionReplacementTest.txt +++ b/dev/tests/verification/Resources/SectionReplacementTest.txt @@ -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, []); @@ -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")); } } diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index cae931611..821b12f6a 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -1565,26 +1565,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 ($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('/(?(? Date: Mon, 16 Apr 2018 11:18:18 -0500 Subject: [PATCH 2/2] MQE-914: Multiple Uniqueness References On Same Entity Generates Incorrectly - CR Fixes --- dev/tests/verification/Resources/DataReplacementTest.txt | 2 ++ dev/tests/verification/TestModule/Test/DataReplacementTest.xml | 2 ++ src/Magento/FunctionalTestingFramework/Util/TestGenerator.php | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dev/tests/verification/Resources/DataReplacementTest.txt b/dev/tests/verification/Resources/DataReplacementTest.txt index 0d2a91ae4..d5121931c 100644 --- a/dev/tests/verification/Resources/DataReplacementTest.txt +++ b/dev/tests/verification/Resources/DataReplacementTest.txt @@ -39,6 +39,8 @@ class DataReplacementTestCest $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")); diff --git a/dev/tests/verification/TestModule/Test/DataReplacementTest.xml b/dev/tests/verification/TestModule/Test/DataReplacementTest.xml index 7aadebb47..f12c70b26 100644 --- a/dev/tests/verification/TestModule/Test/DataReplacementTest.xml +++ b/dev/tests/verification/TestModule/Test/DataReplacementTest.xml @@ -22,6 +22,8 @@ + + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 821b12f6a..44f2ba81f 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -1569,7 +1569,7 @@ private function addUniquenessFunctionCall($input) //Match on msq(\"entityName\") preg_match_all('/' . EntityDataObject::CEST_UNIQUE_FUNCTION . '\(\\\\"[\w]+\\\\"\)/', $output, $matches); - foreach ($matches[0] as $match) { + foreach (array_unique($matches[0]) as $match) { preg_match('/\\\\"([\w]+)\\\\"/', $match, $entityMatch); $entity = $entityMatch[1]; $output = str_replace($match, '" . msq("' . $entity . '") . "', $output);