From b42cf6d1d8714160ac80a6a307579cf8802d3272 Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Wed, 1 Aug 2018 14:44:37 -0500 Subject: [PATCH 1/9] MQE-1123 - TestGenerator keeps track stepKeys in the block of test actions, assumes createDataKey references are scoped to the class if they are not present in the test. --- .../Resources/BasicFunctionalTest.txt | 2 +- .../Resources/DataActionsTest.txt | 71 +++++++++++++++++++ .../TestModule/Test/DataActionsTest.xml | 25 +++++++ .../Util/TestGenerator.php | 10 ++- 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 dev/tests/verification/Resources/DataActionsTest.txt create mode 100644 dev/tests/verification/TestModule/Test/DataActionsTest.xml diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index 7fed6db42..9ef07a67e 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -77,7 +77,7 @@ class BasicFunctionalTestCest $I->closeTab(); $I->conditionalClick(".functionalTestSelector", ".functionalDependentTestSelector", true); $I->amGoingTo("delete entity that has the createDataKey: createKey1"); - $createKey1->deleteEntity(); + $this->createKey1->deleteEntity(); $I->deleteEntityByUrl("/V1/categories{$grabbedData}"); $I->dontSee("someInput", ".functionalTestSelector"); $I->dontSeeCheckboxIsChecked(".functionalTestSelector"); diff --git a/dev/tests/verification/Resources/DataActionsTest.txt b/dev/tests/verification/Resources/DataActionsTest.txt new file mode 100644 index 000000000..969973317 --- /dev/null +++ b/dev/tests/verification/Resources/DataActionsTest.txt @@ -0,0 +1,71 @@ +amGoingTo("create entity that has the stepKey: createdInBefore"); + $entity = DataObjectHandler::getInstance()->getObject("entity"); + $this->createdInBefore = new DataPersistenceHandler($entity, []); + $this->createdInBefore->createEntity(); + $I->amGoingTo("update entity that has the createdDataKey: createdInBefore"); + $this->createdInBefore->updateEntity("entity"); + $I->amGoingTo("delete entity that has the createDataKey: createdInBefore"); + $this->createdInBefore->deleteEntity(); + } + + /** + * @Features({"TestModule"}) + * @Parameter(name = "AcceptanceTester", value="$I") + * @param AcceptanceTester $I + * @return void + * @throws \Exception + */ + public function DataActionsTest(AcceptanceTester $I) + { + $I->amGoingTo("create entity that has the stepKey: createdInTest"); + $entity = DataObjectHandler::getInstance()->getObject("entity"); + $createdInTest = new DataPersistenceHandler($entity, []); + $createdInTest->createEntity(); + $I->amGoingTo("update entity that has the createdDataKey: createdInTest"); + $createdInTest->updateEntity("entity"); + $I->amGoingTo("delete entity that has the createDataKey: createdInTest"); + $createdInTest->deleteEntity(); + $I->amGoingTo("update entity that has the createdDataKey: createdInBefore"); + $this->createdInBefore->updateEntity("entity"); + $I->amGoingTo("delete entity that has the createDataKey: createdInBefore"); + $this->createdInBefore->deleteEntity(); + } +} diff --git a/dev/tests/verification/TestModule/Test/DataActionsTest.xml b/dev/tests/verification/TestModule/Test/DataActionsTest.xml new file mode 100644 index 000000000..03d7caa35 --- /dev/null +++ b/dev/tests/verification/TestModule/Test/DataActionsTest.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index bcae12c9b..755e79866 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -463,9 +463,11 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " { //TODO: Refactor Method according to PHPMD warnings, remove @SuppressWarnings accordingly. $testSteps = ""; + $previousStepKeys = []; foreach ($actionObjects as $actionObject) { $stepKey = $actionObject->getStepKey(); + $previousStepKeys[] = $stepKey; $customActionAttributes = $actionObject->getCustomActionAttributes(); $attribute = null; $selector = null; @@ -755,6 +757,8 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "deleteData": if (isset($customActionAttributes['createDataKey'])) { $key = $customActionAttributes['createDataKey']; + $keyIsFoundInSameBlock = array_search($key, $previousStepKeys); + //Add an informative statement to help the user debug test runs $contextSetter = sprintf( "\t\t$%s->amGoingTo(\"delete entity that has the createDataKey: %s\");\n", @@ -763,7 +767,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " ); $deleteEntityFunctionCall = ""; - if ($hookObject) { + if ($hookObject || $keyIsFoundInSameBlock === false) { $deleteEntityFunctionCall .= sprintf("\t\t\$this->%s->deleteEntity();\n", $key); } else { $deleteEntityFunctionCall .= sprintf("\t\t$%s->deleteEntity();\n", $key); @@ -785,6 +789,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "updateData": $key = $customActionAttributes['createDataKey']; $updateEntity = $customActionAttributes['entity']; + $keyIsFoundInSameBlock = array_search($key, $previousStepKeys); //Add an informative statement to help the user debug test runs $testSteps .= sprintf( @@ -815,7 +820,8 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " } } - if ($hookObject) { + // If hook object, or if key not found in test block, assume it's class scoped + if ($hookObject || $keyIsFoundInSameBlock === false) { $updateEntityFunctionCall = sprintf("\t\t\$this->%s->updateEntity(\"%s\"", $key, $updateEntity); } else { $updateEntityFunctionCall = sprintf("\t\t\$%s->updateEntity(\"%s\"", $key, $updateEntity); From a27337cd3346f8618159d9fdfd501858fc7c3dce Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Thu, 2 Aug 2018 13:06:50 -0500 Subject: [PATCH 2/9] MQE-1123-DATAREFACTOR - Refactored TestGenerator code to use new Handler - Introduced Handler --- .../verification/Tests/DataActionsTest.php | 22 ++ .../Handlers/PersistedObjectHandler.php | 193 +++++++++++++ .../Extension/TestContextExtension.php | 12 + .../Test/etc/Actions/dataActions.xsd | 11 + .../Util/TestGenerator.php | 259 +++++++----------- 5 files changed, 335 insertions(+), 162 deletions(-) create mode 100644 dev/tests/verification/Tests/DataActionsTest.php create mode 100644 src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php diff --git a/dev/tests/verification/Tests/DataActionsTest.php b/dev/tests/verification/Tests/DataActionsTest.php new file mode 100644 index 000000000..b5ad4a659 --- /dev/null +++ b/dev/tests/verification/Tests/DataActionsTest.php @@ -0,0 +1,22 @@ +generateAndCompareTest('DataActionsTest'); + } +} diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php new file mode 100644 index 000000000..5711e9ddb --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -0,0 +1,193 @@ + Value of override fields. + * @param string $storeCode + * @return void + */ + public function createEntity( + $key, + $scope, + $entity, + $dependentObjectKeys = [], + $overrideFields = [], + $storeCode = "" + ) { + $retrievedDependentObjects = []; + foreach ($dependentObjectKeys as $objectKey) { + $retrievedDependentObjects = $this->retrieveEntity($objectKey, $scope); + } + + $retrievedEntity = DataObjectHandler::getInstance()->getObject($entity); + $persistedObject = new DataPersistenceHandler( + $retrievedEntity, + $retrievedDependentObjects, + $overrideFields + ); + + $persistedObject->createEntity($storeCode); + + if ($scope == self::TEST_SCOPE) { + $this->testObjects[$key] = $persistedObject; + } else { + $this->hookObjects[$key] = $persistedObject; + } + } + + /** + * Retrieves and updates a previously created entity. + * @param string $key StepKey of the createData action. + * @param $scope + * @param string $updateEntity Name of the static XML data to update the entity with. + * @param array $dependentObjectKeys StepKeys of other createData actions that are required. + * @return void + */ + public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = []) + { + $retrievedDependentObjects = []; + foreach ($dependentObjectKeys as $objectKey) { + $retrievedDependentObjects = $this->retrieveEntity($objectKey, $scope); + } + + $originalEntity = $this->retrieveEntity($key, $scope); + $originalEntity->updateEntity($updateEntity, $retrievedDependentObjects); + } + + /** + * Retrieves and deletes a previously created entity. + * @param string $key StepKey of the createData action. + * @param string $scope + * @return void + */ + public function deleteEntity($key, $scope) + { + $originalEntity = $this->retrieveEntity($key, $scope); + $originalEntity->deleteEntity(); + } + + /** + * Performs GET on given entity and stores entity for use. + * @param string $key StepKey of getData action. + * @param string $scope + * @param string $entity Name of XML static data to use. + * @param array $dependentObjectKeys StepKeys of other createData actions that are required. + * @param string $storeCode + * @param integer $index + * @return void + */ + public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $storeCode = "", $index = null) + { + $retrievedDependentObjects = []; + foreach ($dependentObjectKeys as $objectKey) { + $retrievedDependentObjects = $this->retrieveEntity($objectKey, $scope); + } + + $retrievedEntity = DataObjectHandler::getInstance()->getObject($entity); + $persistedObject = new DataPersistenceHandler( + $retrievedEntity, + $retrievedDependentObjects + ); + $persistedObject->getEntity($index, $storeCode); + + if ($scope == self::TEST_SCOPE) { + $this->testObjects[$key] = $persistedObject; + } else { + $this->hookObjects[$key] = $persistedObject; + } + } + + /** + * Attempts to retrieve Entity from given scope, falling back to other scope if not found. + * @param $key + * @param $scope + * @return DataPersistenceHandler + * @throws TestReferenceException + */ + private function retrieveEntity($key, $scope) + { + if ($scope == self::TEST_SCOPE) { + if (array_key_exists($key, $this->testObjects)) { + return $this->testObjects[$key]; + } elseif (array_key_exists($key, $this->hookObjects)) { + return $this->hookObjects[$key]; + } + } else { + if (array_key_exists($key, $this->hookObjects)) { + return $this->hookObjects[$key]; + } elseif (array_key_exists($key, $this->testObjects)) { + return $this->testObjects[$key]; + } + } + throw new TestReferenceException("Entity with a CreateDataKey of {$key} could not be found"); + } + + /** + * Clears store of all persisted Objects + * @return void + */ + public function clearPersistedObjects() + { + $this->hookObjects = []; + $this->testObjects = []; + } +} diff --git a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php index c0bf78f19..da1bc148f 100644 --- a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php +++ b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php @@ -7,6 +7,7 @@ namespace Magento\FunctionalTestingFramework\Extension; use \Codeception\Events; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use Magento\FunctionalTestingFramework\Extension\ErrorLogger; /** @@ -22,11 +23,22 @@ class TestContextExtension extends \Codeception\Extension * @var array */ public static $events = [ + Events::TEST_START => 'testStart', Events::TEST_FAIL => 'testFail', Events::STEP_AFTER => 'afterStep', Events::TEST_END => 'testError' ]; + /** + * Codeception event listener function, triggered on test start. + * @param \Codeception\Event\TestEvent $e + * @throws \Exception + */ + public function testStart(\Codeception\Event\TestEvent $e) + { + PersistedObjectHandler::getInstance()->clearPersistedObjects(); + } + /** * Codeception event listener function, triggered on test failure. * @param \Codeception\Event\FailEvent $e diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/dataActions.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/dataActions.xsd index 1a7ea2d78..2cd614266 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/dataActions.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/dataActions.xsd @@ -43,6 +43,14 @@ + + + + StepKey of the ActionGroup where this data was created, if it was created in one. + + + + @@ -66,6 +74,7 @@ + @@ -77,6 +86,7 @@ + @@ -108,6 +118,7 @@ + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 755e79866..b515f14e1 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -7,6 +7,7 @@ namespace Magento\FunctionalTestingFramework\Util; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject; use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler; @@ -286,11 +287,8 @@ private function debug($messages) private function generateUseStatementsPhp() { $useStatementsPhp = "use Magento\FunctionalTestingFramework\AcceptanceTester;\n"; - - $useStatementsPhp .= "use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;\n"; - $useStatementsPhp .= "use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;\n"; - $useStatementsPhp .= "use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;\n"; $useStatementsPhp .= "use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;\n"; + $useStatementsPhp .= "use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;\n"; $useStatementsPhp .= "use \Codeception\Util\Locator;\n"; $allureStatements = [ @@ -686,93 +684,68 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $actor, $stepKey ); - //Get Entity from Static data. - $testSteps .= sprintf( - "\t\t$%s = DataObjectHandler::getInstance()->getObject(\"%s\");\n", - $entity, - $entity - ); - //HookObject End-Product needs to be created in the Class scope, - //otherwise create them in the Test scope. - //Determine if there are required-entities and create array of required-entities for merging. - $requiredEntities = []; + //TODO refactor entity field override to not be individual actionObjects $customEntityFields = $customActionAttributes[ActionObjectExtractor::ACTION_OBJECT_PERSISTENCE_FIELDS] ?? []; - $requiredEntityObjects = []; - foreach ($customActionAttributes as $customAttribute) { - if (is_array($customAttribute) && $customAttribute['nodeName'] == 'requiredEntity') { - if ($hookObject) { - $requiredEntities [] = "\$this->" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getName() => " . "\$this->" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getType()"; - $requiredEntityObjects [] = '$this->' . $customAttribute - [self::REQUIRED_ENTITY_REFERENCE]; - } else { - $requiredEntities [] = "\$" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] - . "->getName() => " . "\$" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getType()"; - $requiredEntityObjects [] = '$' . $customAttribute[self::REQUIRED_ENTITY_REFERENCE]; - } + + $requiredEntityKeys = []; + foreach ($actionObject->getCustomActionAttributes() as $actionAttribute) { + if (is_array($actionAttribute) && $actionAttribute['nodeName'] == 'requiredEntity') { + //append ActionGroup if provided + $requiredEntityActionGroup = $actionAttribute['actionGroup'] ?? null; + $requiredEntityKeys[] = $actionAttribute['createDataKey'] . $requiredEntityActionGroup; } } - + // Build array of requiredEntities + $requiredEntityKeysArray = ""; + if (!empty($requiredEntityKeys)) { + $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; + } + //Determine Scope + $scope = "PersistedObjectHandler::TEST_SCOPE"; if ($hookObject) { - $createEntityFunctionCall = sprintf("\t\t\$this->%s->createEntity(", $stepKey); - $dataPersistenceHandlerFunctionCall = sprintf( - "\t\t\$this->%s = new DataPersistenceHandler($%s", - $stepKey, - $entity - ); - } else { - $createEntityFunctionCall = sprintf("\t\t\$%s->createEntity(", $stepKey); - $dataPersistenceHandlerFunctionCall = sprintf( - "\t\t$%s = new DataPersistenceHandler($%s", - $stepKey, - $entity - ); + $scope = "PersistedObjectHandler::HOOK_SCOPE"; } - - if ($storeCode) { - $createEntityFunctionCall .= sprintf("\"%s\");\n", $storeCode); - } else { - $createEntityFunctionCall .= ");\n"; + $createEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->createEntity("; + $createEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; + $createEntityFunctionCall .= "\n\t\t\t{$scope},"; + $createEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; + if (!empty($requiredEntityKeysArray)) { + $createEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; } - - // Add a reference to the requiredEntityObjects to the new DataPersistenceHandler. If there are none - // defined, an empty array will be passed in to the constructor. - $dataPersistenceHandlerFunctionCall .= sprintf( - ", [%s]", - implode(', ', $requiredEntityObjects) - ); - if (count($customEntityFields) > 1) { - $dataPersistenceHandlerFunctionCall .= ", \${$stepKey}Fields"; + $createEntityFunctionCall .= ",\n\t\t\t\${$stepKey}Fields"; } - - $dataPersistenceHandlerFunctionCall .= ");\n"; - $testSteps .= $dataPersistenceHandlerFunctionCall; + if ($storeCode !== null) { + $createEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; + } + $createEntityFunctionCall .= "\n\t\t);\n"; $testSteps .= $createEntityFunctionCall; break; case "deleteData": if (isset($customActionAttributes['createDataKey'])) { $key = $customActionAttributes['createDataKey']; - $keyIsFoundInSameBlock = array_search($key, $previousStepKeys); - + $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null; //Add an informative statement to help the user debug test runs $contextSetter = sprintf( "\t\t$%s->amGoingTo(\"delete entity that has the createDataKey: %s\");\n", $actor, $key ); - $deleteEntityFunctionCall = ""; - if ($hookObject || $keyIsFoundInSameBlock === false) { - $deleteEntityFunctionCall .= sprintf("\t\t\$this->%s->deleteEntity();\n", $key); - } else { - $deleteEntityFunctionCall .= sprintf("\t\t$%s->deleteEntity();\n", $key); + $key .= $actionGroup; + //Determine Scope + $scope = "PersistedObjectHandler::TEST_SCOPE"; + if ($hookObject) { + $scope = "PersistedObjectHandler::HOOK_SCOPE"; } + $deleteEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->deleteEntity("; + $deleteEntityFunctionCall .= "\n\t\t\t\"{$key}\","; + $deleteEntityFunctionCall .= "\n\t\t\t{$scope}"; + $deleteEntityFunctionCall .= "\n\t\t);\n"; + $testSteps .= $contextSetter; $testSteps .= $deleteEntityFunctionCall; } else { @@ -789,7 +762,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "updateData": $key = $customActionAttributes['createDataKey']; $updateEntity = $customActionAttributes['entity']; - $keyIsFoundInSameBlock = array_search($key, $previousStepKeys); + $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null; //Add an informative statement to help the user debug test runs $testSteps .= sprintf( @@ -798,128 +771,90 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $key ); - //HookObject End-Product needs to be created in the Class scope, - //otherwise create them in the Test scope. - //Determine if there are required-entities and create array of required-entities for merging. - $requiredEntities = []; - $requiredEntityObjects = []; - foreach ($customActionAttributes as $customAttribute) { - if (is_array($customAttribute) && $customAttribute['nodeName'] == 'requiredEntity') { - if ($hookObject) { - $requiredEntities [] = "\$this->" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getName() => " . "\$this->" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getType()"; - $requiredEntityObjects [] = '$this->' . $customAttribute - [self::REQUIRED_ENTITY_REFERENCE]; - } else { - $requiredEntities [] = "\$" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] - . "->getName() => " . "\$" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getType()"; - $requiredEntityObjects [] = '$' . $customAttribute[self::REQUIRED_ENTITY_REFERENCE]; - } + $key .= $actionGroup; + + // Build array of requiredEntities + $requiredEntityKeys = []; + foreach ($actionObject->getCustomActionAttributes() as $actionAttribute) { + if (is_array($actionAttribute) && $actionAttribute['nodeName'] == 'requiredEntity') { + //append ActionGroup if provided + $requiredEntityActionGroup = $actionAttribute['actionGroup'] ?? null; + $requiredEntityKeys[] = $actionAttribute['createDataKey'] . $requiredEntityActionGroup; } } - - // If hook object, or if key not found in test block, assume it's class scoped - if ($hookObject || $keyIsFoundInSameBlock === false) { - $updateEntityFunctionCall = sprintf("\t\t\$this->%s->updateEntity(\"%s\"", $key, $updateEntity); - } else { - $updateEntityFunctionCall = sprintf("\t\t\$%s->updateEntity(\"%s\"", $key, $updateEntity); + $requiredEntityKeysArray = ""; + if (!empty($requiredEntityKeys)) { + $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; } - if (!empty($requiredEntities)) { - $updateEntityFunctionCall .= sprintf( - ", [%s]", - implode(', ', $requiredEntityObjects) - ); + $scope = "PersistedObjectHandler::TEST_SCOPE"; + if ($hookObject) { + $scope = "PersistedObjectHandler::HOOK_SCOPE"; } - if ($storeCode) { - $updateEntityFunctionCall .= sprintf(", \"%s\");\n", $storeCode); - } else { - $updateEntityFunctionCall .= ");\n"; + $updateEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->updateEntity("; + $updateEntityFunctionCall .= "\n\t\t\t\"{$key}\","; + $updateEntityFunctionCall .= "\n\t\t\t{$scope},"; + $updateEntityFunctionCall .= "\n\t\t\t\"{$updateEntity}\""; + if (!empty($requiredEntityKeysArray)) { + $updateEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; } - + if ($storeCode !== null) { + $updateEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; + } + $updateEntityFunctionCall .= "\n\t\t);\n"; $testSteps .= $updateEntityFunctionCall; + break; case "getData": $entity = $customActionAttributes['entity']; + $index = null; + if (isset($customActionAttributes['index'])) { + $index = (int)$customActionAttributes['index']; + } //Add an informative statement to help the user debug test runs $testSteps .= sprintf( "\t\t$%s->amGoingTo(\"get entity that has the stepKey: %s\");\n", $actor, $stepKey ); - //Get Entity from Static data. - $testSteps .= sprintf( - "\t\t$%s = DataObjectHandler::getInstance()->getObject(\"%s\");\n", - $entity, - $entity - ); - //HookObject End-Product needs to be created in the Class scope, - //otherwise create them in the Test scope. - //Determine if there are required-entities and create array of required-entities for merging. - $requiredEntities = []; - $requiredEntityObjects = []; - foreach ($customActionAttributes as $customAttribute) { - if (is_array($customAttribute) && $customAttribute['nodeName'] = 'requiredEntity') { - if ($hookObject) { - $requiredEntities [] = "\$this->" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getName() => " . "\$this->" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getType()"; - $requiredEntityObjects [] = '$this->' . $customAttribute - [self::REQUIRED_ENTITY_REFERENCE]; - } else { - $requiredEntities [] = "\$" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] - . "->getName() => " . "\$" . $customAttribute[self::REQUIRED_ENTITY_REFERENCE] . - "->getType()"; - $requiredEntityObjects [] = '$' . $customAttribute[self::REQUIRED_ENTITY_REFERENCE]; - } + // Build array of requiredEntities + $requiredEntityKeys = []; + foreach ($actionObject->getCustomActionAttributes() as $actionAttribute) { + if (is_array($actionAttribute) && $actionAttribute['nodeName'] == 'requiredEntity') { + $requiredEntityActionGroup = $actionAttribute['actionGroup'] ?? null; + $requiredEntityKeys[] = $actionAttribute['createDataKey'] . $requiredEntityActionGroup; } } + $requiredEntityKeysArray = ""; + if (!empty($requiredEntityKeys)) { + $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; + } + //Determine Scope + $scope = "PersistedObjectHandler::TEST_SCOPE"; if ($hookObject) { - $getEntityFunctionCall = sprintf("\t\t\$this->%s->getEntity(", $stepKey); - $dataPersistenceHandlerFunctionCall = sprintf( - "\t\t\$this->%s = new DataPersistenceHandler($%s", - $stepKey, - $entity - ); - } else { - $getEntityFunctionCall = sprintf("\t\t\$%s->getEntity(", $stepKey); - $dataPersistenceHandlerFunctionCall = sprintf( - "\t\t$%s = new DataPersistenceHandler($%s", - $stepKey, - $entity - ); + $scope = "PersistedObjectHandler::HOOK_SCOPE"; } - if (isset($customActionAttributes['index'])) { - $getEntityFunctionCall .= sprintf("%s", (int)$customActionAttributes['index']); - } else { - $getEntityFunctionCall .= 'null'; + //Create Function + $getEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->getEntity("; + $getEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; + $getEntityFunctionCall .= "\n\t\t\t{$scope},"; + $getEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; + if (!empty($requiredEntityKeysArray)) { + $getEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; } - - if ($storeCode) { - $getEntityFunctionCall .= sprintf(", \"%s\");\n", $storeCode); - } else { - $getEntityFunctionCall .= ");\n"; + if ($storeCode !== null) { + $getEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; } - - //If required-entities are defined, reassign dataObject to not overwrite the static definition. - //Also, DataPersistenceHandler needs to be defined with customData array. - if (!empty($requiredEntities)) { - $dataPersistenceHandlerFunctionCall .= sprintf( - ", [%s]);\n", - implode(', ', $requiredEntityObjects) - ); - } else { - $dataPersistenceHandlerFunctionCall .= ");\n"; + if ($index !== null) { + $getEntityFunctionCall .= ",\n\t\t\t{$index}"; } - - $testSteps .= $dataPersistenceHandlerFunctionCall; + $getEntityFunctionCall .= "\n\t\t);\n"; $testSteps .= $getEntityFunctionCall; + break; case "assertArrayIsSorted": $testSteps .= $this->wrapFunctionCall( From 0879eda8b184b7caa79d7740c7c9aa84fa73c45a Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Wed, 8 Aug 2018 14:40:04 -0500 Subject: [PATCH 3/9] MQE-1123-DATAREFACTOR - Further TestGenerator refactor work to use constants - Scope now passed into generateStepsPhp (to support test/hook/suite) - refactored $data.key$ references to use handler for value retrieval --- .../Handlers/PersistedObjectHandler.php | 78 +++++++-- .../Extension/TestContextExtension.php | 3 +- .../Suite/Generators/GroupClassGenerator.php | 2 +- .../Suite/views/SuiteClass.mustache | 7 +- .../Suite/views/partials/testActions.mustache | 15 +- .../Util/TestGenerator.php | 150 +++++++++++------- 6 files changed, 166 insertions(+), 89 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php index 5711e9ddb..c2bb9a312 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -13,6 +13,7 @@ class PersistedObjectHandler { const HOOK_SCOPE = "hook"; const TEST_SCOPE = "test"; + const SUITE_SCOPE = "suite"; /** * The singleton instance of this class @@ -33,6 +34,13 @@ class PersistedObjectHandler */ private $testObjects = []; + + /** + * Store of all suite created objects + * @var DataPersistenceHandler[] array + */ + private $suiteObjects = []; + /** * Constructor */ @@ -89,8 +97,10 @@ public function createEntity( if ($scope == self::TEST_SCOPE) { $this->testObjects[$key] = $persistedObject; - } else { + } elseif ($scope == self::HOOK_SCOPE) { $this->hookObjects[$key] = $persistedObject; + } else { + $this->suiteObjects[$key] = $persistedObject; } } @@ -151,13 +161,29 @@ public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $sto if ($scope == self::TEST_SCOPE) { $this->testObjects[$key] = $persistedObject; - } else { + } elseif ($scope == self::HOOK_SCOPE) { $this->hookObjects[$key] = $persistedObject; + } else { + $this->suiteObjects[$key] = $persistedObject; } } /** - * Attempts to retrieve Entity from given scope, falling back to other scope if not found. + * Retrieves a field from an entity, according to key and scope given. + * @param $key + * @param $field + * @param $scope + * @return string + * @throws TestReferenceException + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException + */ + public function retrieveEntityField($key, $field, $scope) + { + return $this->retrieveEntity($key, $scope)->getCreatedDataByName($field); + } + + /** + * Attempts to retrieve Entity from given scope, falling back to outer scopes if not found. * @param $key * @param $scope * @return DataPersistenceHandler @@ -165,29 +191,47 @@ public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $sto */ private function retrieveEntity($key, $scope) { - if ($scope == self::TEST_SCOPE) { - if (array_key_exists($key, $this->testObjects)) { - return $this->testObjects[$key]; - } elseif (array_key_exists($key, $this->hookObjects)) { - return $this->hookObjects[$key]; - } - } else { - if (array_key_exists($key, $this->hookObjects)) { - return $this->hookObjects[$key]; - } elseif (array_key_exists($key, $this->testObjects)) { - return $this->testObjects[$key]; + // Assume TEST_SCOPE is default + $entityArrays = [$this->testObjects, $this->hookObjects, $this->suiteObjects]; + + if ($scope == self::HOOK_SCOPE) { + $entityArrays[0] = $this->hookObjects; + $entityArrays[1] = $this->testObjects; + } + + foreach ($entityArrays as $entityArray) { + if (array_key_exists($key, $entityArray)) { + return $entityArray[$key]; } } + throw new TestReferenceException("Entity with a CreateDataKey of {$key} could not be found"); } /** - * Clears store of all persisted Objects + * Clears store of all test persisted Objects * @return void */ - public function clearPersistedObjects() + public function clearTestObjects() { - $this->hookObjects = []; $this->testObjects = []; } + + /** + * Clears store of all hook persisted Objects + * @return void + */ + public function clearHookObjects() + { + $this->hookObjects = []; + } + + /** + * Clears store of all suite persisted Objects + * @return void + */ + public function clearSuiteObjects() + { + $this->suiteObjects = []; + } } diff --git a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php index da1bc148f..65af03e27 100644 --- a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php +++ b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php @@ -36,7 +36,8 @@ class TestContextExtension extends \Codeception\Extension */ public function testStart(\Codeception\Event\TestEvent $e) { - PersistedObjectHandler::getInstance()->clearPersistedObjects(); + PersistedObjectHandler::getInstance()->clearHookObjects(); + PersistedObjectHandler::getInstance()->clearTestObjects(); } /** diff --git a/src/Magento/FunctionalTestingFramework/Suite/Generators/GroupClassGenerator.php b/src/Magento/FunctionalTestingFramework/Suite/Generators/GroupClassGenerator.php index 2b9662a1a..7e1278345 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/Generators/GroupClassGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Suite/Generators/GroupClassGenerator.php @@ -179,7 +179,7 @@ private function buildHookMustacheArray($hookObj) */ private function buildWebDriverActionsMustacheArray($action, $actionEntries) { - $step = TestGenerator::getInstance()->generateStepsPhp([$action], false, 'webDriver'); + $step = TestGenerator::getInstance()->generateStepsPhp([$action], TestGenerator::SUITE_SCOPE, 'webDriver'); $rawPhp = str_replace(["\t", "\n"], "", $step); $multipleCommands = explode(";", $rawPhp, -1); foreach ($multipleCommands as $command) { diff --git a/src/Magento/FunctionalTestingFramework/Suite/views/SuiteClass.mustache b/src/Magento/FunctionalTestingFramework/Suite/views/SuiteClass.mustache index cee281f36..0f3047481 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/views/SuiteClass.mustache +++ b/src/Magento/FunctionalTestingFramework/Suite/views/SuiteClass.mustache @@ -2,8 +2,7 @@ namespace Group; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler; -use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; /** * Group class is Codeception Extension which is allowed to handle to all internal events. @@ -22,9 +21,6 @@ class {{suiteName}} extends \Codeception\GroupObject private $currentTestRun = 0; private static $HOOK_EXECUTION_INIT = "\n/******** Beginning execution of {{suiteName}} suite %s block ********/\n"; private static $HOOK_EXECUTION_END = "\n/******** Execution of {{suiteName}} suite %s block complete ********/\n"; - {{#var}} - private ${{stepKey}}; - {{/var}} {{#before}} public function _before(\Codeception\Event\TestEvent $e) @@ -74,6 +70,7 @@ class {{suiteName}} extends \Codeception\GroupObject print $exception->getMessage(); } + PersistedObjectHandler::getInstance()->clearSuiteObjects(); print sprintf(self::$HOOK_EXECUTION_END, "after"); } } diff --git a/src/Magento/FunctionalTestingFramework/Suite/views/partials/testActions.mustache b/src/Magento/FunctionalTestingFramework/Suite/views/partials/testActions.mustache index 46951aa46..af68f3a25 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/views/partials/testActions.mustache +++ b/src/Magento/FunctionalTestingFramework/Suite/views/partials/testActions.mustache @@ -22,11 +22,18 @@ $webDriver->webDriver = null; {{{action}}} {{/action}} {{#createData}} -${{entityName}} = DataObjectHandler::getInstance()->getObject("{{entityName}}"); -$this->{{stepKey}} = new DataPersistenceHandler(${{entityName}}, [{{#requiredEntities}}$this->{{entityName}}{{^last}}, {{/last}}{{/requiredEntities}}]{{#customFields}}, ${{customFields}}{{/customFields}}); -$this->{{stepKey}}->createEntity(); +PersistedObjectHandler::getInstance()->createEntity( + "{{stepKey}}", + "suite", + "{{entityName}}"{{#requiredEntities}}, + [$this->{{entityName}}{{^last}}, {{/last}}]{{/requiredEntities}}{{#customFields}}, + ${{customFields}}{{/customFields}} +); {{/createData}} {{#deleteData}} -$this->{{entityName}}->deleteEntity(); +PersistedObjectHandler::getInstance()->deleteEntity( + "{{entityName}}", + "suite" +); {{/deleteData}} {{/actions}} diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index b515f14e1..7b5109237 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -34,6 +34,9 @@ class TestGenerator const REQUIRED_ENTITY_REFERENCE = 'createDataKey'; const GENERATED_DIR = '_generated'; const DEFAULT_DIR = 'default'; + const TEST_SCOPE = 'test'; + const HOOK_SCOPE = 'hook'; + const SUITE_SCOPE = 'suite'; /** * Path to the export dir. @@ -457,7 +460,7 @@ private function generateClassAnnotations($annotationType, $annotationName) * @throws \Exception * @SuppressWarnings(PHPMD) */ - public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "I") + public function generateStepsPhp($actionObjects, $generationScope = TestGenerator::TEST_SCOPE, $actor = "I") { //TODO: Refactor Method according to PHPMD warnings, remove @SuppressWarnings accordingly. $testSteps = ""; @@ -703,13 +706,16 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; } //Determine Scope - $scope = "PersistedObjectHandler::TEST_SCOPE"; - if ($hookObject) { - $scope = "PersistedObjectHandler::HOOK_SCOPE"; + $scope = PersistedObjectHandler::TEST_SCOPE; + if ($generationScope == TestGenerator::HOOK_SCOPE) { + $scope = PersistedObjectHandler::HOOK_SCOPE; + } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { + $scope = PersistedObjectHandler::SUITE_SCOPE; } + $createEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->createEntity("; $createEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; - $createEntityFunctionCall .= "\n\t\t\t{$scope},"; + $createEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $createEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; if (!empty($requiredEntityKeysArray)) { $createEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; @@ -736,21 +742,24 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $key .= $actionGroup; //Determine Scope - $scope = "PersistedObjectHandler::TEST_SCOPE"; - if ($hookObject) { - $scope = "PersistedObjectHandler::HOOK_SCOPE"; + $scope = PersistedObjectHandler::TEST_SCOPE; + if ($generationScope == TestGenerator::HOOK_SCOPE) { + $scope = PersistedObjectHandler::HOOK_SCOPE; + } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { + $scope = PersistedObjectHandler::SUITE_SCOPE; } + $deleteEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->deleteEntity("; $deleteEntityFunctionCall .= "\n\t\t\t\"{$key}\","; - $deleteEntityFunctionCall .= "\n\t\t\t{$scope}"; + $deleteEntityFunctionCall .= "\n\t\t\t\"{$scope}\""; $deleteEntityFunctionCall .= "\n\t\t);\n"; $testSteps .= $contextSetter; $testSteps .= $deleteEntityFunctionCall; } else { $url = $this->resolveAllRuntimeReferences([$url])[0]; - $url = $this->resolveTestVariable([$url], null)[0]; + $url = $this->resolveTestVariable([$url], null, $generationScope)[0]; $output = sprintf( "\t\t$%s->deleteEntityByUrl(%s);\n", $actor, @@ -787,14 +796,17 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; } - $scope = "PersistedObjectHandler::TEST_SCOPE"; - if ($hookObject) { - $scope = "PersistedObjectHandler::HOOK_SCOPE"; + $scope = PersistedObjectHandler::TEST_SCOPE; + if ($generationScope == TestGenerator::HOOK_SCOPE) { + $scope = PersistedObjectHandler::HOOK_SCOPE; + } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { + $scope = PersistedObjectHandler::SUITE_SCOPE; } + $updateEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->updateEntity("; $updateEntityFunctionCall .= "\n\t\t\t\"{$key}\","; - $updateEntityFunctionCall .= "\n\t\t\t{$scope},"; + $updateEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $updateEntityFunctionCall .= "\n\t\t\t\"{$updateEntity}\""; if (!empty($requiredEntityKeysArray)) { $updateEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; @@ -833,15 +845,18 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " } //Determine Scope - $scope = "PersistedObjectHandler::TEST_SCOPE"; - if ($hookObject) { - $scope = "PersistedObjectHandler::HOOK_SCOPE"; + $scope = PersistedObjectHandler::TEST_SCOPE; + if ($generationScope == TestGenerator::HOOK_SCOPE) { + $scope = PersistedObjectHandler::HOOK_SCOPE; + } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { + $scope = PersistedObjectHandler::SUITE_SCOPE; } + //Create Function $getEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->getEntity("; $getEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; - $getEntityFunctionCall .= "\n\t\t\t{$scope},"; + $getEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $getEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; if (!empty($requiredEntityKeysArray)) { $getEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; @@ -860,6 +875,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $parameterArray, $this->wrapWithDoubleQuotes($sortOrder) ); @@ -877,11 +893,11 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "typeInPopup": case "dontSee": case "see": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $selector); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $selector); break; case "switchToNextTab": case "switchToPreviousTab": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input); break; case "clickWithLeftButton": case "clickWithRightButton": @@ -890,18 +906,19 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " if (!$selector) { $selector = 'null'; } - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $x, $y); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $x, $y); break; case "dontSeeCookie": case "resetCookie": case "seeCookie": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $parameterArray); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $parameterArray); break; case "grabCookie": $testSteps .= $this->wrapFunctionCallWithReturnValue( $stepKey, $actor, $actionObject, + $generationScope, $input, $parameterArray ); @@ -912,7 +929,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "seeElement": case "seeElementInDOM": case "seeInFormFields": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $parameterArray); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $parameterArray); break; case "pressKey": $parameterArray = $customActionAttributes['parameterArray'] ?? null; @@ -936,22 +953,23 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " // put the array together as a string to be passed as args $parameterArray = implode(",", $tmpParameterArray); } - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input, $parameterArray); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $input, $parameterArray); break; case "selectOption": case "unselectOption": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input, $parameterArray); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $input, $parameterArray); break; case "submitForm": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $parameterArray, $button); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $parameterArray, $button); break; case "dragAndDrop": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector1, $selector2, $x, $y); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector1, $selector2, $x, $y); break; case "selectMultipleOptions": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $selector1, $selector2, $input, @@ -959,24 +977,26 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " ); break; case "executeInSelenium": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $function); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $function); break; case "executeJS": $testSteps .= $this->wrapFunctionCallWithReturnValue( $stepKey, $actor, $actionObject, + $generationScope, $function ); break; case "performOn": case "waitForElementChange": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $function, $time); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $function, $time); break; case "waitForJS": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $function, $time ); @@ -986,23 +1006,24 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "waitForElement": case "waitForElementVisible": case "waitForElementNotVisible": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $time); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $time); break; case "waitForPageLoad": case "waitForText": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $time, $selector); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $time, $selector); break; case "formatMoney": $testSteps .= $this->wrapFunctionCallWithReturnValue( $stepKey, $actor, $actionObject, + $generationScope, $input, $locale ); break; case "mSetLocale": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $locale); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $locale); break; case "grabAttributeFrom": case "grabMultiple": @@ -1011,6 +1032,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $stepKey, $actor, $actionObject, + $generationScope, $selector, $input ); @@ -1021,6 +1043,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $stepKey, $actor, $actionObject, + $generationScope, $selector ); break; @@ -1028,16 +1051,18 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $this->wrapFunctionCallWithReturnValue( $stepKey, $actor, - $actionObject + $actionObject, + $generationScope ); break; case "resizeWindow": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $width, $height); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $width, $height); break; case "searchAndMultiSelectOption": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $selector, $input, $parameterArray, @@ -1046,12 +1071,13 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " break; case "seeLink": case "dontSeeLink": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $url); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $url); break; case "setCookie": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $selector, $input, $value, @@ -1073,12 +1099,13 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "loadSessionSnapshot": case "seeInField": case "seeOptionIsSelected": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $input); break; case "seeNumberOfElements": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $selector, $input, $parameterArray @@ -1088,12 +1115,13 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "seeInSource": case "dontSeeInSource": // TODO: Need to fix xml parser to allow parsing html. - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $html); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $html); break; case "conditionalClick": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $selector, $dependentSelector, $visible @@ -1125,6 +1153,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $assertExpected, $assertActual, $assertMessage, @@ -1140,6 +1169,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $selector, $this->wrapWithDoubleQuotes($attribute), $assertExpected @@ -1157,6 +1187,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $assertActual, $assertMessage ); @@ -1165,6 +1196,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $assertExpected, $assertActual, $assertIsStrict, @@ -1175,6 +1207,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, + $generationScope, $assertMessage ); break; @@ -1183,6 +1216,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $stepKey, $actor, $actionObject, + $generationScope, $command, $arguments ); @@ -1194,7 +1228,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " break; case "field": $fieldKey = $actionObject->getCustomActionAttributes()['key']; - $input = $this->resolveTestVariable([$input], $actionObject->getActionOrigin())[0]; + $input = $this->resolveTestVariable([$input], $actionObject->getActionOrigin(), $generationScope)[0]; $argRef = "\t\t\$"; $argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = ${input};\n"; $testSteps .= $argRef; @@ -1213,7 +1247,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $dateGenerateCode; break; default: - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input, $parameter); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $input, $parameter); } } @@ -1244,7 +1278,7 @@ private function resolveLocatorFunctionInAttribute($attribute) * @return array * @throws \Exception */ - private function resolveTestVariable($args, $actionOrigin) + private function resolveTestVariable($args, $actionOrigin, $scope) { $newArgs = []; foreach ($args as $key => $arg) { @@ -1252,13 +1286,9 @@ private function resolveTestVariable($args, $actionOrigin) continue; } $outputArg = $arg; - // Match on any $$data.key$$ found inside arg, matches[0] will be array of $$data.key$$ - preg_match_all("/\\$\\$[\w.\[\]]+\\$\\$/", $outputArg, $matches); - $this->replaceMatchesIntoArg($matches[0], $outputArg, "$$"); - - // Match on any $data.key$ found inside arg, matches[0] will be array of $data.key$ - preg_match_all("/\\$[\w.\[\]]+\\$/", $outputArg, $matches); - $this->replaceMatchesIntoArg($matches[0], $outputArg, "$"); + // Math on $data.key$ and $$data.key$$ + preg_match_all('/\${1,2}[\w.\[\]]+\${1,2}/', $outputArg, $matches); + $this->replaceMatchesIntoArg($matches[0], $outputArg, $scope); //trim "{$variable}" into $variable $outputArg = $this->trimVariableIfNeeded($outputArg); @@ -1292,16 +1322,17 @@ private function trimVariableIfNeeded($input) * * @param array $matches * @param string $outputArg - * @param string $delimiter + * @param string $scope * @return void * @throws \Exception */ - private function replaceMatchesIntoArg($matches, &$outputArg, $delimiter) + private function replaceMatchesIntoArg($matches, &$outputArg, $scope) { // Remove Duplicate $matches from array. Duplicate matches are replaced all in one go. $matches = array_unique($matches); foreach ($matches as $match) { $replacement = null; + $delimiter = '$'; $variable = $this->stripAndSplitReference($match, $delimiter); if (count($variable) != 2) { throw new \Exception( @@ -1309,11 +1340,8 @@ private function replaceMatchesIntoArg($matches, &$outputArg, $delimiter) Test persisted entity references must follow {$delimiter}entityStepKey.field{$delimiter} format." ); } - if ($delimiter == "$") { - $replacement = sprintf("$%s->getCreatedDataByName('%s')", $variable[0], $variable[1]); - } elseif ($delimiter == "$$") { - $replacement = sprintf("\$this->%s->getCreatedDataByName('%s')", $variable[0], $variable[1]); - } + + $replacement = "PersistedObjectHandler::getInstance()->retrieveEntityField('{$variable[0]}', '$variable[1]', '{$scope}')"; //Determine if quoteBreak check is necessary. Assume replacement is surrounded in quotes, then override if (strpos($outputArg, "\"") !== false) { @@ -1442,7 +1470,6 @@ private function stripAndSplitReference($reference, $delimiter) private function generateHooksPhp($hookObjects) { $hooks = ""; - $createData = false; foreach ($hookObjects as $hookObject) { $type = $hookObject->getType(); @@ -1461,7 +1488,6 @@ private function generateHooksPhp($hookObjects) $hooks .= sprintf("\t * @var DataPersistenceHandler $%s;\n", $step->getStepKey()); $hooks .= "\t */\n"; $hooks .= sprintf("\tprotected $%s;\n\n", $step->getStepKey()); - $createData = true; } } @@ -1473,7 +1499,7 @@ private function generateHooksPhp($hookObjects) try { $steps = $this->generateStepsPhp( $hookObject->getActions(), - $createData + TestGenerator::HOOK_SCOPE ); } catch (TestReferenceException $e) { throw new TestReferenceException($e->getMessage() . " in Element \"" . $type . "\""); @@ -1642,11 +1668,12 @@ private function addDollarSign($input) * * @param string $actor * @param actionObject $action + * @param string $scope * @param array ...$args * @return string * @throws \Exception */ - private function wrapFunctionCall($actor, $action, ...$args) + private function wrapFunctionCall($actor, $action, $scope, ...$args) { $isFirst = true; $output = sprintf("\t\t$%s->%s(", $actor, $action->getType()); @@ -1662,7 +1689,7 @@ private function wrapFunctionCall($actor, $action, ...$args) $args = [$args]; } $args = $this->resolveAllRuntimeReferences($args); - $args = $this->resolveTestVariable($args, $action->getActionOrigin()); + $args = $this->resolveTestVariable($args, $action->getActionOrigin(), $scope); $output .= implode(", ", array_filter($args, function($value) { return $value !== null; })) . ");\n"; return $output; } @@ -1673,11 +1700,12 @@ private function wrapFunctionCall($actor, $action, ...$args) * @param string $returnVariable * @param string $actor * @param string $action + * @param string $scope * @param array ...$args * @return string * @throws \Exception */ - private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $action, ...$args) + private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $action, $scope, ...$args) { $isFirst = true; $output = sprintf("\t\t$%s = $%s->%s(", $returnVariable, $actor, $action->getType()); @@ -1693,7 +1721,7 @@ private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $actio $args = [$args]; } $args = $this->resolveAllRuntimeReferences($args); - $args = $this->resolveTestVariable($args, $action->getActionOrigin()); + $args = $this->resolveTestVariable($args, $action->getActionOrigin(), $scope); $output .= implode(", ", array_filter($args, function($value) { return $value !== null; })) . ");\n"; return $output; } From 4b03af040f88913060016c6677d9de5b18412f47 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Wed, 15 Aug 2018 13:31:42 -0500 Subject: [PATCH 4/9] MQE-1123-DATAREFACTOR - Incorrect generation fixes. --- .../Handlers/PersistedObjectHandler.php | 6 +++--- .../Util/TestGenerator.php | 16 +++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php index c2bb9a312..ea1b7fb2e 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -83,7 +83,7 @@ public function createEntity( ) { $retrievedDependentObjects = []; foreach ($dependentObjectKeys as $objectKey) { - $retrievedDependentObjects = $this->retrieveEntity($objectKey, $scope); + $retrievedDependentObjects[] = $this->retrieveEntity($objectKey, $scope); } $retrievedEntity = DataObjectHandler::getInstance()->getObject($entity); @@ -116,7 +116,7 @@ public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = { $retrievedDependentObjects = []; foreach ($dependentObjectKeys as $objectKey) { - $retrievedDependentObjects = $this->retrieveEntity($objectKey, $scope); + $retrievedDependentObjects[] = $this->retrieveEntity($objectKey, $scope); } $originalEntity = $this->retrieveEntity($key, $scope); @@ -149,7 +149,7 @@ public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $sto { $retrievedDependentObjects = []; foreach ($dependentObjectKeys as $objectKey) { - $retrievedDependentObjects = $this->retrieveEntity($objectKey, $scope); + $retrievedDependentObjects[] = $this->retrieveEntity($objectKey, $scope); } $retrievedEntity = DataObjectHandler::getInstance()->getObject($entity); diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 7b5109237..5a02d6870 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -717,11 +717,11 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $createEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; $createEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $createEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; - if (!empty($requiredEntityKeysArray)) { - $createEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; - } + $createEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; if (count($customEntityFields) > 1) { $createEntityFunctionCall .= ",\n\t\t\t\${$stepKey}Fields"; + } else { + $createEntityFunctionCall .= ",\n\t\t\tnull"; } if ($storeCode !== null) { $createEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; @@ -808,9 +808,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $updateEntityFunctionCall .= "\n\t\t\t\"{$key}\","; $updateEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $updateEntityFunctionCall .= "\n\t\t\t\"{$updateEntity}\""; - if (!empty($requiredEntityKeysArray)) { - $updateEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; - } + $updateEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; if ($storeCode !== null) { $updateEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; } @@ -858,11 +856,11 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $getEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; $getEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $getEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; - if (!empty($requiredEntityKeysArray)) { - $getEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; - } + $getEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; if ($storeCode !== null) { $getEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; + } else { + $getEntityFunctionCall .= ",\n\t\t\tnull"; } if ($index !== null) { $getEntityFunctionCall .= ",\n\t\t\t{$index}"; From 9af66475d6d3e7d8b4990e5cd7a8fbcae1b6271c Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Fri, 17 Aug 2018 11:39:51 -0500 Subject: [PATCH 5/9] MQE-1123-DATAREFACTOR - Unit tests created - Update to all verification tests --- .../Handlers/PersistedObjectHandlerTest.php | 377 ++++++++++++++++++ .../ActionGroupContainsStepKeyInArgText.txt | 4 +- .../ActionGroupMergedViaInsertAfter.txt | 4 +- .../ActionGroupMergedViaInsertBefore.txt | 4 +- .../Resources/ActionGroupToExtend.txt | 4 +- .../Resources/ActionGroupUsingCreateData.txt | 24 +- .../ActionGroupUsingNestedArgument.txt | 4 +- .../ActionGroupWithDataOverrideTest.txt | 14 +- .../Resources/ActionGroupWithDataTest.txt | 14 +- ...hDefaultArgumentAndStringSelectorParam.txt | 4 +- ...eParameterSelectorsFromDefaultArgument.txt | 4 +- .../Resources/ActionGroupWithNoArguments.txt | 4 +- .../ActionGroupWithNoDefaultTest.txt | 14 +- ...thPassedArgumentAndStringSelectorParam.txt | 4 +- .../ActionGroupWithPersistedData.txt | 34 +- ...WithSimpleDataUsageFromDefaultArgument.txt | 4 +- ...pWithSimpleDataUsageFromPassedArgument.txt | 12 +- ...leParameterSelectorFromDefaultArgument.txt | 4 +- ...gleParameterSelectorFromPassedArgument.txt | 4 +- .../ActionGroupWithStepKeyReferences.txt | 16 +- .../ActionGroupWithTopLevelPersistedData.txt | 24 +- .../ArgumentWithSameNameAsElement.txt | 14 +- .../verification/Resources/AssertTest.txt | 46 ++- .../Resources/BasicActionGroupTest.txt | 14 +- .../Resources/BasicFunctionalTest.txt | 9 +- .../verification/Resources/BasicMergeTest.txt | 4 +- .../Resources/CharacterReplacementTest.txt | 4 +- .../Resources/ChildExtendedTestAddHooks.txt | 4 +- .../Resources/ChildExtendedTestMerging.txt | 4 +- .../Resources/ChildExtendedTestNoParent.txt | 4 +- .../ChildExtendedTestRemoveAction.txt | 4 +- .../ChildExtendedTestRemoveHookAction.txt | 4 +- .../Resources/ChildExtendedTestReplace.txt | 4 +- .../ChildExtendedTestReplaceHook.txt | 4 +- .../Resources/DataActionsTest.txt | 60 ++- .../Resources/DataReplacementTest.txt | 4 +- .../Resources/ExecuteJsEscapingTest.txt | 4 +- .../Resources/ExtendParentDataTest.txt | 14 +- .../Resources/ExtendedActionGroup.txt | 4 +- .../Resources/ExtendedParameterArrayTest.txt | 21 +- .../Resources/ExtendedRemoveActionGroup.txt | 4 +- .../Resources/ExtendingSkippedTest.txt | 4 +- .../Resources/HookActionsTest.txt | 44 +- .../Resources/LocatorFunctionTest.txt | 22 +- .../Resources/MergeMassViaInsertAfter.txt | 4 +- .../Resources/MergeMassViaInsertBefore.txt | 4 +- .../verification/Resources/MergeSkip.txt | 4 +- .../Resources/MergedActionGroupTest.txt | 14 +- .../Resources/MergedReferencesTest.txt | 4 +- .../Resources/MultipleActionGroupsTest.txt | 14 +- .../Resources/PageReplacementTest.txt | 20 +- .../Resources/ParameterArrayTest.txt | 24 +- .../Resources/ParentExtendedTest.txt | 4 +- .../PersistedAndXmlEntityArguments.txt | 6 +- .../Resources/PersistedReplacementTest.txt | 44 +- .../Resources/PersistenceCustomFieldsTest.txt | 78 ++-- .../Resources/SectionReplacementTest.txt | 30 +- .../verification/Resources/SkippedTest.txt | 4 +- .../Resources/SkippedTestNoIssues.txt | 4 +- .../Resources/SkippedTestTwoIssues.txt | 4 +- .../Resources/SkippedTestWithHooks.txt | 4 +- .../Resources/functionalSuiteHooks.txt | 14 +- .../Handlers/PersistedObjectHandler.php | 51 ++- .../Extension/TestContextExtension.php | 10 +- .../Util/TestGenerator.php | 102 ++++- 65 files changed, 909 insertions(+), 411 deletions(-) create mode 100644 dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php new file mode 100644 index 000000000..30dc3ec40 --- /dev/null +++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php @@ -0,0 +1,377 @@ + [ + 'EntityOne' => [ + 'type' => 'testType', + 'data' => [ + 0 => [ + 'key' => $dataKey, + 'value' => $dataValue + ] + ] + ] + ] + ]; + $jsonResponse = " + { + \"" . strtolower($dataKey) . "\" : \"{$dataValue}\" + } + "; + + // Mock Classes + $this->mockDataHandlerWithOutput($parserOutput); + $this->mockCurlHandler($jsonResponse); + $handler = PersistedObjectHandler::getInstance(); + + // Call method + $handler->createEntity( + $entityStepKey, + $scope, + $entityName + ); + + $persistedValue = $handler->retrieveEntityField($entityStepKey, $dataKey, $scope); + $this->assertEquals($dataValue, $persistedValue); + } + + public function testDeleteSimpleEntity() + { + // Test Data and Variables + $entityName = "EntityOne"; + $entityStepKey = "StepKey"; + $dataKey = "testKey"; + $dataValue = "testValue"; + $scope = PersistedObjectHandler::TEST_SCOPE; + $parserOutput = [ + 'entity' => [ + 'EntityOne' => [ + 'type' => 'testType', + 'data' => [ + 0 => [ + 'key' => $dataKey, + 'value' => $dataValue + ] + ] + ] + ] + ]; + $jsonResponse = " + { + \"" . strtolower($dataKey) . "\" : \"{$dataValue}\" + } + "; + + // Mock Classes + $this->mockDataHandlerWithOutput($parserOutput); + $this->mockCurlHandler($jsonResponse); + $handler = PersistedObjectHandler::getInstance(); + + // Call method + $handler->createEntity( + $entityStepKey, + $scope, + $entityName + ); + + $handler->deleteEntity( + $entityStepKey, + $scope + ); + + // Handler found and called Delete on existing entity + $this->addToAssertionCount(1); + } + + public function testGetSimpleEntity() + { + // Test Data and Variables + $entityName = "EntityOne"; + $entityStepKey = "StepKey"; + $dataKey = "testKey"; + $dataValue = "testValue"; + $scope = PersistedObjectHandler::TEST_SCOPE; + $parserOutput = [ + 'entity' => [ + 'EntityOne' => [ + 'type' => 'testType', + 'data' => [ + 0 => [ + 'key' => $dataKey, + 'value' => $dataValue + ] + ] + ] + ] + ]; + $jsonResponse = " + { + \"" . strtolower($dataKey) . "\" : \"{$dataValue}\" + } + "; + + // Mock Classes + $this->mockDataHandlerWithOutput($parserOutput); + $this->mockCurlHandler($jsonResponse); + $handler = PersistedObjectHandler::getInstance(); + + // Call method + $handler->getEntity( + $entityStepKey, + $scope, + $entityName + ); + + $persistedValue = $handler->retrieveEntityField($entityStepKey, $dataKey, $scope); + $this->assertEquals($dataValue, $persistedValue); + } + + public function testUpdateSimpleEntity() + { + $this->markTestSkipped("Potential Bug in DataPersistenceHandler class"); + // Test Data and Variables + $entityName = "EntityOne"; + $entityStepKey = "StepKey"; + $dataKey = "testKey"; + $dataValue = "testValue"; + $updateName = "EntityTwo"; + $updateValue = "newValue"; + $scope = PersistedObjectHandler::TEST_SCOPE; + $parserOutput = [ + 'entity' => [ + $entityName => [ + 'type' => 'testType', + 'data' => [ + 0 => [ + 'key' => $dataKey, + 'value' => $dataValue + ] + ] + ], + $updateName => [ + 'type' => 'testType', + 'data' => [ + 0 => [ + 'key' => $dataKey, + 'value' => $updateValue + ] + ] + ] + ] + ]; + $jsonResponse = " + { + \"" . strtolower($dataKey) . "\" : \"{$dataValue}\" + } + "; + $updatedResponse = " + { + \"" . strtolower($dataKey) . "\" : \"{$updateValue}\" + } + "; + + // Mock Classes + $this->mockDataHandlerWithOutput($parserOutput); + $this->mockCurlHandler($jsonResponse); + $handler = PersistedObjectHandler::getInstance(); + $handler->createEntity( + $entityStepKey, + $scope, + $entityName + ); + $this->mockCurlHandler($updatedResponse); + + // Call method + $handler->updateEntity( + $entityStepKey, + $scope, + $updateName + ); + + $persistedValue = $handler->retrieveEntityField($entityStepKey, $dataKey, $scope); + $this->assertEquals($updateValue, $persistedValue); + } + + public function testRetrieveEntityAcrossScopes() + { + // Test Data and Variables + $entityNameOne = "EntityOne"; + $entityStepKeyOne = "StepKeyOne"; + $dataKeyOne = "testKeyOne"; + $dataValueOne = "testValueOne"; + $entityNameTwo = "EntityTwo"; + $entityStepKeyTwo = "StepKeyTwo"; + $dataKeyTwo = "testKeyTwo"; + $dataValueTwo = "testValueTwo"; + $entityNameThree = "EntityThree"; + $entityStepKeyThree = "StepKeyThree"; + $dataKeyThree = "testKeyThree"; + $dataValueThree = "testValueThree"; + + $parserOutputOne = [ + 'entity' => [ + $entityNameOne => [ + 'type' => 'testType', + 'data' => [ + 0 => [ + 'key' => $dataKeyOne, + 'value' => $dataValueOne + ] + ] + ], + $entityNameTwo => [ + 'type' => 'testType', + 'data' => [ + 0 => [ + 'key' => $dataKeyTwo, + 'value' => $dataValueTwo + ] + ] + ], + $entityNameThree => [ + 'type' => 'testType', + 'data' => [ + 0 => [ + 'key' => $dataKeyThree, + 'value' => $dataValueThree + ] + ] + ] + ] + ]; + $jsonReponseOne = " + { + \"" . strtolower($dataKeyOne) . "\" : \"{$dataValueOne}\" + } + "; + $jsonReponseTwo = " + { + \"" . strtolower($dataKeyTwo) . "\" : \"{$dataValueTwo}\" + } + "; + $jsonReponseThree = " + { + \"" . strtolower($dataKeyThree) . "\" : \"{$dataValueThree}\" + } + "; + + // Mock Classes and Create Entities + $handler = PersistedObjectHandler::getInstance(); + + $this->mockDataHandlerWithOutput($parserOutputOne); + $this->mockCurlHandler($jsonReponseOne); + $handler->createEntity( + $entityStepKeyOne, + PersistedObjectHandler::TEST_SCOPE, + $entityNameOne + ); + + $this->mockCurlHandler($jsonReponseTwo); + $handler->createEntity( + $entityStepKeyTwo, + PersistedObjectHandler::HOOK_SCOPE, + $entityNameTwo + ); + + $this->mockCurlHandler($jsonReponseThree); + $handler->createEntity( + $entityStepKeyThree, + PersistedObjectHandler::SUITE_SCOPE, + $entityNameThree + ); + + // Call method + $retrievedFromTest = $handler->retrieveEntityField( + $entityStepKeyOne, + $dataKeyOne, + PersistedObjectHandler::HOOK_SCOPE + ); + $retrievedFromHook = $handler->retrieveEntityField( + $entityStepKeyTwo, + $dataKeyTwo, + PersistedObjectHandler::SUITE_SCOPE + ); + $retrievedFromSuite = $handler->retrieveEntityField( + $entityStepKeyThree, + $dataKeyThree, + PersistedObjectHandler::TEST_SCOPE + ); + + $this->assertEquals($dataValueOne, $retrievedFromTest); + $this->assertEquals($dataValueTwo, $retrievedFromHook); + $this->assertEquals($dataValueThree, $retrievedFromSuite); + } + + /** + * Mocks DataObjectHandler to use given output to create + * @param $parserOutput + * @throws \Exception + */ + public function mockDataHandlerWithOutput($parserOutput) + { + // Clear DataObjectHandler singleton if already set + $property = new \ReflectionProperty(DataObjectHandler::class, "INSTANCE"); + $property->setAccessible(true); + $property->setValue(null); + + $mockDataProfileSchemaParser = AspectMock::double(DataProfileSchemaParser::class, [ + 'readDataProfiles' => $parserOutput + ])->make(); + + $mockObjectManager = AspectMock::double(ObjectManager::class, [ + 'create' => $mockDataProfileSchemaParser + ])->make(); + + AspectMock::double(ObjectManagerFactory::class, [ + 'getObjectManager' => $mockObjectManager + ]); + } + + public function mockCurlHandler($response) + { + AspectMock::double(CurlHandler::class, [ + "__construct" => null, + "executeRequest" => $response, + "getRequestDataArray" => [], + "isContentTypeJson" => true + ]); + } + + public function tearDown() + { + // Clear out Singleton between tests + $property = new \ReflectionProperty(PersistedObjectHandler::class, "INSTANCE"); + $property->setAccessible(true); + $property->setValue(null); + + parent::tearDown(); // TODO: Change the autogenerated stub + } +} diff --git a/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt b/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt index 60b645cfa..8d33003af 100644 --- a/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt +++ b/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt index ddee76f82..2c2536136 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt index 4121a6d48..110ce3059 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupToExtend.txt b/dev/tests/verification/Resources/ActionGroupToExtend.txt index fb8a9fd60..7c7e666cd 100644 --- a/dev/tests/verification/Resources/ActionGroupToExtend.txt +++ b/dev/tests/verification/Resources/ActionGroupToExtend.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt index 41953aa3f..3c291ba24 100644 --- a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt +++ b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -37,13 +35,21 @@ class ActionGroupUsingCreateDataCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createCategoryKey1"); - $ApiCategory = DataObjectHandler::getInstance()->getObject("ApiCategory"); - $this->createCategoryKey1 = new DataPersistenceHandler($ApiCategory, []); - $this->createCategoryKey1->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createCategoryKey1", + "hook", + "ApiCategory", + [], + null + ); $I->amGoingTo("create entity that has the stepKey: createConfigProductKey1"); - $ApiConfigurableProduct = DataObjectHandler::getInstance()->getObject("ApiConfigurableProduct"); - $this->createConfigProductKey1 = new DataPersistenceHandler($ApiConfigurableProduct, [$this->createCategoryKey1]); - $this->createConfigProductKey1->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createConfigProductKey1", + "hook", + "ApiConfigurableProduct", + ["createCategoryKey1"], + null + ); } /** diff --git a/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt b/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt index 674de1afc..2d435b051 100644 --- a/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt index 6815d318b..cc4701264 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class ActionGroupWithDataOverrideTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } diff --git a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt index e4b79cf73..d981068f5 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class ActionGroupWithDataTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } diff --git a/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt b/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt index 79c95b0df..115ed73f3 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt index 620bbf5f5..495af8666 100644 --- a/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt b/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt index b0f709ac9..ed8323423 100644 --- a/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt +++ b/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt index a5119c368..b65668460 100644 --- a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class ActionGroupWithNoDefaultTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } diff --git a/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt b/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt index 33d3d3d13..fd5e72c3f 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt index 133553573..ecff3ffc9 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class ActionGroupWithPersistedDataCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } @@ -71,13 +73,17 @@ class ActionGroupWithPersistedDataCest public function ActionGroupWithPersistedData(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPerson"); - $DefaultPerson = DataObjectHandler::getInstance()->getObject("DefaultPerson"); - $createPerson = new DataPersistenceHandler($DefaultPerson, []); - $createPerson->createEntity(); - $I->amOnPage("/" . $createPerson->getCreatedDataByName('firstname') . "/" . $createPerson->getCreatedDataByName('lastname') . ".html"); - $I->fillField("#foo", $createPerson->getCreatedDataByName('firstname')); - $I->fillField("#bar", $createPerson->getCreatedDataByName('lastname')); - $I->searchAndMultiSelectOption("#foo", [$createPerson->getCreatedDataByName('firstname'), $createPerson->getCreatedDataByName('lastname')]); - $I->see("#element ." . $createPerson->getCreatedDataByName('firstname')); + PersistedObjectHandler::getInstance()->createEntity( + "createPerson", + "test", + "DefaultPerson", + [], + null + ); + $I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'firstname', 'test') . "/" . PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'lastname', 'test') . ".html"); + $I->fillField("#foo", PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'firstname', 'test')); + $I->fillField("#bar", PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'lastname', 'test')); + $I->searchAndMultiSelectOption("#foo", [PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'lastname', 'test')]); + $I->see("#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'firstname', 'test')); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt index b5c871a0d..6ab432bf2 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt index d3b910c0a..46ce55e62 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -36,10 +34,10 @@ class ActionGroupWithSimpleDataUsageFromPassedArgumentCest $I->see("1.5", "#element .1.5"); $I->see("true", "#element .true"); $I->see("simpleData.firstname", "#element .simpleData.firstname"); - $I->see($persisted->getCreatedDataByName('data'), "#element ." . $persisted->getCreatedDataByName('data')); + $I->see(PersistedObjectHandler::getInstance()->retrieveEntityField('persisted', 'data', 'test'), "#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('persisted', 'data', 'test')); $I->see("John", "#element .John"); - $I->see($simpleData->getCreatedDataByName('firstname'), "#element ." . $simpleData->getCreatedDataByName('firstname')); - $I->see($simpleData->getCreatedDataByName('firstname[0]'), "#element ." . $simpleData->getCreatedDataByName('firstname[0]')); - $I->see($simpleData->getCreatedDataByName('firstname[data_index]'), "#element ." . $simpleData->getCreatedDataByName('firstname[data_index]')); + $I->see(PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname', 'test'), "#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname', 'test')); + $I->see(PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname[0]', 'test'), "#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname[0]', 'test')); + $I->see(PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname[data_index]', 'test'), "#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname[data_index]', 'test')); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt index 027370779..e4eabcb07 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt index 7900385db..aa8b3d3d2 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt index 28bb00d4d..f8be7d914 100644 --- a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -30,10 +28,14 @@ class ActionGroupWithStepKeyReferencesCest public function ActionGroupWithStepKeyReferences(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createSimpleDataActionGroup"); - $simpleData = DataObjectHandler::getInstance()->getObject("simpleData"); - $createSimpleDataActionGroup = new DataPersistenceHandler($simpleData, []); - $createSimpleDataActionGroup->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createSimpleDataActionGroup", + "test", + "simpleData", + [], + null + ); $grabTextDataActionGroup = $I->grabTextFrom(".class"); - $I->fillField(".{$grabTextDataActionGroup}", $createSimpleDataActionGroup->getCreatedDataByName('field')); + $I->fillField(".{$grabTextDataActionGroup}", PersistedObjectHandler::getInstance()->retrieveEntityField('createSimpleData', 'field', 'test')); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt index 4ec6520d9..b4217e188 100644 --- a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class ActionGroupWithTopLevelPersistedDataCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } @@ -70,10 +72,10 @@ class ActionGroupWithTopLevelPersistedDataCest */ public function ActionGroupWithTopLevelPersistedData(AcceptanceTester $I) { - $I->amOnPage("/" . $this->createPersonParam->getCreatedDataByName('firstname') . "/" . $this->createPersonParam->getCreatedDataByName('lastname') . ".html"); - $I->fillField("#foo", $this->createPersonParam->getCreatedDataByName('firstname')); - $I->fillField("#bar", $this->createPersonParam->getCreatedDataByName('lastname')); - $I->searchAndMultiSelectOption("#foo", [$this->createPersonParam->getCreatedDataByName('firstname'), $this->createPersonParam->getCreatedDataByName('lastname')]); - $I->see("#element ." . $this->createPersonParam->getCreatedDataByName('firstname')); + $I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'firstname', 'test') . "/" . PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'lastname', 'test') . ".html"); + $I->fillField("#foo", PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'firstname', 'test')); + $I->fillField("#bar", PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'lastname', 'test')); + $I->searchAndMultiSelectOption("#foo", [PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'lastname', 'test')]); + $I->see("#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'firstname', 'test')); } } diff --git a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt index a97fd116e..7766d0dd8 100644 --- a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt +++ b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class ArgumentWithSameNameAsElementCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } diff --git a/dev/tests/verification/Resources/AssertTest.txt b/dev/tests/verification/Resources/AssertTest.txt index beb78eed1..a4e484d55 100644 --- a/dev/tests/verification/Resources/AssertTest.txt +++ b/dev/tests/verification/Resources/AssertTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -32,9 +30,13 @@ class AssertTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createData1"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createData1 = new DataPersistenceHandler($ReplacementPerson, []); - $this->createData1->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createData1", + "hook", + "ReplacementPerson", + [], + null + ); } /** @@ -47,9 +49,13 @@ class AssertTestCest public function AssertTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createData2"); - $UniquePerson = DataObjectHandler::getInstance()->getObject("UniquePerson"); - $createData2 = new DataPersistenceHandler($UniquePerson, []); - $createData2->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createData2", + "test", + "UniquePerson", + [], + null + ); $grabTextFrom1 = $I->grabTextFrom(".copyright>span"); $I->assertArrayIsSorted(["1", "2", "3", "4", "5"], "asc"); $I->comment("asserts without variable replacement"); @@ -130,14 +136,14 @@ class AssertTestCest $I->assertNull($text, "pass"); $I->expectException(new MyException('exception msg'), function() {$this->doSomethingBad();}); $I->comment("string type that use created data"); - $I->assertStringStartsWith("D", $this->createData1->getCreatedDataByName('lastname') . ", " . $this->createData1->getCreatedDataByName('firstname'), "fail"); - $I->assertStringStartsNotWith("W", $createData2->getCreatedDataByName('firstname') . ", " . $createData2->getCreatedDataByName('lastname'), "pass"); - $I->assertEquals($this->createData1->getCreatedDataByName('lastname'), $this->createData1->getCreatedDataByName('lastname'), "pass"); + $I->assertStringStartsWith("D", PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test') . ", " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test'), "fail"); + $I->assertStringStartsNotWith("W", PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test') . ", " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'lastname', 'test'), "pass"); + $I->assertEquals(PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test'), "pass"); $I->comment("array type that use created data"); - $I->assertArraySubset([$this->createData1->getCreatedDataByName('lastname'), $this->createData1->getCreatedDataByName('firstname')], [$this->createData1->getCreatedDataByName('lastname'), $this->createData1->getCreatedDataByName('firstname'), "1"], "pass"); - $I->assertArraySubset([$createData2->getCreatedDataByName('firstname'), $createData2->getCreatedDataByName('lastname')], [$createData2->getCreatedDataByName('firstname'), $createData2->getCreatedDataByName('lastname'), "1"], "pass"); - $I->assertArrayHasKey("lastname", ['lastname' => $this->createData1->getCreatedDataByName('lastname'), 'firstname' => $this->createData1->getCreatedDataByName('firstname')], "pass"); - $I->assertArrayHasKey("lastname", ['lastname' => $createData2->getCreatedDataByName('lastname'), 'firstname' => $createData2->getCreatedDataByName('firstname')], "pass"); + $I->assertArraySubset([PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test')], [PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test'), "1"], "pass"); + $I->assertArraySubset([PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'lastname', 'test')], [PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'lastname', 'test'), "1"], "pass"); + $I->assertArrayHasKey("lastname", ['lastname' => PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test'), 'firstname' => PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test')], "pass"); + $I->assertArrayHasKey("lastname", ['lastname' => PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'lastname', 'test'), 'firstname' => PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test')], "pass"); $I->assertInstanceOf(User::class, $text, "pass"); $I->assertNotInstanceOf(User::class, 21, "pass"); $I->assertFileExists($text, "pass"); @@ -146,16 +152,16 @@ class AssertTestCest $I->assertNull($text, "pass"); $I->expectException(new MyException('exception msg'), function() {$this->doSomethingBad();}); $I->fail("fail"); - $I->fail($createData2->getCreatedDataByName('firstname') . " " . $createData2->getCreatedDataByName('lastname')); - $I->fail($this->createData1->getCreatedDataByName('firstname') . " " . $this->createData1->getCreatedDataByName('lastname')); + $I->fail(PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test') . " " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'lastname', 'test')); + $I->fail(PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test') . " " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test')); $I->assertElementContainsAttribute("#username", "class", "admin__control-text"); $I->assertElementContainsAttribute("#username", "name", "login[username]"); $I->assertElementContainsAttribute("#username", "autofocus", "true"); $I->assertElementContainsAttribute("#username", "data-validate", "{required:true}"); $I->assertElementContainsAttribute(".admin__menu-overlay", "style", "display: none;"); $I->assertElementContainsAttribute(".admin__menu-overlay", "border", "0"); - $I->assertElementContainsAttribute("#username", "value", $createData2->getCreatedDataByName('firstname')); - $I->assertElementContainsAttribute("#username", "value", $this->createData1->getCreatedDataByName('firstname')); + $I->assertElementContainsAttribute("#username", "value", PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test')); + $I->assertElementContainsAttribute("#username", "value", PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test')); $I->assertEquals("John", "Doe", "pass"); } } diff --git a/dev/tests/verification/Resources/BasicActionGroupTest.txt b/dev/tests/verification/Resources/BasicActionGroupTest.txt index b8b491ef4..83932cf33 100644 --- a/dev/tests/verification/Resources/BasicActionGroupTest.txt +++ b/dev/tests/verification/Resources/BasicActionGroupTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class BasicActionGroupTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index 9ef07a67e..6f4ce072f 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -77,7 +75,10 @@ class BasicFunctionalTestCest $I->closeTab(); $I->conditionalClick(".functionalTestSelector", ".functionalDependentTestSelector", true); $I->amGoingTo("delete entity that has the createDataKey: createKey1"); - $this->createKey1->deleteEntity(); + PersistedObjectHandler::getInstance()->deleteEntity( + "createKey1", + "test" + ); $I->deleteEntityByUrl("/V1/categories{$grabbedData}"); $I->dontSee("someInput", ".functionalTestSelector"); $I->dontSeeCheckboxIsChecked(".functionalTestSelector"); diff --git a/dev/tests/verification/Resources/BasicMergeTest.txt b/dev/tests/verification/Resources/BasicMergeTest.txt index 280630b6f..c77017cbc 100644 --- a/dev/tests/verification/Resources/BasicMergeTest.txt +++ b/dev/tests/verification/Resources/BasicMergeTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/CharacterReplacementTest.txt b/dev/tests/verification/Resources/CharacterReplacementTest.txt index 844b08974..c1fddf69b 100644 --- a/dev/tests/verification/Resources/CharacterReplacementTest.txt +++ b/dev/tests/verification/Resources/CharacterReplacementTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt b/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt index d8417f5cb..de328c399 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestMerging.txt b/dev/tests/verification/Resources/ChildExtendedTestMerging.txt index caf382718..388d584e6 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestMerging.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestMerging.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt b/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt index 3ab774b3d..5efddc379 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt b/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt index 4fefcd657..9c64b2f7b 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt b/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt index 5f135c6d7..96d39be2d 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestReplace.txt b/dev/tests/verification/Resources/ChildExtendedTestReplace.txt index 650544131..3e3b6ee58 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestReplace.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestReplace.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt b/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt index 9c05eb88e..bf4d31020 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/DataActionsTest.txt b/dev/tests/verification/Resources/DataActionsTest.txt index 969973317..9eb68c94c 100644 --- a/dev/tests/verification/Resources/DataActionsTest.txt +++ b/dev/tests/verification/Resources/DataActionsTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -37,13 +35,25 @@ class DataActionsTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createdInBefore"); - $entity = DataObjectHandler::getInstance()->getObject("entity"); - $this->createdInBefore = new DataPersistenceHandler($entity, []); - $this->createdInBefore->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createdInBefore", + "hook", + "entity", + [], + null + ); $I->amGoingTo("update entity that has the createdDataKey: createdInBefore"); - $this->createdInBefore->updateEntity("entity"); + PersistedObjectHandler::getInstance()->updateEntity( + "createdInBefore", + "hook", + "entity", + [] + ); $I->amGoingTo("delete entity that has the createDataKey: createdInBefore"); - $this->createdInBefore->deleteEntity(); + PersistedObjectHandler::getInstance()->deleteEntity( + "createdInBefore", + "hook" + ); } /** @@ -56,16 +66,36 @@ class DataActionsTestCest public function DataActionsTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createdInTest"); - $entity = DataObjectHandler::getInstance()->getObject("entity"); - $createdInTest = new DataPersistenceHandler($entity, []); - $createdInTest->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createdInTest", + "test", + "entity", + [], + null + ); $I->amGoingTo("update entity that has the createdDataKey: createdInTest"); - $createdInTest->updateEntity("entity"); + PersistedObjectHandler::getInstance()->updateEntity( + "createdInTest", + "test", + "entity", + [] + ); $I->amGoingTo("delete entity that has the createDataKey: createdInTest"); - $createdInTest->deleteEntity(); + PersistedObjectHandler::getInstance()->deleteEntity( + "createdInTest", + "test" + ); $I->amGoingTo("update entity that has the createdDataKey: createdInBefore"); - $this->createdInBefore->updateEntity("entity"); + PersistedObjectHandler::getInstance()->updateEntity( + "createdInBefore", + "test", + "entity", + [] + ); $I->amGoingTo("delete entity that has the createDataKey: createdInBefore"); - $this->createdInBefore->deleteEntity(); + PersistedObjectHandler::getInstance()->deleteEntity( + "createdInBefore", + "test" + ); } } diff --git a/dev/tests/verification/Resources/DataReplacementTest.txt b/dev/tests/verification/Resources/DataReplacementTest.txt index 8a95eb1e8..60dd2faae 100644 --- a/dev/tests/verification/Resources/DataReplacementTest.txt +++ b/dev/tests/verification/Resources/DataReplacementTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt index 94dc2cbdb..035d33bc3 100644 --- a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt +++ b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ExtendParentDataTest.txt b/dev/tests/verification/Resources/ExtendParentDataTest.txt index a681733f0..41bea9d6f 100644 --- a/dev/tests/verification/Resources/ExtendParentDataTest.txt +++ b/dev/tests/verification/Resources/ExtendParentDataTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -30,9 +28,13 @@ class ExtendParentDataTestCest public function ExtendParentDataTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: simpleDataKey"); - $extendParentData = DataObjectHandler::getInstance()->getObject("extendParentData"); - $simpleDataKey = new DataPersistenceHandler($extendParentData, []); - $simpleDataKey->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "simpleDataKey", + "test", + "extendParentData", + [], + null + ); $I->searchAndMultiSelectOption("#selector", ["otherName"]); $I->searchAndMultiSelectOption("#selector", ["extendName"]); $I->searchAndMultiSelectOption("#selector", ["item"]); diff --git a/dev/tests/verification/Resources/ExtendedActionGroup.txt b/dev/tests/verification/Resources/ExtendedActionGroup.txt index 93acc8910..48fa542bc 100644 --- a/dev/tests/verification/Resources/ExtendedActionGroup.txt +++ b/dev/tests/verification/Resources/ExtendedActionGroup.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt b/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt index afdbdec3e..41bea9d6f 100644 --- a/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt +++ b/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -18,7 +16,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** */ -class ExtendedParameterArrayTestCest +class ExtendParentDataTestCest { /** * @Features({"TestModule"}) @@ -27,13 +25,20 @@ class ExtendedParameterArrayTestCest * @return void * @throws \Exception */ - public function ExtendedParameterArrayTest(AcceptanceTester $I) + public function ExtendParentDataTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: simpleDataKey"); - $testExtendSimpleParamData = DataObjectHandler::getInstance()->getObject("testExtendSimpleParamData"); - $simpleDataKey = new DataPersistenceHandler($testExtendSimpleParamData, []); - $simpleDataKey->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "simpleDataKey", + "test", + "extendParentData", + [], + null + ); $I->searchAndMultiSelectOption("#selector", ["otherName"]); $I->searchAndMultiSelectOption("#selector", ["extendName"]); + $I->searchAndMultiSelectOption("#selector", ["item"]); + $I->searchAndMultiSelectOption("#selector", [msq("extendParentData") . "prename"]); + $I->searchAndMultiSelectOption("#selector", ["postnameExtend" . msq("extendParentData")]); } } diff --git a/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt b/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt index 2bfd08a91..936e78721 100644 --- a/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt +++ b/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ExtendingSkippedTest.txt b/dev/tests/verification/Resources/ExtendingSkippedTest.txt index 35cd3a825..b1f6bf648 100644 --- a/dev/tests/verification/Resources/ExtendingSkippedTest.txt +++ b/dev/tests/verification/Resources/ExtendingSkippedTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/HookActionsTest.txt b/dev/tests/verification/Resources/HookActionsTest.txt index 76947ce61..8ce4ad320 100644 --- a/dev/tests/verification/Resources/HookActionsTest.txt +++ b/dev/tests/verification/Resources/HookActionsTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -37,15 +35,26 @@ class HookActionsTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: sampleCreateBefore"); - $sampleCreatedEntity = DataObjectHandler::getInstance()->getObject("sampleCreatedEntity"); - $this->sampleCreateBefore = new DataPersistenceHandler($sampleCreatedEntity, []); - $this->sampleCreateBefore->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "sampleCreateBefore", + "hook", + "sampleCreatedEntity", + [], + null + ); $I->amGoingTo("delete entity that has the createDataKey: sampleCreateBefore"); - $this->sampleCreateBefore->deleteEntity(); + PersistedObjectHandler::getInstance()->deleteEntity( + "sampleCreateBefore", + "hook" + ); $I->amGoingTo("create entity that has the stepKey: sampleCreateForAfter"); - $sampleCreatedEntity = DataObjectHandler::getInstance()->getObject("sampleCreatedEntity"); - $this->sampleCreateForAfter = new DataPersistenceHandler($sampleCreatedEntity, []); - $this->sampleCreateForAfter->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "sampleCreateForAfter", + "hook", + "sampleCreatedEntity", + [], + null + ); } /** @@ -60,11 +69,18 @@ class HookActionsTestCest public function _after(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: sampleCreateAfter"); - $sampleCreatedEntity = DataObjectHandler::getInstance()->getObject("sampleCreatedEntity"); - $this->sampleCreateAfter = new DataPersistenceHandler($sampleCreatedEntity, []); - $this->sampleCreateAfter->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "sampleCreateAfter", + "hook", + "sampleCreatedEntity", + [], + null + ); $I->amGoingTo("delete entity that has the createDataKey: sampleCreateForAfter"); - $this->sampleCreateForAfter->deleteEntity(); + PersistedObjectHandler::getInstance()->deleteEntity( + "sampleCreateForAfter", + "hook" + ); } /** diff --git a/dev/tests/verification/Resources/LocatorFunctionTest.txt b/dev/tests/verification/Resources/LocatorFunctionTest.txt index b9423d1b5..bde511aac 100644 --- a/dev/tests/verification/Resources/LocatorFunctionTest.txt +++ b/dev/tests/verification/Resources/LocatorFunctionTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -30,20 +28,24 @@ class LocatorFunctionTestCest public function LocatorFunctionTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: data"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $data = new DataPersistenceHandler($ReplacementPerson, []); - $data->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "data", + "test", + "ReplacementPerson", + [], + null + ); $I->click(Locator::contains("'label'", "'Name'")); $I->click(Locator::contains("'label'", "'Name'")); $I->click(Locator::find("'img'", ['title' => 'diagram'])); $I->click(Locator::contains("string", "'Name'")); $I->click(Locator::contains("John", "'Name'")); - $I->click(Locator::contains($data->getCreatedDataByName('key'), "'Name'")); + $I->click(Locator::contains(PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key', 'test'), "'Name'")); $I->click(Locator::contains("string1", "string2")); $I->click(Locator::contains("John", "Doe")); - $I->click(Locator::contains($data->getCreatedDataByName('key1'), $data->getCreatedDataByName('key2'))); + $I->click(Locator::contains(PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key2', 'test'))); $I->click(Locator::contains("string1", "John")); - $I->click(Locator::contains("string1", $data->getCreatedDataByName('key1'))); - $I->click(Locator::contains("John", $data->getCreatedDataByName('key1'))); + $I->click(Locator::contains("string1", PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test'))); + $I->click(Locator::contains("John", PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test'))); } } diff --git a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt index ddfa5da12..5c5091566 100644 --- a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt +++ b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt index 82e2c4d6d..94982ec21 100644 --- a/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt +++ b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/MergeSkip.txt b/dev/tests/verification/Resources/MergeSkip.txt index d6ecff5db..878fe6497 100644 --- a/dev/tests/verification/Resources/MergeSkip.txt +++ b/dev/tests/verification/Resources/MergeSkip.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/MergedActionGroupTest.txt b/dev/tests/verification/Resources/MergedActionGroupTest.txt index 7862b0036..0be121125 100644 --- a/dev/tests/verification/Resources/MergedActionGroupTest.txt +++ b/dev/tests/verification/Resources/MergedActionGroupTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class MergedActionGroupTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } diff --git a/dev/tests/verification/Resources/MergedReferencesTest.txt b/dev/tests/verification/Resources/MergedReferencesTest.txt index 39111ad40..932229df9 100644 --- a/dev/tests/verification/Resources/MergedReferencesTest.txt +++ b/dev/tests/verification/Resources/MergedReferencesTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt index 1b5a74c94..7548aa79a 100644 --- a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt +++ b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -33,9 +31,13 @@ class MultipleActionGroupsTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createPersonParam"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createPersonParam = new DataPersistenceHandler($ReplacementPerson, []); - $this->createPersonParam->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createPersonParam", + "hook", + "ReplacementPerson", + [], + null + ); $I->fillField("#foo", "myData1"); $I->fillField("#bar", "myData2"); } diff --git a/dev/tests/verification/Resources/PageReplacementTest.txt b/dev/tests/verification/Resources/PageReplacementTest.txt index 1422a24ba..01ddedf78 100644 --- a/dev/tests/verification/Resources/PageReplacementTest.txt +++ b/dev/tests/verification/Resources/PageReplacementTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -30,17 +28,21 @@ class PageReplacementTestCest public function PageReplacementTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: datakey"); - $simpleData = DataObjectHandler::getInstance()->getObject("simpleData"); - $datakey = new DataPersistenceHandler($simpleData, []); - $datakey->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "datakey", + "test", + "simpleData", + [], + null + ); $I->amOnPage("/page.html"); $I->amOnPage("/StringLiteral/page.html"); $I->amOnPage("/John/page.html"); - $I->amOnPage("/" . $datakey->getCreatedDataByName('firstname') . "/page.html"); + $I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . "/page.html"); $I->amOnPage("/StringLiteral1/StringLiteral2.html"); $I->amOnPage("/John/StringLiteral2.html"); - $I->amOnPage("/John/" . $datakey->getCreatedDataByName('firstname') . ".html"); - $I->amOnPage("/" . $datakey->getCreatedDataByName('firstname') . "/StringLiteral2.html"); + $I->amOnPage("/John/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . ".html"); + $I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . "/StringLiteral2.html"); $I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/backend"); $I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/StringLiteral/page.html"); $I->amOnUrl("http://myFullUrl.com/"); diff --git a/dev/tests/verification/Resources/ParameterArrayTest.txt b/dev/tests/verification/Resources/ParameterArrayTest.txt index 4b56eb15c..5564bddac 100644 --- a/dev/tests/verification/Resources/ParameterArrayTest.txt +++ b/dev/tests/verification/Resources/ParameterArrayTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -30,15 +28,19 @@ class ParameterArrayTestCest public function ParameterArrayTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: simpleDataKey"); - $simpleParamData = DataObjectHandler::getInstance()->getObject("simpleParamData"); - $simpleDataKey = new DataPersistenceHandler($simpleParamData, []); - $simpleDataKey->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "simpleDataKey", + "test", + "simpleParamData", + [], + null + ); $I->searchAndMultiSelectOption("#selector", ["name"]); $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", [PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); + $I->searchAndMultiSelectOption("#selector", ["name", PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); + $I->searchAndMultiSelectOption("#selector", ['someKey' => PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); $I->searchAndMultiSelectOption("#selector", ['someKey' => "name"]); $I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData") . "prename"]); $I->searchAndMultiSelectOption("#selector", ['someKey' => "postname" . msq("simpleParamData")]); @@ -47,7 +49,7 @@ class ParameterArrayTestCest $I->unselectOption("#selector", ["name"]); $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')]); + $I->unselectOption("#selector", [PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); + $I->unselectOption("#selector", ["name", PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); } } diff --git a/dev/tests/verification/Resources/ParentExtendedTest.txt b/dev/tests/verification/Resources/ParentExtendedTest.txt index a8e74e493..8d7c11319 100644 --- a/dev/tests/verification/Resources/ParentExtendedTest.txt +++ b/dev/tests/verification/Resources/ParentExtendedTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt b/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt index 8ff0d58bd..02d371571 100644 --- a/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt +++ b/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -29,6 +27,6 @@ class PersistedAndXmlEntityArgumentsCest */ public function PersistedAndXmlEntityArguments(AcceptanceTester $I) { - $I->seeInCurrentUrl("/" . $persistedInTest->getCreatedDataByName('urlKey') . ".html?___store=" . msq("uniqueData") . "John"); + $I->seeInCurrentUrl("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('persistedInTest', 'urlKey', 'test') . ".html?___store=" . msq("uniqueData") . "John"); } } diff --git a/dev/tests/verification/Resources/PersistedReplacementTest.txt b/dev/tests/verification/Resources/PersistedReplacementTest.txt index 78cdd5029..baa627e5e 100644 --- a/dev/tests/verification/Resources/PersistedReplacementTest.txt +++ b/dev/tests/verification/Resources/PersistedReplacementTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -32,9 +30,13 @@ class PersistedReplacementTestCest public function _before(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createData1"); - $ReplacementPerson = DataObjectHandler::getInstance()->getObject("ReplacementPerson"); - $this->createData1 = new DataPersistenceHandler($ReplacementPerson, []); - $this->createData1->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createData1", + "hook", + "ReplacementPerson", + [], + null + ); } /** @@ -47,18 +49,22 @@ class PersistedReplacementTestCest public function PersistedReplacementTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: createdData"); - $simpleData = DataObjectHandler::getInstance()->getObject("simpleData"); - $createdData = new DataPersistenceHandler($simpleData, []); - $createdData->createEntity(); - $I->fillField("#selector", "StringBefore " . $createdData->getCreatedDataByName('firstname') . " StringAfter"); - $I->fillField("#" . $createdData->getCreatedDataByName('firstname'), "input"); - $I->fillField("#" . getenv("MAGENTO_BASE_URL") . "#" . $createdData->getCreatedDataByName('firstname'), "input"); - $I->fillSecretField("#" . CredentialStore::getInstance()->getSecret("SECRET_PARAM") . "#" . $createdData->getCreatedDataByName('firstname'), "input"); - $I->dragAndDrop("#" . $createdData->getCreatedDataByName('firstname'), $createdData->getCreatedDataByName('lastname')); - $I->conditionalClick($createdData->getCreatedDataByName('lastname'), "#" . $createdData->getCreatedDataByName('firstname'), true); - $I->amOnUrl($createdData->getCreatedDataByName('firstname') . ".html"); - $I->searchAndMultiSelectOption("#selector", [$createdData->getCreatedDataByName('firstname'), $createdData->getCreatedDataByName('lastname')]); - $I->fillField("#selector", "John " . $createdData->getCreatedDataByName('firstname') . " stringLiteral"); - $I->searchAndMultiSelectOption("#selector", [$createdData->getCreatedDataByName('firstname'), "John", "stringLiteral"]); + PersistedObjectHandler::getInstance()->createEntity( + "createdData", + "test", + "simpleData", + [], + null + ); + $I->fillField("#selector", "StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); + $I->fillField("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), "input"); + $I->fillField("#" . getenv("MAGENTO_BASE_URL") . "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), "input"); + $I->fillSecretField("#" . CredentialStore::getInstance()->getSecret("SECRET_PARAM") . "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), "input"); + $I->dragAndDrop("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'lastname', 'test')); + $I->conditionalClick(PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'lastname', 'test'), "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), true); + $I->amOnUrl(PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . ".html"); + $I->searchAndMultiSelectOption("#selector", [PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'lastname', 'test')]); + $I->fillField("#selector", "John " . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " stringLiteral"); + $I->searchAndMultiSelectOption("#selector", [PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), "John", "stringLiteral"]); } } diff --git a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt index eb9f2d234..a4e24c5bc 100644 --- a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt +++ b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -39,14 +37,22 @@ class PersistenceCustomFieldsTestCest $createData1Fields['firstname'] = "Mac"; $createData1Fields['lastname'] = "Doe"; $I->amGoingTo("create entity that has the stepKey: createData1"); - $DefaultPerson = DataObjectHandler::getInstance()->getObject("DefaultPerson"); - $this->createData1 = new DataPersistenceHandler($DefaultPerson, [], $createData1Fields); - $this->createData1->createEntity(); - $createData2Fields['firstname'] = $this->createData1->getCreatedDataByName('firstname'); + PersistedObjectHandler::getInstance()->createEntity( + "createData1", + "hook", + "DefaultPerson", + [], + $createData1Fields + ); + $createData2Fields['firstname'] = PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'hook'); $I->amGoingTo("create entity that has the stepKey: createData2"); - $uniqueData = DataObjectHandler::getInstance()->getObject("uniqueData"); - $this->createData2 = new DataPersistenceHandler($uniqueData, [$this->createData1], $createData2Fields); - $this->createData2->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createData2", + "hook", + "uniqueData", + ["createData1"], + $createData2Fields + ); } /** @@ -61,29 +67,49 @@ class PersistenceCustomFieldsTestCest $createdDataFields['favoriteIndex'] = "1"; $createdDataFields['middlename'] = "Kovacs"; $I->amGoingTo("create entity that has the stepKey: createdData"); - $simpleData = DataObjectHandler::getInstance()->getObject("simpleData"); - $createdData = new DataPersistenceHandler($simpleData, [], $createdDataFields); - $createdData->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createdData", + "test", + "simpleData", + [], + $createdDataFields + ); $createdData3Fields['firstname'] = "Takeshi"; $createdData3Fields['lastname'] = "Kovacs"; $I->amGoingTo("create entity that has the stepKey: createdData3"); - $UniquePerson = DataObjectHandler::getInstance()->getObject("UniquePerson"); - $createdData3 = new DataPersistenceHandler($UniquePerson, [$createdData], $createdData3Fields); - $createdData3->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createdData3", + "test", + "UniquePerson", + ["createdData"], + $createdData3Fields + ); $createDataAG1CreatedAGFields['firstname'] = "string1"; $I->amGoingTo("create entity that has the stepKey: createDataAG1CreatedAG"); - $simpleData = DataObjectHandler::getInstance()->getObject("simpleData"); - $createDataAG1CreatedAG = new DataPersistenceHandler($simpleData, [], $createDataAG1CreatedAGFields); - $createDataAG1CreatedAG->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createDataAG1CreatedAG", + "test", + "simpleData", + [], + $createDataAG1CreatedAGFields + ); $createDataAG2CreatedAGFields['firstname'] = "Jane"; $I->amGoingTo("create entity that has the stepKey: createDataAG2CreatedAG"); - $simpleData = DataObjectHandler::getInstance()->getObject("simpleData"); - $createDataAG2CreatedAG = new DataPersistenceHandler($simpleData, [], $createDataAG2CreatedAGFields); - $createDataAG2CreatedAG->createEntity(); - $createDataAG3CreatedAGFields['firstname'] = $createdData3->getCreatedDataByName('firstname'); + PersistedObjectHandler::getInstance()->createEntity( + "createDataAG2CreatedAG", + "test", + "simpleData", + [], + $createDataAG2CreatedAGFields + ); + $createDataAG3CreatedAGFields['firstname'] = PersistedObjectHandler::getInstance()->retrieveEntityField('createdData3', 'firstname', 'test'); $I->amGoingTo("create entity that has the stepKey: createDataAG3CreatedAG"); - $simpleData = DataObjectHandler::getInstance()->getObject("simpleData"); - $createDataAG3CreatedAG = new DataPersistenceHandler($simpleData, [], $createDataAG3CreatedAGFields); - $createDataAG3CreatedAG->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "createDataAG3CreatedAG", + "test", + "simpleData", + [], + $createDataAG3CreatedAGFields + ); } } diff --git a/dev/tests/verification/Resources/SectionReplacementTest.txt b/dev/tests/verification/Resources/SectionReplacementTest.txt index 6fdef9083..5bdba2812 100644 --- a/dev/tests/verification/Resources/SectionReplacementTest.txt +++ b/dev/tests/verification/Resources/SectionReplacementTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -49,21 +47,25 @@ class SectionReplacementTestCest $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, []); - $createdData->createEntity(); - $I->click("#element ." . $createdData->getCreatedDataByName('firstname')); - $I->click("#" . $createdData->getCreatedDataByName('firstname') . " .stringLiteral2"); - $I->click("#" . $createdData->getCreatedDataByName('firstname') . "-stringLiteral2 .stringLiteral3"); - $I->click("#" . $createdData->getCreatedDataByName('firstname') . "-stringLiteral2 ." . $createdData->getCreatedDataByName('firstname') . " [stringLiteral3]"); + PersistedObjectHandler::getInstance()->createEntity( + "createdData", + "test", + "simpleData", + [], + null + ); + $I->click("#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test')); + $I->click("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .stringLiteral2"); + $I->click("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . "-stringLiteral2 .stringLiteral3"); + $I->click("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . "-stringLiteral2 ." . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " [stringLiteral3]"); $I->click("#element .{$data}"); $I->click("#{$data1} .{$data2}"); $I->click("#{$data1}-{$data2} .{$data3}"); $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-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .John"); + $I->click("#stringLiteral1-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .{$data}"); + $I->click("#stringLiteral1-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " ." . msq("uniqueData") . "John"); + $I->click("#stringLiteral1-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .Doe" . msq("uniqueData")); $I->click("#element .1#element .2"); $I->click("#element .1#element .{$data}"); } diff --git a/dev/tests/verification/Resources/SkippedTest.txt b/dev/tests/verification/Resources/SkippedTest.txt index b00fda574..5cb8fa322 100644 --- a/dev/tests/verification/Resources/SkippedTest.txt +++ b/dev/tests/verification/Resources/SkippedTest.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/SkippedTestNoIssues.txt b/dev/tests/verification/Resources/SkippedTestNoIssues.txt index 8d22ca415..9472d69ad 100644 --- a/dev/tests/verification/Resources/SkippedTestNoIssues.txt +++ b/dev/tests/verification/Resources/SkippedTestNoIssues.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/SkippedTestTwoIssues.txt b/dev/tests/verification/Resources/SkippedTestTwoIssues.txt index cd140e440..91edd6527 100644 --- a/dev/tests/verification/Resources/SkippedTestTwoIssues.txt +++ b/dev/tests/verification/Resources/SkippedTestTwoIssues.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/SkippedTestWithHooks.txt b/dev/tests/verification/Resources/SkippedTestWithHooks.txt index d28c61486..2bb206a78 100644 --- a/dev/tests/verification/Resources/SkippedTestWithHooks.txt +++ b/dev/tests/verification/Resources/SkippedTestWithHooks.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/functionalSuiteHooks.txt b/dev/tests/verification/Resources/functionalSuiteHooks.txt index 8ec37451c..daffb634b 100644 --- a/dev/tests/verification/Resources/functionalSuiteHooks.txt +++ b/dev/tests/verification/Resources/functionalSuiteHooks.txt @@ -2,8 +2,7 @@ namespace Group; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler; -use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; /** * Group class is Codeception Extension which is allowed to handle to all internal events. @@ -22,7 +21,6 @@ class functionalSuiteHooks extends \Codeception\GroupObject private $currentTestRun = 0; private static $HOOK_EXECUTION_INIT = "\n/******** Beginning execution of functionalSuiteHooks suite %s block ********/\n"; private static $HOOK_EXECUTION_END = "\n/******** Execution of functionalSuiteHooks suite %s block complete ********/\n"; - private $create; public function _before(\Codeception\Event\TestEvent $e) { @@ -55,9 +53,12 @@ class functionalSuiteHooks extends \Codeception\GroupObject $webDriver->_initializeSession(); $webDriver->amOnPage("some.url"); $createFields['someKey'] = "dataHere"; - $createThis = DataObjectHandler::getInstance()->getObject("createThis"); - $this->create = new DataPersistenceHandler($createThis, [], $createFields); - $this->create->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "create", + "suite", + "createThis", + $createFields + ); $webDriver->see("John", msq("uniqueData") . "John"); // reset configuration and close session @@ -106,6 +107,7 @@ class functionalSuiteHooks extends \Codeception\GroupObject print $exception->getMessage(); } + PersistedObjectHandler::getInstance()->clearSuiteObjects(); print sprintf(self::$HOOK_EXECUTION_END, "after"); } } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php index ea1b7fb2e..64bb5f0a0 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -34,7 +34,6 @@ class PersistedObjectHandler */ private $testObjects = []; - /** * Store of all suite created objects * @var DataPersistenceHandler[] array @@ -65,11 +64,11 @@ public static function getInstance() /** * Creates and stores the entity. - * @param string $key StepKey of the createData action. + * @param string $key StepKey of the createData action. * @param string $scope - * @param string $entity Name of xml entity to create. - * @param array $dependentObjectKeys StepKeys of other createData actions that are required. - * @param array $overrideFields Array of FieldName => Value of override fields. + * @param string $entity Name of xml entity to create. + * @param array $dependentObjectKeys StepKeys of other createData actions that are required. + * @param array $overrideFields Array of FieldName => Value of override fields. * @param string $storeCode * @return void */ @@ -106,10 +105,10 @@ public function createEntity( /** * Retrieves and updates a previously created entity. - * @param string $key StepKey of the createData action. - * @param $scope - * @param string $updateEntity Name of the static XML data to update the entity with. - * @param array $dependentObjectKeys StepKeys of other createData actions that are required. + * @param string $key StepKey of the createData action. + * @param string $scope + * @param string $updateEntity Name of the static XML data to update the entity with. + * @param array $dependentObjectKeys StepKeys of other createData actions that are required. * @return void */ public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = []) @@ -125,7 +124,7 @@ public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = /** * Retrieves and deletes a previously created entity. - * @param string $key StepKey of the createData action. + * @param string $key StepKey of the createData action. * @param string $scope * @return void */ @@ -137,11 +136,11 @@ public function deleteEntity($key, $scope) /** * Performs GET on given entity and stores entity for use. - * @param string $key StepKey of getData action. - * @param string $scope - * @param string $entity Name of XML static data to use. - * @param array $dependentObjectKeys StepKeys of other createData actions that are required. - * @param string $storeCode + * @param string $key StepKey of getData action. + * @param string $scope + * @param string $entity Name of XML static data to use. + * @param array $dependentObjectKeys StepKeys of other createData actions that are required. + * @param string $storeCode * @param integer $index * @return void */ @@ -170,26 +169,26 @@ public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $sto /** * Retrieves a field from an entity, according to key and scope given. - * @param $key - * @param $field - * @param $scope + * @param string $stepKey + * @param string $field + * @param string $scope * @return string * @throws TestReferenceException * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException */ - public function retrieveEntityField($key, $field, $scope) + public function retrieveEntityField($stepKey, $field, $scope) { - return $this->retrieveEntity($key, $scope)->getCreatedDataByName($field); + return $this->retrieveEntity($stepKey, $scope)->getCreatedDataByName($field); } /** * Attempts to retrieve Entity from given scope, falling back to outer scopes if not found. - * @param $key - * @param $scope + * @param string $stepKey + * @param string $scope * @return DataPersistenceHandler * @throws TestReferenceException */ - private function retrieveEntity($key, $scope) + private function retrieveEntity($stepKey, $scope) { // Assume TEST_SCOPE is default $entityArrays = [$this->testObjects, $this->hookObjects, $this->suiteObjects]; @@ -200,12 +199,12 @@ private function retrieveEntity($key, $scope) } foreach ($entityArrays as $entityArray) { - if (array_key_exists($key, $entityArray)) { - return $entityArray[$key]; + if (array_key_exists($stepKey, $entityArray)) { + return $entityArray[$stepKey]; } } - throw new TestReferenceException("Entity with a CreateDataKey of {$key} could not be found"); + throw new TestReferenceException("Entity with a CreateDataKey of {$stepKey} could not be found"); } /** diff --git a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php index 65af03e27..c3bd71faa 100644 --- a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php +++ b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php @@ -26,15 +26,15 @@ class TestContextExtension extends \Codeception\Extension Events::TEST_START => 'testStart', Events::TEST_FAIL => 'testFail', Events::STEP_AFTER => 'afterStep', - Events::TEST_END => 'testError' + Events::TEST_END => 'testEnd' ]; /** * Codeception event listener function, triggered on test start. - * @param \Codeception\Event\TestEvent $e * @throws \Exception + * @return void */ - public function testStart(\Codeception\Event\TestEvent $e) + public function testStart() { PersistedObjectHandler::getInstance()->clearHookObjects(); PersistedObjectHandler::getInstance()->clearTestObjects(); @@ -57,11 +57,11 @@ public function testFail(\Codeception\Event\FailEvent $e) } /** - * Codeception event listener function, triggered on test error. + * Codeception event listener function, triggered on test ending (naturally or by error). * @param \Codeception\Event\TestEvent $e * @return void */ - public function testError(\Codeception\Event\TestEvent $e) + public function testEnd(\Codeception\Event\TestEvent $e) { $cest = $e->getTest(); diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 5a02d6870..2c8483703 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -452,9 +452,9 @@ private function generateClassAnnotations($annotationType, $annotationName) * statement to handle each unique action. At the bottom of the case statement there is a generic function that can * construct the PHP string for nearly half of all Codeception actions. * - * @param array $actionObjects - * @param array|boolean $hookObject - * @param string $actor + * @param array $actionObjects + * @param string $generationScope + * @param string $actor * @return string * @throws TestReferenceException * @throws \Exception @@ -721,7 +721,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato if (count($customEntityFields) > 1) { $createEntityFunctionCall .= ",\n\t\t\t\${$stepKey}Fields"; } else { - $createEntityFunctionCall .= ",\n\t\t\tnull"; + $createEntityFunctionCall .= ",\n\t\t\tnull"; } if ($storeCode !== null) { $createEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; @@ -749,7 +749,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $scope = PersistedObjectHandler::SUITE_SCOPE; } - $deleteEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->deleteEntity("; $deleteEntityFunctionCall .= "\n\t\t\t\"{$key}\","; $deleteEntityFunctionCall .= "\n\t\t\t\"{$scope}\""; @@ -803,7 +802,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $scope = PersistedObjectHandler::SUITE_SCOPE; } - $updateEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->updateEntity("; $updateEntityFunctionCall .= "\n\t\t\t\"{$key}\","; $updateEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; @@ -850,7 +848,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $scope = PersistedObjectHandler::SUITE_SCOPE; } - //Create Function $getEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->getEntity("; $getEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; @@ -860,7 +857,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato if ($storeCode !== null) { $getEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; } else { - $getEntityFunctionCall .= ",\n\t\t\tnull"; + $getEntityFunctionCall .= ",\n\t\t\tnull"; } if ($index !== null) { $getEntityFunctionCall .= ",\n\t\t\t{$index}"; @@ -909,7 +906,13 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "dontSeeCookie": case "resetCookie": case "seeCookie": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $parameterArray); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $input, + $parameterArray + ); break; case "grabCookie": $testSteps .= $this->wrapFunctionCallWithReturnValue( @@ -927,7 +930,13 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "seeElement": case "seeElementInDOM": case "seeInFormFields": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $parameterArray); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $selector, + $parameterArray + ); break; case "pressKey": $parameterArray = $customActionAttributes['parameterArray'] ?? null; @@ -951,17 +960,46 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato // put the array together as a string to be passed as args $parameterArray = implode(",", $tmpParameterArray); } - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $input, $parameterArray); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $selector, + $input, + $parameterArray + ); break; case "selectOption": case "unselectOption": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $input, $parameterArray); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $selector, + $input, + $parameterArray + ); break; case "submitForm": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $parameterArray, $button); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $selector, + $parameterArray, + $button + ); break; case "dragAndDrop": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector1, $selector2, $x, $y); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $selector1, + $selector2, + $x, + $y + ); break; case "selectMultipleOptions": $testSteps .= $this->wrapFunctionCall( @@ -988,7 +1026,14 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato break; case "performOn": case "waitForElementChange": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $function, $time); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $selector, + $function, + $time + ); break; case "waitForJS": $testSteps .= $this->wrapFunctionCall( @@ -1008,7 +1053,14 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato break; case "waitForPageLoad": case "waitForText": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $time, $selector); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $input, + $time, + $selector + ); break; case "formatMoney": $testSteps .= $this->wrapFunctionCallWithReturnValue( @@ -1226,7 +1278,11 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato break; case "field": $fieldKey = $actionObject->getCustomActionAttributes()['key']; - $input = $this->resolveTestVariable([$input], $actionObject->getActionOrigin(), $generationScope)[0]; + $input = $this->resolveTestVariable( + [$input], + $actionObject->getActionOrigin(), + $generationScope + )[0]; $argRef = "\t\t\$"; $argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = ${input};\n"; $testSteps .= $argRef; @@ -1245,7 +1301,14 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $dateGenerateCode; break; default: - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $input, $parameter); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $generationScope, + $selector, + $input, + $parameter + ); } } @@ -1339,7 +1402,8 @@ private function replaceMatchesIntoArg($matches, &$outputArg, $scope) ); } - $replacement = "PersistedObjectHandler::getInstance()->retrieveEntityField('{$variable[0]}', '$variable[1]', '{$scope}')"; + $replacement = "PersistedObjectHandler::getInstance()->retrieveEntityField"; + $replacement .= "('{$variable[0]}', '$variable[1]', '{$scope}')"; //Determine if quoteBreak check is necessary. Assume replacement is surrounded in quotes, then override if (strpos($outputArg, "\"") !== false) { From 64ba9ca882acf90078421094c0b3d9063b925146 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 23 Aug 2018 10:40:44 -0500 Subject: [PATCH 6/9] MQE-1123-DATAREFACTOR - Updated Generator to use private variable for currentScope, refactored signatures to account for this - verification test update to increase coverage --- .../Resources/functionalSuiteHooks.txt | 1 + .../_suite/functionalSuiteHooks.xml | 1 + .../Util/TestGenerator.php | 80 +++++++------------ 3 files changed, 31 insertions(+), 51 deletions(-) diff --git a/dev/tests/verification/Resources/functionalSuiteHooks.txt b/dev/tests/verification/Resources/functionalSuiteHooks.txt index daffb634b..ab69f3b13 100644 --- a/dev/tests/verification/Resources/functionalSuiteHooks.txt +++ b/dev/tests/verification/Resources/functionalSuiteHooks.txt @@ -59,6 +59,7 @@ class functionalSuiteHooks extends \Codeception\GroupObject "createThis", $createFields ); + $webDriver->click(PersistedObjectHandler::getInstance()->retrieveEntityField('create', 'data', 'suite')); $webDriver->see("John", msq("uniqueData") . "John"); // reset configuration and close session diff --git a/dev/tests/verification/_suite/functionalSuiteHooks.xml b/dev/tests/verification/_suite/functionalSuiteHooks.xml index e86ea9590..f86f8c43c 100644 --- a/dev/tests/verification/_suite/functionalSuiteHooks.xml +++ b/dev/tests/verification/_suite/functionalSuiteHooks.xml @@ -16,6 +16,7 @@ dataHere + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 2c8483703..d13ab5554 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -73,6 +73,13 @@ class TestGenerator */ private $debug; + /** + * Current generation scope. + * + * @var string + */ + private $currentGenerationScope; + /** * TestGenerator constructor. * @@ -465,6 +472,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato //TODO: Refactor Method according to PHPMD warnings, remove @SuppressWarnings accordingly. $testSteps = ""; $previousStepKeys = []; + $this->currentGenerationScope = $generationScope; foreach ($actionObjects as $actionObject) { $stepKey = $actionObject->getStepKey(); @@ -758,7 +766,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $deleteEntityFunctionCall; } else { $url = $this->resolveAllRuntimeReferences([$url])[0]; - $url = $this->resolveTestVariable([$url], null, $generationScope)[0]; + $url = $this->resolveTestVariable([$url], null)[0]; $output = sprintf( "\t\t$%s->deleteEntityByUrl(%s);\n", $actor, @@ -870,7 +878,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $parameterArray, $this->wrapWithDoubleQuotes($sortOrder) ); @@ -888,11 +895,11 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "typeInPopup": case "dontSee": case "see": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $selector); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $selector); break; case "switchToNextTab": case "switchToPreviousTab": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input); break; case "clickWithLeftButton": case "clickWithRightButton": @@ -901,7 +908,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato if (!$selector) { $selector = 'null'; } - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $x, $y); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $x, $y); break; case "dontSeeCookie": case "resetCookie": @@ -909,7 +916,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $input, $parameterArray ); @@ -919,7 +925,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $stepKey, $actor, $actionObject, - $generationScope, $input, $parameterArray ); @@ -933,7 +938,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $parameterArray ); @@ -963,7 +967,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $input, $parameterArray @@ -974,7 +977,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $input, $parameterArray @@ -984,7 +986,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $parameterArray, $button @@ -994,7 +995,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector1, $selector2, $x, @@ -1005,7 +1005,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector1, $selector2, $input, @@ -1013,14 +1012,13 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato ); break; case "executeInSelenium": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $function); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $function); break; case "executeJS": $testSteps .= $this->wrapFunctionCallWithReturnValue( $stepKey, $actor, $actionObject, - $generationScope, $function ); break; @@ -1029,7 +1027,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $function, $time @@ -1039,7 +1036,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $function, $time ); @@ -1049,14 +1045,13 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "waitForElement": case "waitForElementVisible": case "waitForElementNotVisible": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $time); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $time); break; case "waitForPageLoad": case "waitForText": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $input, $time, $selector @@ -1067,13 +1062,12 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $stepKey, $actor, $actionObject, - $generationScope, $input, $locale ); break; case "mSetLocale": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $locale); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $locale); break; case "grabAttributeFrom": case "grabMultiple": @@ -1082,7 +1076,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $stepKey, $actor, $actionObject, - $generationScope, $selector, $input ); @@ -1093,7 +1086,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $stepKey, $actor, $actionObject, - $generationScope, $selector ); break; @@ -1101,18 +1093,16 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCallWithReturnValue( $stepKey, $actor, - $actionObject, - $generationScope + $actionObject ); break; case "resizeWindow": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $width, $height); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $width, $height); break; case "searchAndMultiSelectOption": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $input, $parameterArray, @@ -1121,13 +1111,12 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato break; case "seeLink": case "dontSeeLink": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $input, $url); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $url); break; case "setCookie": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $input, $value, @@ -1149,13 +1138,12 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "loadSessionSnapshot": case "seeInField": case "seeOptionIsSelected": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $selector, $input); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input); break; case "seeNumberOfElements": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $input, $parameterArray @@ -1165,13 +1153,12 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "seeInSource": case "dontSeeInSource": // TODO: Need to fix xml parser to allow parsing html. - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $generationScope, $html); + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $html); break; case "conditionalClick": $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $dependentSelector, $visible @@ -1203,7 +1190,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $assertExpected, $assertActual, $assertMessage, @@ -1219,7 +1205,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $this->wrapWithDoubleQuotes($attribute), $assertExpected @@ -1237,7 +1222,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $assertActual, $assertMessage ); @@ -1246,7 +1230,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $assertExpected, $assertActual, $assertIsStrict, @@ -1257,7 +1240,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $assertMessage ); break; @@ -1266,7 +1248,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $stepKey, $actor, $actionObject, - $generationScope, $command, $arguments ); @@ -1280,8 +1261,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $fieldKey = $actionObject->getCustomActionAttributes()['key']; $input = $this->resolveTestVariable( [$input], - $actionObject->getActionOrigin(), - $generationScope + $actionObject->getActionOrigin() )[0]; $argRef = "\t\t\$"; $argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = ${input};\n"; @@ -1304,7 +1284,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps .= $this->wrapFunctionCall( $actor, $actionObject, - $generationScope, $selector, $input, $parameter @@ -1339,7 +1318,7 @@ private function resolveLocatorFunctionInAttribute($attribute) * @return array * @throws \Exception */ - private function resolveTestVariable($args, $actionOrigin, $scope) + private function resolveTestVariable($args, $actionOrigin) { $newArgs = []; foreach ($args as $key => $arg) { @@ -1349,7 +1328,7 @@ private function resolveTestVariable($args, $actionOrigin, $scope) $outputArg = $arg; // Math on $data.key$ and $$data.key$$ preg_match_all('/\${1,2}[\w.\[\]]+\${1,2}/', $outputArg, $matches); - $this->replaceMatchesIntoArg($matches[0], $outputArg, $scope); + $this->replaceMatchesIntoArg($matches[0], $outputArg); //trim "{$variable}" into $variable $outputArg = $this->trimVariableIfNeeded($outputArg); @@ -1383,11 +1362,10 @@ private function trimVariableIfNeeded($input) * * @param array $matches * @param string $outputArg - * @param string $scope * @return void * @throws \Exception */ - private function replaceMatchesIntoArg($matches, &$outputArg, $scope) + private function replaceMatchesIntoArg($matches, &$outputArg) { // Remove Duplicate $matches from array. Duplicate matches are replaced all in one go. $matches = array_unique($matches); @@ -1403,7 +1381,7 @@ private function replaceMatchesIntoArg($matches, &$outputArg, $scope) } $replacement = "PersistedObjectHandler::getInstance()->retrieveEntityField"; - $replacement .= "('{$variable[0]}', '$variable[1]', '{$scope}')"; + $replacement .= "('{$variable[0]}', '$variable[1]', '{$this->currentGenerationScope}')"; //Determine if quoteBreak check is necessary. Assume replacement is surrounded in quotes, then override if (strpos($outputArg, "\"") !== false) { @@ -1735,7 +1713,7 @@ private function addDollarSign($input) * @return string * @throws \Exception */ - private function wrapFunctionCall($actor, $action, $scope, ...$args) + private function wrapFunctionCall($actor, $action, ...$args) { $isFirst = true; $output = sprintf("\t\t$%s->%s(", $actor, $action->getType()); @@ -1751,7 +1729,7 @@ private function wrapFunctionCall($actor, $action, $scope, ...$args) $args = [$args]; } $args = $this->resolveAllRuntimeReferences($args); - $args = $this->resolveTestVariable($args, $action->getActionOrigin(), $scope); + $args = $this->resolveTestVariable($args, $action->getActionOrigin()); $output .= implode(", ", array_filter($args, function($value) { return $value !== null; })) . ");\n"; return $output; } @@ -1767,7 +1745,7 @@ private function wrapFunctionCall($actor, $action, $scope, ...$args) * @return string * @throws \Exception */ - private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $action, $scope, ...$args) + private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $action, ...$args) { $isFirst = true; $output = sprintf("\t\t$%s = $%s->%s(", $returnVariable, $actor, $action->getType()); @@ -1783,7 +1761,7 @@ private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $actio $args = [$args]; } $args = $this->resolveAllRuntimeReferences($args); - $args = $this->resolveTestVariable($args, $action->getActionOrigin(), $scope); + $args = $this->resolveTestVariable($args, $action->getActionOrigin()); $output .= implode(", ", array_filter($args, function($value) { return $value !== null; })) . ");\n"; return $output; } From c9fdc2df084e3b15e6a7f838122e09df4acea3ef Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 23 Aug 2018 14:02:21 -0500 Subject: [PATCH 7/9] MQE-1123-DATAREFACTOR - Fixed merged verification test --- dev/tests/verification/Resources/ExecuteJsEscapingTest.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt index 4628df5cf..6dd8ef3db 100644 --- a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt +++ b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt @@ -29,8 +29,8 @@ class ExecuteJsEscapingTestCest { $javaVariableEscape = $I->executeJS("return \$javascriptVariable"); $mftfVariableNotEscaped = $I->executeJS("return {$doNotEscape}"); - $persistedDataNotEscaped = $I->executeJS("return " . $persisted->getCreatedDataByName('data')); - $hookPersistedDataNotEscaped = $I->executeJS("return " . $this->persisted->getCreatedDataByName('data')); - $addNewAttributeForRule = $I->executeJS("document.querySelector('entity option[value=" . $this->productAttribute->getCreatedDataByName('attribute_code') . "]').setAttribute('selected', 'selected')"); + $persistedDataNotEscaped = $I->executeJS("return " . PersistedObjectHandler::getInstance()->retrieveEntityField('persisted', 'data', 'test')); + $hookPersistedDataNotEscaped = $I->executeJS("return " . PersistedObjectHandler::getInstance()->retrieveEntityField('persisted', 'data', 'test')); + $addNewAttributeForRule = $I->executeJS("document.querySelector('entity option[value=" . PersistedObjectHandler::getInstance()->retrieveEntityField('productAttribute', 'attribute_code', 'test') . "]').setAttribute('selected', 'selected')"); } } From bebc86504d28512e8c2dca9b1ad3910d53bda003 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Tue, 28 Aug 2018 13:53:29 -0500 Subject: [PATCH 8/9] MQE-1123-DATAREFACTOR - ActionGroups were not replacing their createDataKey references correctly. - Added new test for above use case - No hooks no longer assign a variable (not necessary), verification test updates --- .../Resources/ActionGroupUsingCreateData.txt | 10 -- .../ActionGroupWithDataOverrideTest.txt | 5 - .../Resources/ActionGroupWithDataTest.txt | 5 - .../ActionGroupWithNoDefaultTest.txt | 5 - .../ActionGroupWithPersistedData.txt | 5 - .../ActionGroupWithStepKeyReferences.txt | 38 ++++++-- .../ActionGroupWithTopLevelPersistedData.txt | 5 - .../ArgumentWithSameNameAsElement.txt | 5 - .../verification/Resources/AssertTest.txt | 5 - .../Resources/BasicActionGroupTest.txt | 5 - .../Resources/DataActionsTest.txt | 10 -- .../Resources/HookActionsTest.txt | 15 --- .../Resources/MergedActionGroupTest.txt | 5 - .../Resources/MultipleActionGroupsTest.txt | 5 - .../Resources/PersistedReplacementTest.txt | 5 - .../PersistenceActionGroupAppendingTest.txt | 97 +++++++++++++++++++ .../Resources/PersistenceCustomFieldsTest.txt | 10 -- .../ActionGroup/FunctionalActionGroup.xml | 4 +- .../ActionGroup/PersistenceActionGroup.xml | 7 ++ .../PersistenceActionGroupAppendingTest.xml | 17 ++++ .../Tests/PersistenceGenerationTest.php | 8 ++ .../Util/TestGenerator.php | 48 +++++---- 22 files changed, 182 insertions(+), 137 deletions(-) create mode 100644 dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt create mode 100644 dev/tests/verification/TestModule/Test/PersistenceActionGroupAppendingTest.xml diff --git a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt index 3c291ba24..f0d14dbd9 100644 --- a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt +++ b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt @@ -18,16 +18,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupUsingCreateDataCest { - /** - * @var DataPersistenceHandler $createCategoryKey1; - */ - protected $createCategoryKey1; - - /** - * @var DataPersistenceHandler $createConfigProductKey1; - */ - protected $createConfigProductKey1; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt index cc4701264..3bc708a1a 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithDataOverrideTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt index d981068f5..e79534bad 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithDataTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt index b65668460..ed02790e5 100644 --- a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithNoDefaultTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt index ecff3ffc9..5ed6eb7f7 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithPersistedDataCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt index 75bf8ae31..542e20133 100644 --- a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt @@ -36,9 +36,11 @@ class ActionGroupWithStepKeyReferencesCest null ); $grabTextDataActionGroup = $I->grabTextFrom(".class"); - $I->fillField(".{$grabTextDataActionGroup}", PersistedObjectHandler::getInstance()->retrieveEntityField('createSimpleData', 'field', 'test')); + $I->fillField(".{$grabTextDataActionGroup}", PersistedObjectHandler::getInstance()->retrieveEntityField('createSimpleDataActionGroup', 'field', 'test')); + $I->comment("Invocation stepKey will not be appended in non stepKey instances"); $I->click($action0); $I->fillField($action1); + $I->comment("Invocation stepKey will be appended in non stepKey instances"); $action3ActionGroup = $I->executeJS($action3ActionGroup); $action4ActionGroup = $I->magentoCLI($action4ActionGroup, "\"stuffHere\""); $I->comment($action4ActionGroup); @@ -47,18 +49,34 @@ class ActionGroupWithStepKeyReferencesCest $date->setTimezone(new \DateTimeZone("America/Los_Angeles")); $action5ActionGroup = $date->format("H:i:s"); $action6ActionGroup = $I->formatMoney($action6ActionGroup); - $I->amGoingTo("delete entity that has the createDataKey: {$action7}"); - ${$action7}->deleteEntity(); + $I->amGoingTo("delete entity that has the createDataKey: {$action7ActionGroupActionGroup}"); + PersistedObjectHandler::getInstance()->deleteEntity( + "{$action7ActionGroupActionGroup}", + "test" + ); $I->amGoingTo("get entity that has the stepKey: action8ActionGroup"); - ${$action8} = DataObjectHandler::getInstance()->getObject("{$action8}"); - $action8ActionGroup = new DataPersistenceHandler(${$action8}); - $action8ActionGroup->getEntity(null); + PersistedObjectHandler::getInstance()->getEntity( + "action8ActionGroup", + "test", + "{$action8}", + [], + null + ); $I->amGoingTo("update entity that has the createdDataKey: 1"); - $1->updateEntity("{$action9}"); + PersistedObjectHandler::getInstance()->updateEntity( + "1", + "test", + "{$action9}", + [] + ); $I->amGoingTo("create entity that has the stepKey: action10ActionGroup"); - ${$action10} = DataObjectHandler::getInstance()->getObject("{$action10}"); - $action10ActionGroup = new DataPersistenceHandler(${$action10}, []); - $action10ActionGroup->createEntity(); + PersistedObjectHandler::getInstance()->createEntity( + "action10ActionGroup", + "test", + "{$action10}", + [], + null + ); $action11ActionGroup = $I->grabAttributeFrom($action11ActionGroup, "someInput"); $action12ActionGroup = $I->grabCookie($action12ActionGroup, ['domain' => 'www.google.com']); $action13ActionGroup = $I->grabFromCurrentUrl($action13ActionGroup); diff --git a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt index b4217e188..acc274567 100644 --- a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithTopLevelPersistedDataCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt index 7766d0dd8..80a1d3c80 100644 --- a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt +++ b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ArgumentWithSameNameAsElementCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/AssertTest.txt b/dev/tests/verification/Resources/AssertTest.txt index a4e484d55..adc764975 100644 --- a/dev/tests/verification/Resources/AssertTest.txt +++ b/dev/tests/verification/Resources/AssertTest.txt @@ -18,11 +18,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class AssertTestCest { - /** - * @var DataPersistenceHandler $createData1; - */ - protected $createData1; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/BasicActionGroupTest.txt b/dev/tests/verification/Resources/BasicActionGroupTest.txt index 83932cf33..d6d953a88 100644 --- a/dev/tests/verification/Resources/BasicActionGroupTest.txt +++ b/dev/tests/verification/Resources/BasicActionGroupTest.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class BasicActionGroupTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/DataActionsTest.txt b/dev/tests/verification/Resources/DataActionsTest.txt index 9eb68c94c..cac3b72cd 100644 --- a/dev/tests/verification/Resources/DataActionsTest.txt +++ b/dev/tests/verification/Resources/DataActionsTest.txt @@ -18,16 +18,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class DataActionsTestCest { - /** - * @var DataPersistenceHandler $createdInBefore; - */ - protected $createdInBefore; - - /** - * @var DataPersistenceHandler $updateInBefore; - */ - protected $updateInBefore; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/HookActionsTest.txt b/dev/tests/verification/Resources/HookActionsTest.txt index 8ce4ad320..70e4ece10 100644 --- a/dev/tests/verification/Resources/HookActionsTest.txt +++ b/dev/tests/verification/Resources/HookActionsTest.txt @@ -18,16 +18,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class HookActionsTestCest { - /** - * @var DataPersistenceHandler $sampleCreateBefore; - */ - protected $sampleCreateBefore; - - /** - * @var DataPersistenceHandler $sampleCreateForAfter; - */ - protected $sampleCreateForAfter; - /** * @param AcceptanceTester $I * @throws \Exception @@ -57,11 +47,6 @@ class HookActionsTestCest ); } - /** - * @var DataPersistenceHandler $sampleCreateAfter; - */ - protected $sampleCreateAfter; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/MergedActionGroupTest.txt b/dev/tests/verification/Resources/MergedActionGroupTest.txt index 0be121125..2d1748f56 100644 --- a/dev/tests/verification/Resources/MergedActionGroupTest.txt +++ b/dev/tests/verification/Resources/MergedActionGroupTest.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class MergedActionGroupTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt index 7548aa79a..5084692be 100644 --- a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt +++ b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt @@ -19,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class MultipleActionGroupsTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/PersistedReplacementTest.txt b/dev/tests/verification/Resources/PersistedReplacementTest.txt index baa627e5e..c19e33ee7 100644 --- a/dev/tests/verification/Resources/PersistedReplacementTest.txt +++ b/dev/tests/verification/Resources/PersistedReplacementTest.txt @@ -18,11 +18,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class PersistedReplacementTestCest { - /** - * @var DataPersistenceHandler $createData1; - */ - protected $createData1; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt b/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt new file mode 100644 index 000000000..c38a14155 --- /dev/null +++ b/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt @@ -0,0 +1,97 @@ +amGoingTo("create entity that has the stepKey: createDataACTIONGROUPBEFORE"); + PersistedObjectHandler::getInstance()->createEntity( + "createDataACTIONGROUPBEFORE", + "hook", + "entity", + [], + null + ); + $I->amGoingTo("update entity that has the createdDataKey: createDataACTIONGROUPBEFORE"); + PersistedObjectHandler::getInstance()->updateEntity( + "createDataACTIONGROUPBEFORE", + "hook", + "newEntity", + [] + ); + $I->amGoingTo("delete entity that has the createDataKey: createDataACTIONGROUPBEFORE"); + PersistedObjectHandler::getInstance()->deleteEntity( + "createDataACTIONGROUPBEFORE", + "hook" + ); + $I->amGoingTo("get entity that has the stepKey: getDataACTIONGROUPBEFORE"); + PersistedObjectHandler::getInstance()->getEntity( + "getDataACTIONGROUPBEFORE", + "hook", + "someEneity", + [], + null + ); + $I->comment(PersistedObjectHandler::getInstance()->retrieveEntityField('createData', 'field', 'hook')); + } + + /** + * @Features({"TestModule"}) + * @Parameter(name = "AcceptanceTester", value="$I") + * @param AcceptanceTester $I + * @return void + * @throws \Exception + */ + public function PersistenceActionGroupAppendingTest(AcceptanceTester $I) + { + $I->amGoingTo("create entity that has the stepKey: createDataACTIONGROUP"); + PersistedObjectHandler::getInstance()->createEntity( + "createDataACTIONGROUP", + "test", + "entity", + [], + null + ); + $I->amGoingTo("update entity that has the createdDataKey: createDataACTIONGROUP"); + PersistedObjectHandler::getInstance()->updateEntity( + "createDataACTIONGROUP", + "test", + "newEntity", + [] + ); + $I->amGoingTo("delete entity that has the createDataKey: createDataACTIONGROUP"); + PersistedObjectHandler::getInstance()->deleteEntity( + "createDataACTIONGROUP", + "test" + ); + $I->amGoingTo("get entity that has the stepKey: getDataACTIONGROUP"); + PersistedObjectHandler::getInstance()->getEntity( + "getDataACTIONGROUP", + "test", + "someEneity", + [], + null + ); + $I->comment(PersistedObjectHandler::getInstance()->retrieveEntityField('createDataACTIONGROUP', 'field', 'test')); + } +} diff --git a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt index a4e24c5bc..24faac699 100644 --- a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt +++ b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt @@ -18,16 +18,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class PersistenceCustomFieldsTestCest { - /** - * @var DataPersistenceHandler $createData1; - */ - protected $createData1; - - /** - * @var DataPersistenceHandler $createData2; - */ - protected $createData2; - /** * @param AcceptanceTester $I * @throws \Exception diff --git a/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml index af89993ef..728b606b2 100644 --- a/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml @@ -49,10 +49,10 @@ - + - + diff --git a/dev/tests/verification/TestModule/ActionGroup/PersistenceActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/PersistenceActionGroup.xml index 45ba57acb..c4f894cfc 100644 --- a/dev/tests/verification/TestModule/ActionGroup/PersistenceActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/PersistenceActionGroup.xml @@ -23,4 +23,11 @@ {{arg3}} + + + + + + + \ No newline at end of file diff --git a/dev/tests/verification/TestModule/Test/PersistenceActionGroupAppendingTest.xml b/dev/tests/verification/TestModule/Test/PersistenceActionGroupAppendingTest.xml new file mode 100644 index 000000000..20a9b6a28 --- /dev/null +++ b/dev/tests/verification/TestModule/Test/PersistenceActionGroupAppendingTest.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/dev/tests/verification/Tests/PersistenceGenerationTest.php b/dev/tests/verification/Tests/PersistenceGenerationTest.php index afe231c9b..6944d75a0 100644 --- a/dev/tests/verification/Tests/PersistenceGenerationTest.php +++ b/dev/tests/verification/Tests/PersistenceGenerationTest.php @@ -16,4 +16,12 @@ public function testPersistedDeclarations() { $this->generateAndCompareTest('PersistenceCustomFieldsTest'); } + + /** + * Tests complex persistence declarations in xml as they are generated to php. + */ + public function testPersistenceActionGroupAppendingTest() + { + $this->generateAndCompareTest('PersistenceActionGroupAppendingTest'); + } } diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 72a26db88..e773690e8 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -749,8 +749,13 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato break; case "deleteData": if (isset($customActionAttributes['createDataKey'])) { - $key = $customActionAttributes['createDataKey']; + $key = $this->resolveStepKeyReferences( + $customActionAttributes['createDataKey'], + $actionObject->getActionOrigin(), + true + ); $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null; + $key .= $actionGroup; //Add an informative statement to help the user debug test runs $contextSetter = sprintf( "\t\t$%s->amGoingTo(\"delete entity that has the createDataKey: %s\");\n", @@ -758,7 +763,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $key ); - $key .= $actionGroup; //Determine Scope $scope = PersistedObjectHandler::TEST_SCOPE; if ($generationScope == TestGenerator::HOOK_SCOPE) { @@ -786,9 +790,14 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato } break; case "updateData": - $key = $customActionAttributes['createDataKey']; + $key = $this->resolveStepKeyReferences( + $customActionAttributes['createDataKey'], + $actionObject->getActionOrigin(), + true + ); $updateEntity = $customActionAttributes['entity']; $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null; + $key .= $actionGroup; //Add an informative statement to help the user debug test runs $testSteps .= sprintf( @@ -796,8 +805,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $actor, $key ); - - $key .= $actionGroup; // Build array of requiredEntities $requiredEntityKeys = []; @@ -1429,7 +1436,7 @@ private function processQuoteBreaks($match, $argument, $replacement) * @param array $actionGroupOrigin * @return string */ - private function resolveStepKeyReferences($input, $actionGroupOrigin) + private function resolveStepKeyReferences($input, $actionGroupOrigin, $matchAll = false) { if ($actionGroupOrigin == null) { return $input; @@ -1445,14 +1452,21 @@ private function resolveStepKeyReferences($input, $actionGroupOrigin) foreach ($stepKeys as $stepKey) { // MQE-1011 $stepKeyVarRef = "$" . $stepKey; - $classVarRef = "\$this->$stepKey"; + $persistedVarRef = "PersistedObjectHandler::getInstance()->retrieveEntityField('{$stepKey}'" + . ", 'field', 'test')"; + $persistedVarRefInvoked = "PersistedObjectHandler::getInstance()->retrieveEntityField('" + . $stepKey . $testInvocationKey . "', 'field', 'test')"; if (strpos($output, $stepKeyVarRef) !== false) { $output = str_replace($stepKeyVarRef, $stepKeyVarRef . $testInvocationKey, $output); } - if (strpos($output, $classVarRef) !== false) { - $output = str_replace($classVarRef, $classVarRef . $testInvocationKey, $output); + if (strpos($output, $persistedVarRef) !== false) { + $output = str_replace($persistedVarRef, $persistedVarRefInvoked, $output); + } + + if ($matchAll && strpos($output, $stepKey) !== false) { + $output = str_replace($stepKey, $stepKey . $testInvocationKey, $output); } } return $output; @@ -1525,22 +1539,6 @@ private function generateHooksPhp($hookObjects) $type = $hookObject->getType(); $dependencies = 'AcceptanceTester $I'; - foreach ($hookObject->getActions() as $step) { - if ($hookObject->getType() == TestObjectExtractor::TEST_FAILED_HOOK) { - continue; - } - - if (($step->getType() == "createData") - || ($step->getType() == "updateData") - || ($step->getType() == "getData") - ) { - $hooks .= "\t/**\n"; - $hooks .= sprintf("\t * @var DataPersistenceHandler $%s;\n", $step->getStepKey()); - $hooks .= "\t */\n"; - $hooks .= sprintf("\tprotected $%s;\n\n", $step->getStepKey()); - } - } - $hooks .= "\t/**\n"; $hooks .= "\t * @param AcceptanceTester \$I\n"; $hooks .= "\t * @throws \Exception\n"; From b90e31457e5b31a0b2dba984379b9a5de702be64 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Wed, 29 Aug 2018 08:50:02 -0500 Subject: [PATCH 9/9] MQE-1184: Describe which entity reference fails in generate:tests - Fix verification test --- dev/tests/verification/Resources/ActionGroupSkipReadiness.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt b/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt index 073211992..b787f9116 100644 --- a/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt +++ b/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt @@ -2,10 +2,8 @@ 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 Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories;