diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b6998ce1..c8a7efa13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,32 @@ Magento Functional Testing Framework Changelog ================================================ +2.3.6 +----- +### Enhancements +* Maintainability + * A `-r` or `--remove` flag has been introduced to `bin/mftf` commands to clear out the contents of the `_generated` folder before generation. This flag has been added to the following commands: + * `generate:tests` + * `generate:suite` + * `run:test` + * `run:group` +* Customizability + * Persisted data handling mechanisms have been reworked. + * All persisted data is now referenced with the single `$` syntax (old syntax is still supported): + * `$persistedData.field$` + * Persisted data resolution now starts in its own scope and broadens if no matching `stepKey` was found in the current scope. + * Added support for referencing `suite` persisted data in tests. + * Added support for removing data created in between test scopes (`test`, `before/after`, `suite`). + * An attribute `skipReadiness` has been added to all test actions, allowing the individual test action to completely bypass the `ReadinessExtension` if it is enabled. + +### Fixes +* To prevent Allure reporting from collating tests with identical `title`, the `testCaseId` annotation is now automatically prepended to the `title` annotation when tests are generated. +* The `magentoCLI` command now correctly removes `index.php` if it is present in the `MAGENTO_BASE_URL`. +* Invalid XML errors now indicate which XML file caused the error. +* Attempting to `extend` a test that does not exist now skips the generation of the test. +* Fixed an issue where a `suite` would generate invalid PHP if the `before` or `after` contained only `createData` actions. +* Fixed an issue where a selector inside an `actionGroup` would incorrectly append the `actionGroup`'s `stepKey` to the selector. + 2.3.5 ----- ### Fixes diff --git a/bin/mftf b/bin/mftf index e37a33835..ef96ecca0 100755 --- a/bin/mftf +++ b/bin/mftf @@ -29,7 +29,7 @@ try { try { $application = new Symfony\Component\Console\Application(); $application->setName('Magento Functional Testing Framework CLI'); - $application->setVersion('2.3.5'); + $application->setVersion('2.3.6'); /** @var \Magento\FunctionalTestingFramework\Console\CommandListInterface $commandList */ $commandList = new \Magento\FunctionalTestingFramework\Console\CommandList; foreach ($commandList->getCommands() as $command) { diff --git a/composer.json b/composer.json index c3a4a9840..60d6f2653 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/magento2-functional-testing-framework", "description": "Magento2 Functional Testing Framework", "type": "library", - "version": "2.3.5", + "version": "2.3.6", "license": "AGPL-3.0", "keywords": ["magento", "automation", "functional", "testing"], "config": { diff --git a/composer.lock b/composer.lock index d6fa0f490..8ec534fda 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "996e132ba111598750baca40e9152d5f", + "content-hash": "4dc0a2b0fc82647238bf0892f3b65d0f", "packages": [ { "name": "allure-framework/allure-codeception", @@ -588,16 +588,16 @@ }, { "name": "consolidation/self-update", - "version": "1.0.0", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/consolidation/self-update.git", - "reference": "adbb784e58cc0836d8522851f7e38ee7ade0d553" + "reference": "de33822f907e0beb0ffad24cf4b1b4fae5ada318" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/self-update/zipball/adbb784e58cc0836d8522851f7e38ee7ade0d553", - "reference": "adbb784e58cc0836d8522851f7e38ee7ade0d553", + "url": "https://api.github.com/repos/consolidation/self-update/zipball/de33822f907e0beb0ffad24cf4b1b4fae5ada318", + "reference": "de33822f907e0beb0ffad24cf4b1b4fae5ada318", "shasum": "" }, "require": { @@ -605,6 +605,9 @@ "symfony/console": "^2.8|^3|^4", "symfony/filesystem": "^2.5|^3|^4" }, + "bin": [ + "scripts/release" + ], "type": "library", "extra": { "branch-alias": { @@ -621,13 +624,17 @@ "MIT" ], "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + }, { "name": "Alexander Menk", "email": "menk@mestrona.net" } ], "description": "Provides a self:update command for Symfony Console applications.", - "time": "2018-08-17T04:50:59+00:00" + "time": "2018-08-24T17:01:46+00:00" }, { "name": "container-interop/container-interop", @@ -2632,16 +2639,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.5.11", + "version": "6.5.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "7bab54cb366076023bbf457a2a0d513332cd40f2" + "reference": "24da433d7384824d65ea93fbb462e2f31bbb494e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7bab54cb366076023bbf457a2a0d513332cd40f2", - "reference": "7bab54cb366076023bbf457a2a0d513332cd40f2", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/24da433d7384824d65ea93fbb462e2f31bbb494e", + "reference": "24da433d7384824d65ea93fbb462e2f31bbb494e", "shasum": "" }, "require": { @@ -2712,7 +2719,7 @@ "testing", "xunit" ], - "time": "2018-08-07T07:05:35+00:00" + "time": "2018-08-22T06:32:48+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -3562,7 +3569,7 @@ }, { "name": "symfony/browser-kit", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", @@ -3619,7 +3626,7 @@ }, { "name": "symfony/console", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/console.git", @@ -3688,7 +3695,7 @@ }, { "name": "symfony/css-selector", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -3741,16 +3748,16 @@ }, { "name": "symfony/debug", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "d5a058ff6ecad26b30c1ba452241306ea34c65cc" + "reference": "c4625e75341e4fb309ce0c049cbf7fb84b8897cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/d5a058ff6ecad26b30c1ba452241306ea34c65cc", - "reference": "d5a058ff6ecad26b30c1ba452241306ea34c65cc", + "url": "https://api.github.com/repos/symfony/debug/zipball/c4625e75341e4fb309ce0c049cbf7fb84b8897cd", + "reference": "c4625e75341e4fb309ce0c049cbf7fb84b8897cd", "shasum": "" }, "require": { @@ -3793,11 +3800,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:19:56+00:00" + "time": "2018-08-03T10:42:44+00:00" }, { "name": "symfony/dom-crawler", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", @@ -3854,7 +3861,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -3917,16 +3924,16 @@ }, { "name": "symfony/filesystem", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "a59f917e3c5d82332514cb4538387638f5bde2d6" + "reference": "285ce5005cb01a0aeaa5b0cf590bd0cc40bb631c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/a59f917e3c5d82332514cb4538387638f5bde2d6", - "reference": "a59f917e3c5d82332514cb4538387638f5bde2d6", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/285ce5005cb01a0aeaa5b0cf590bd0cc40bb631c", + "reference": "285ce5005cb01a0aeaa5b0cf590bd0cc40bb631c", "shasum": "" }, "require": { @@ -3963,11 +3970,11 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:19:56+00:00" + "time": "2018-08-10T07:29:05+00:00" }, { "name": "symfony/finder", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -4016,16 +4023,16 @@ }, { "name": "symfony/http-foundation", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "19a3267828046a2a4a05e3dc2954bbd2e0ad9fa6" + "reference": "2fb33cb6eefe6e790e4023f7c534a9e4214252fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/19a3267828046a2a4a05e3dc2954bbd2e0ad9fa6", - "reference": "19a3267828046a2a4a05e3dc2954bbd2e0ad9fa6", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/2fb33cb6eefe6e790e4023f7c534a9e4214252fc", + "reference": "2fb33cb6eefe6e790e4023f7c534a9e4214252fc", "shasum": "" }, "require": { @@ -4066,7 +4073,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2018-08-01T14:04:26+00:00" + "time": "2018-08-27T17:45:33+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4246,16 +4253,16 @@ }, { "name": "symfony/process", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "0414db29bd770ec5a4152683e655f55efd4fa60f" + "reference": "4d6b125d5293cbceedc2aa10f2c71617e76262e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/0414db29bd770ec5a4152683e655f55efd4fa60f", - "reference": "0414db29bd770ec5a4152683e655f55efd4fa60f", + "url": "https://api.github.com/repos/symfony/process/zipball/4d6b125d5293cbceedc2aa10f2c71617e76262e7", + "reference": "4d6b125d5293cbceedc2aa10f2c71617e76262e7", "shasum": "" }, "require": { @@ -4291,20 +4298,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:19:56+00:00" + "time": "2018-08-03T10:42:44+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "810af2d35fc72b6cf5c01116806d2b65ccaaf2e2" + "reference": "c2f4812ead9f847cb69e90917ca7502e6892d6b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/810af2d35fc72b6cf5c01116806d2b65ccaaf2e2", - "reference": "810af2d35fc72b6cf5c01116806d2b65ccaaf2e2", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c2f4812ead9f847cb69e90917ca7502e6892d6b8", + "reference": "c2f4812ead9f847cb69e90917ca7502e6892d6b8", "shasum": "" }, "require": { @@ -4350,7 +4357,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2018-07-26T11:19:56+00:00" + "time": "2018-08-10T07:34:36+00:00" }, { "name": "theseer/tokenizer", @@ -4496,16 +4503,16 @@ "packages-dev": [ { "name": "brainmaestro/composer-git-hooks", - "version": "v2.4.5", + "version": "v2.5.0", "source": { "type": "git", "url": "https://github.com/BrainMaestro/composer-git-hooks.git", - "reference": "1bc14b8938a328550e915e1051ddcfbb02048e5d" + "reference": "5b2feb35fa8d460b14fc71792aca57f97d349430" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/BrainMaestro/composer-git-hooks/zipball/1bc14b8938a328550e915e1051ddcfbb02048e5d", - "reference": "1bc14b8938a328550e915e1051ddcfbb02048e5d", + "url": "https://api.github.com/repos/BrainMaestro/composer-git-hooks/zipball/5b2feb35fa8d460b14fc71792aca57f97d349430", + "reference": "5b2feb35fa8d460b14fc71792aca57f97d349430", "shasum": "" }, "require": { @@ -4514,12 +4521,18 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.9", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^5.7|^7.0" }, "bin": [ "cghooks" ], "type": "library", + "extra": { + "hooks": { + "pre-commit": "composer check-style", + "pre-push": "composer test" + } + }, "autoload": { "psr-4": { "BrainMaestro\\GitHooks\\": "src/" @@ -4544,7 +4557,7 @@ "composer", "git" ], - "time": "2018-06-06T07:05:21+00:00" + "time": "2018-09-02T01:27:40+00:00" }, { "name": "codacy/coverage", @@ -5428,7 +5441,7 @@ }, { "name": "symfony/config", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/config.git", @@ -5492,16 +5505,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "1c0e679e522591fd744fdf242fec41a43d62b2b1" + "reference": "09d7df7bf06c1393b6afc85875993cbdbdf897a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/1c0e679e522591fd744fdf242fec41a43d62b2b1", - "reference": "1c0e679e522591fd744fdf242fec41a43d62b2b1", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/09d7df7bf06c1393b6afc85875993cbdbdf897a0", + "reference": "09d7df7bf06c1393b6afc85875993cbdbdf897a0", "shasum": "" }, "require": { @@ -5559,11 +5572,11 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2018-07-29T15:19:31+00:00" + "time": "2018-08-08T11:42:34+00:00" }, { "name": "symfony/stopwatch", - "version": "v3.4.14", + "version": "v3.4.15", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", 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/unit/Magento/FunctionalTestFramework/Suite/Handlers/SuiteObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Suite/Handlers/SuiteObjectHandlerTest.php index 3f0d2c5a8..8133c82a3 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Suite/Handlers/SuiteObjectHandlerTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Suite/Handlers/SuiteObjectHandlerTest.php @@ -42,19 +42,19 @@ public function testGetSuiteObject() $mockGroup1Test1 = $testDataArrayBuilder ->withName('group1Test1') - ->withAnnotations(['group' => [['value' => 'group1']]]) + ->withAnnotations(['group' => [['value' => 'group1']], 'title'=>[['value' => 'group1Test1']]]) ->withTestActions() ->build(); $mockGroup1Test2 = $testDataArrayBuilder ->withName('group1Test2') - ->withAnnotations(['group' => [['value' => 'group1']]]) + ->withAnnotations(['group' => [['value' => 'group1']], 'title'=>[['value' => 'group1Test2']]]) ->withTestActions() ->build(); $mockGroup2Test1 = $testDataArrayBuilder ->withName('group2Test1') - ->withAnnotations(['group' => [['value' => 'group2']]]) + ->withAnnotations(['group' => [['value' => 'group2']], 'title'=>[['value' => 'group2Test1']]]) ->withTestActions() ->build(); diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Config/ActionGroupDomTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Config/ActionGroupDomTest.php index 8d0bc19ca..5d1dd7878 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Config/ActionGroupDomTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Config/ActionGroupDomTest.php @@ -6,6 +6,7 @@ namespace Tests\unit\Magento\FunctionalTestFramework\Test\Config; use Magento\FunctionalTestingFramework\Exceptions\Collector\ExceptionCollector; +use Magento\FunctionalTestingFramework\Config\Dom\ValidationException; use Magento\FunctionalTestingFramework\Test\Config\ActionGroupDom; use Magento\FunctionalTestingFramework\Util\MagentoTestCase; @@ -29,4 +30,21 @@ public function testActionGroupDomStepKeyValidation() $this->expectException(\Exception::class); $exceptionCollector->throwException(); } + + /** + * Test Action Group invalid XML + */ + public function testActionGroupDomInvalidXmlValidation() + { + $sampleXml = " + + + + "; + + $exceptionCollector = new ExceptionCollector(); + $this->expectException(ValidationException::class); + $this->expectExceptionMessage("XML Parse Error: invalid.xml\n"); + new ActionGroupDom($sampleXml, 'invalid.xml', $exceptionCollector); + } } diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php index d368d5fa1..1dbeb50db 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php @@ -121,11 +121,12 @@ public function testGetTestsByGroup() // set up mock data with Exclude Test $includeTest = (new TestDataArrayBuilder()) ->withName('includeTest') - ->withAnnotations() + ->withAnnotations(['group' => [['value' => 'test']], 'title'=>[['value' => 'includeTest']]]) ->withTestActions() ->build(); $excludeTest = (new TestDataArrayBuilder()) ->withName('excludeTest') + ->withAnnotations(['title'=>[['value' => 'excludeTest']]]) ->withTestActions() ->build(); diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php index 4844ca684..796e8a28b 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php @@ -261,6 +261,62 @@ public function testExceptionOnMissingArguments() $actionGroupUnderTest->getSteps(null, self::ACTION_GROUP_MERGE_KEY); } + /** + * Tests the stepKey replacement with "stepKey + invocationKey" process filter + * Specific to actions that make it past a "require stepKey replacement" filter + */ + public function testStepKeyReplacementFilteredIn() + { + $createStepKey = "createDataStepKey"; + $updateStepKey = "updateDataStepKey"; + + $actionGroupUnderTest = (new ActionGroupObjectBuilder()) + ->withActionObjects([ + new ActionObject( + $updateStepKey, + ActionGroupObject::STEPKEY_REPLACEMENT_ENABLED_TYPES[6], + ['selector' => 'value'] + ), + new ActionObject( + $createStepKey, + ActionGroupObject::STEPKEY_REPLACEMENT_ENABLED_TYPES[7], + ['selector' => 'value'] + ) + ]) + ->build(); + + $result = $actionGroupUnderTest->extractStepKeys(); + + $this->assertContains($updateStepKey, $result); + $this->assertContains($createStepKey, $result); + $this->assertCount(2, $result); + } + + /** + * Tests the stepKey replacement with "stepKey + invocationKey" process filter + * Specific to actions that make are removed by a "require stepKey replacement" filter + */ + public function testStepKeyReplacementFilteredOut() + { + $clickStepKey = "clickStepKey"; + $fillFieldStepKey = "fillFieldStepKey"; + $clickAction = "click"; + $fillFieldAction ="fillField"; + + $actionGroupUnderTest = (new ActionGroupObjectBuilder()) + ->withActionObjects([ + new ActionObject($clickStepKey, $clickAction, ['selector' => 'value']), + new ActionObject($fillFieldStepKey, $fillFieldAction, ['selector' => 'value']) + ]) + ->build(); + + $result = $actionGroupUnderTest->extractStepKeys(); + + $this->assertNotContains($clickStepKey, $result); + $this->assertNotContains($fillFieldStepKey, $result); + $this->assertCount(0, $result); + } + /** * This function takes a desired return for the EntityObjectHandler mock and performs set up of the mock for the * duration of a single test case. diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/AnnotationExtractorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/AnnotationExtractorTest.php index fcdad2e40..fb93cbb88 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/AnnotationExtractorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/AnnotationExtractorTest.php @@ -122,6 +122,89 @@ public function testMissingAnnotations() ); } + public function testTestCaseIdUniqueness() + { + // Test Data + $firstTestAnnotation = [ + "nodeName" => "annotations", + "features" => [ + [ + "nodeName" => "features", + "value" => "TestFeatures" + ] + ], + "stories" => [ + [ + "nodeName" => "stories", + "value" => "TestStories" + ] + ], + "title" => [ + [ + "nodeName" => "title", + "value" => "TEST TITLE" + ] + ], + "severity" => [ + [ + "nodeName" => "severity", + "value" => "CRITICAL" + ] + ], + "testCaseId" => [ + [ + "nodeName" => "testCaseId", + "value" => "MQE-0001" + ] + ], + ]; + $secondTestannotation = [ + "nodeName" => "annotations", + "features" => [ + [ + "nodeName" => "features", + "value" => "TestFeatures" + ] + ], + "stories" => [ + [ + "nodeName" => "stories", + "value" => "TestStories" + ] + ], + "title" => [ + [ + "nodeName" => "title", + "value" => "TEST TITLE" + ] + ], + "severity" => [ + [ + "nodeName" => "severity", + "value" => "CRITICAL" + ] + ], + "testCaseId" => [ + [ + "nodeName" => "testCaseId", + "value" => "MQE-0001" + ] + ], + ]; + // Perform Test + $extractor = new AnnotationExtractor(); + $extractor->extractAnnotations($firstTestAnnotation, "firstTest"); + $extractor->extractAnnotations($secondTestannotation, "secondTest"); + + //Expect Exception + $this->expectException(\Magento\FunctionalTestingFramework\Exceptions\XmlException::class); + $this->expectExceptionMessage("TestCaseId and Title pairs must be unique:\n\n" . + "TestCaseId: 'MQE-0001' Title: 'TEST TITLE' in Tests 'firstTest', 'secondTest'"); + + //Trigger Exception + $extractor->validateTestCaseIdTitleUniqueness(); + } + /** * After class functionality * @return void diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ObjectExtensionUtilTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ObjectExtensionUtilTest.php index 4b350e5a6..c3d418516 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ObjectExtensionUtilTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Util/ObjectExtensionUtilTest.php @@ -43,12 +43,14 @@ public function testGenerateExtendedTest() $testDataArrayBuilder = new TestDataArrayBuilder(); $mockSimpleTest = $testDataArrayBuilder - ->withName('simpleTest') - ->withTestActions($mockActions) - ->build(); + ->withName('simpleTest') + ->withAnnotations(['title'=>[['value' => 'simpleTest']]]) + ->withTestActions($mockActions) + ->build(); $mockExtendedTest = $testDataArrayBuilder ->withName('extendedTest') + ->withAnnotations(['title'=>[['value' => 'extendedTest']]]) ->withTestReference("simpleTest") ->build(); @@ -86,12 +88,14 @@ public function testGenerateExtendedWithHooks() $testDataArrayBuilder = new TestDataArrayBuilder(); $mockSimpleTest = $testDataArrayBuilder ->withName('simpleTest') + ->withAnnotations(['title'=>[['value' => 'simpleTest']]]) ->withBeforeHook($mockBeforeHooks) ->withAfterHook($mockAfterHooks) ->build(); $mockExtendedTest = $testDataArrayBuilder ->withName('extendedTest') + ->withAnnotations(['title'=>[['value' => 'extendedTest']]]) ->withTestReference("simpleTest") ->build(); @@ -154,12 +158,14 @@ public function testExtendingExtendedTest() $mockSimpleTest = $testDataArrayBuilder ->withName('simpleTest') + ->withAnnotations(['title'=>[['value' => 'simpleTest']]]) ->withTestActions() ->withTestReference("anotherTest") ->build(); $mockExtendedTest = $testDataArrayBuilder ->withName('extendedTest') + ->withAnnotations(['title'=>[['value' => 'extendedTest']]]) ->withTestReference("simpleTest") ->build(); 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/ActionGroupSkipReadiness.txt b/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt new file mode 100644 index 000000000..b787f9116 --- /dev/null +++ b/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt @@ -0,0 +1,34 @@ +skipReadinessCheck(true); + $I->comment("ActionGroupSkipReadiness"); + $I->skipReadinessCheck(false); + } +} 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..f0d14dbd9 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; @@ -20,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 @@ -37,13 +25,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..3bc708a1a 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithDataOverrideTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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..e79534bad 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithDataTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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..db3c6325c 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("Action Group With Default Argument Value and Hardcoded Value in Param") + * @Title("[NO TESTCASEID]: Action Group With Default Argument Value and Hardcoded Value in Param") */ class ActionGroupWithDefaultArgumentAndStringSelectorParamCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt index 620bbf5f5..e446cc407 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("Action Group With Passed Argument Value and Multiple Argument Values in Param") + * @Title("[NO TESTCASEID]: Action Group With Passed Argument Value and Multiple Argument Values in Param") */ class ActionGroupWithMultipleParameterSelectorsFromDefaultArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt b/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt index b0f709ac9..39e4bda89 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("Action Group With No Argument") + * @Title("[NO TESTCASEID]: Action Group With No Argument") */ class ActionGroupWithNoArgumentsCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt index a5119c368..ed02790e5 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithNoDefaultTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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..157690bee 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("Action Group With Passed Argument Value and Hardcoded Value in Param") + * @Title("[NO TESTCASEID]: Action Group With Passed Argument Value and Hardcoded Value in Param") */ class ActionGroupWithPassedArgumentAndStringSelectorParamCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt index 133553573..5ed6eb7f7 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithPersistedDataCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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 +68,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..a71cd562f 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("Action Group With Simple Data Usage From Default Argument") + * @Title("[NO TESTCASEID]: Action Group With Simple Data Usage From Default Argument") */ class ActionGroupWithSimpleDataUsageFromDefaultArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt index d3b910c0a..1453d716f 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("Action Group With Simple Data Usage From Passed Argument") + * @Title("[NO TESTCASEID]: Action Group With Simple Data Usage From Passed Argument") */ class ActionGroupWithSimpleDataUsageFromPassedArgumentCest { @@ -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..86be7fb72 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("Action Group With Default Argument Value and Argument Value in Param") + * @Title("[NO TESTCASEID]: Action Group With Default Argument Value and Argument Value in Param") */ class ActionGroupWithSingleParameterSelectorFromDefaultArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt index 7900385db..9a30bcc5c 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("Action Group With Passed Argument Value and Argument Value in Param") + * @Title("[NO TESTCASEID]: Action Group With Passed Argument Value and Argument Value in Param") */ class ActionGroupWithSingleParameterSelectorFromPassedArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt index 28bb00d4d..542e20133 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,60 @@ 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('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); + $date = new \DateTime(); + $date->setTimestamp(strtotime("{$action5}")); + $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: {$action7ActionGroupActionGroup}"); + PersistedObjectHandler::getInstance()->deleteEntity( + "{$action7ActionGroupActionGroup}", + "test" + ); + $I->amGoingTo("get entity that has the stepKey: action8ActionGroup"); + PersistedObjectHandler::getInstance()->getEntity( + "action8ActionGroup", + "test", + "{$action8}", + [], + null + ); + $I->amGoingTo("update entity that has the createdDataKey: 1"); + PersistedObjectHandler::getInstance()->updateEntity( + "1", + "test", + "{$action9}", + [] + ); + $I->amGoingTo("create entity that has the stepKey: action10ActionGroup"); + PersistedObjectHandler::getInstance()->createEntity( + "action10ActionGroup", + "test", + "{$action10}", + [], + null + ); + $action11ActionGroup = $I->grabAttributeFrom($action11ActionGroup, "someInput"); + $action12ActionGroup = $I->grabCookie($action12ActionGroup, ['domain' => 'www.google.com']); + $action13ActionGroup = $I->grabFromCurrentUrl($action13ActionGroup); + $action14ActionGroup = $I->grabMultiple($action14ActionGroup); + $action15ActionGroup = $I->grabTextFrom($action15ActionGroup); + $action16ActionGroup = $I->grabValueFrom($action16ActionGroup); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt index 4ec6520d9..acc274567 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ActionGroupWithTopLevelPersistedDataCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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 +67,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..80a1d3c80 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class ArgumentWithSameNameAsElementCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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..adc764975 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; @@ -20,11 +18,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class AssertTestCest { - /** - * @var DataPersistenceHandler $createData1; - */ - protected $createData1; - /** * @param AcceptanceTester $I * @throws \Exception @@ -32,9 +25,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 +44,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 +131,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 +147,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..d6d953a88 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class BasicActionGroupTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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 7fed6db42..197a645cc 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("A Functional Cest") + * @Title("[NO TESTCASEID]: A Functional Cest") * @group functional */ class BasicFunctionalTestCest @@ -62,6 +60,9 @@ class BasicFunctionalTestCest { $I->comment(""); $I->comment(""); + $I->skipReadinessCheck(true); + $I->comment("skipReadiness"); + $I->skipReadinessCheck(false); $someVarDefinition = $I->grabValueFrom(); $I->acceptPopup(); $I->amOnPage("/test/url"); @@ -77,7 +78,10 @@ class BasicFunctionalTestCest $I->closeTab(); $I->conditionalClick(".functionalTestSelector", ".functionalDependentTestSelector", true); $I->amGoingTo("delete entity that has the createDataKey: createKey1"); - $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..039e31a58 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("BasicMergeTest") + * @Title("[NO TESTCASEID]: BasicMergeTest") * @group functional * @group mergeTest */ 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..27c9a99c6 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ChildExtendedTestAddHooks") + * @Title("[NO TESTCASEID]: ChildExtendedTestAddHooks") * @group Parent */ class ChildExtendedTestAddHooksCest diff --git a/dev/tests/verification/Resources/ChildExtendedTestMerging.txt b/dev/tests/verification/Resources/ChildExtendedTestMerging.txt index caf382718..788818272 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ChildExtendedTestMerging") + * @Title("[NO TESTCASEID]: ChildExtendedTestMerging") * @group Child */ class ChildExtendedTestMergingCest diff --git a/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt b/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt index 3ab774b3d..cea7ffeca 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ChildExtendedTestNoParent") + * @Title("[NO TESTCASEID]: ChildExtendedTestNoParent") * @group Child * @group skip */ diff --git a/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt b/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt index 4fefcd657..40a3184c9 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ChildExtendedTestRemoveAction") + * @Title("[NO TESTCASEID]: ChildExtendedTestRemoveAction") * @group Child */ class ChildExtendedTestRemoveActionCest diff --git a/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt b/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt index 5f135c6d7..7419e681a 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ChildExtendedTestRemoveHookAction") + * @Title("[NO TESTCASEID]: ChildExtendedTestRemoveHookAction") * @group Child */ class ChildExtendedTestRemoveHookActionCest diff --git a/dev/tests/verification/Resources/ChildExtendedTestReplace.txt b/dev/tests/verification/Resources/ChildExtendedTestReplace.txt index 650544131..18b1984c0 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ChildExtendedTestReplace") + * @Title("[NO TESTCASEID]: ChildExtendedTestReplace") * @group Child */ class ChildExtendedTestReplaceCest diff --git a/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt b/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt index 9c05eb88e..90ebf3676 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ChildExtendedTestReplaceHook") + * @Title("[NO TESTCASEID]: ChildExtendedTestReplaceHook") * @group Child */ class ChildExtendedTestReplaceHookCest diff --git a/dev/tests/verification/Resources/DataActionsTest.txt b/dev/tests/verification/Resources/DataActionsTest.txt new file mode 100644 index 000000000..cac3b72cd --- /dev/null +++ b/dev/tests/verification/Resources/DataActionsTest.txt @@ -0,0 +1,91 @@ +amGoingTo("create entity that has the stepKey: createdInBefore"); + PersistedObjectHandler::getInstance()->createEntity( + "createdInBefore", + "hook", + "entity", + [], + null + ); + $I->amGoingTo("update entity that has the createdDataKey: createdInBefore"); + PersistedObjectHandler::getInstance()->updateEntity( + "createdInBefore", + "hook", + "entity", + [] + ); + $I->amGoingTo("delete entity that has the createDataKey: createdInBefore"); + PersistedObjectHandler::getInstance()->deleteEntity( + "createdInBefore", + "hook" + ); + } + + /** + * @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"); + PersistedObjectHandler::getInstance()->createEntity( + "createdInTest", + "test", + "entity", + [], + null + ); + $I->amGoingTo("update entity that has the createdDataKey: createdInTest"); + PersistedObjectHandler::getInstance()->updateEntity( + "createdInTest", + "test", + "entity", + [] + ); + $I->amGoingTo("delete entity that has the createDataKey: createdInTest"); + PersistedObjectHandler::getInstance()->deleteEntity( + "createdInTest", + "test" + ); + $I->amGoingTo("update entity that has the createdDataKey: createdInBefore"); + PersistedObjectHandler::getInstance()->updateEntity( + "createdInBefore", + "test", + "entity", + [] + ); + $I->amGoingTo("delete entity that has the createDataKey: createdInBefore"); + 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 371eb3d0d..6dd8ef3db 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; @@ -31,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')"); } } 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..2275de057 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ChildExtendedTestSkippedParent") + * @Title("[NO TESTCASEID]: ChildExtendedTestSkippedParent") * @group Child */ class ExtendingSkippedTestCest diff --git a/dev/tests/verification/Resources/HookActionsTest.txt b/dev/tests/verification/Resources/HookActionsTest.txt index 76947ce61..70e4ece10 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; @@ -20,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 @@ -37,22 +25,28 @@ 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 + ); } - /** - * @var DataPersistenceHandler $sampleCreateAfter; - */ - protected $sampleCreateAfter; - /** * @param AcceptanceTester $I * @throws \Exception @@ -60,11 +54,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..2d1748f56 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class MergedActionGroupTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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..3f47703b9 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("MergedReferencesTest") + * @Title("[NO TESTCASEID]: MergedReferencesTest") * @group functional */ class MergedReferencesTestCest diff --git a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt index 1b5a74c94..5084692be 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; @@ -21,11 +19,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class MultipleActionGroupsTestCest { - /** - * @var DataPersistenceHandler $createPersonParam; - */ - protected $createPersonParam; - /** * @param AcceptanceTester $I * @throws \Exception @@ -33,9 +26,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..c3d7217b3 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("ParentExtendedTest") + * @Title("[NO TESTCASEID]: ParentExtendedTest") * @group Parent */ class ParentExtendedTestCest 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..c19e33ee7 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; @@ -20,11 +18,6 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; */ class PersistedReplacementTestCest { - /** - * @var DataPersistenceHandler $createData1; - */ - protected $createData1; - /** * @param AcceptanceTester $I * @throws \Exception @@ -32,9 +25,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 +44,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/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 eb9f2d234..24faac699 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; @@ -20,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 @@ -39,14 +27,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 +57,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..1b466d4e0 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("skippedTest") + * @Title("[NO TESTCASEID]: skippedTest") * @Description("") */ class SkippedTestCest diff --git a/dev/tests/verification/Resources/SkippedTestNoIssues.txt b/dev/tests/verification/Resources/SkippedTestNoIssues.txt index 8d22ca415..b68823d39 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("skippedNoIssuesTest") + * @Title("[NO TESTCASEID]: skippedNoIssuesTest") * @Description("") * @group skip */ diff --git a/dev/tests/verification/Resources/SkippedTestTwoIssues.txt b/dev/tests/verification/Resources/SkippedTestTwoIssues.txt index cd140e440..dbe3ea054 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("skippedMultipleIssuesTest") + * @Title("[NO TESTCASEID]: skippedMultipleIssuesTest") * @Description("") */ class SkippedTestTwoIssuesCest diff --git a/dev/tests/verification/Resources/SkippedTestWithHooks.txt b/dev/tests/verification/Resources/SkippedTestWithHooks.txt index d28c61486..ab6d241e3 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; @@ -17,7 +15,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Title("skippedTestWithHooks") + * @Title("[NO TESTCASEID]: skippedTestWithHooks") * @Description("") */ class SkippedTestWithHooksCest diff --git a/dev/tests/verification/Resources/functionalSuiteHooks.txt b/dev/tests/verification/Resources/functionalSuiteHooks.txt index b85f9e578..665f06a05 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,13 @@ 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->click(PersistedObjectHandler::getInstance()->retrieveEntityField('create', 'data', 'suite')); $webDriver->see("John", msq("uniqueData") . "John"); // reset configuration and close session @@ -123,6 +125,7 @@ class functionalSuiteHooks extends \Codeception\GroupObject print $exception->getMessage(); } + PersistedObjectHandler::getInstance()->clearSuiteObjects(); print sprintf(self::$HOOK_EXECUTION_END, "after"); } } diff --git a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml index 5b5ddf775..75ac71ef2 100644 --- a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml @@ -114,4 +114,8 @@ + + + + diff --git a/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml index 5e1a20f96..728b606b2 100644 --- a/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/FunctionalActionGroup.xml @@ -49,6 +49,24 @@ + + + + + + + + + + + + + + + + + + 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/ActionGroupTest.xml b/dev/tests/verification/TestModule/Test/ActionGroupTest.xml index ccace672b..848fe8bcc 100644 --- a/dev/tests/verification/TestModule/Test/ActionGroupTest.xml +++ b/dev/tests/verification/TestModule/Test/ActionGroupTest.xml @@ -144,6 +144,10 @@ + + + + diff --git a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml index 0a2676ef6..322c5ac74 100644 --- a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml @@ -24,6 +24,7 @@ + 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/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/ActionGroupGenerationTest.php b/dev/tests/verification/Tests/ActionGroupGenerationTest.php index d7b57baed..65d65d04d 100644 --- a/dev/tests/verification/Tests/ActionGroupGenerationTest.php +++ b/dev/tests/verification/Tests/ActionGroupGenerationTest.php @@ -184,4 +184,15 @@ public function testActionGroupWithArgContainingStepKey() { $this->generateAndCompareTest('ActionGroupContainsStepKeyInArgText'); } + + /** + * Test an action group with an arg containing stepKey text + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testActionGroupWithSkipReadiness() + { + $this->generateAndCompareTest('ActionGroupSkipReadiness'); + } } 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/dev/tests/verification/Tests/ExtendedGenerationTest.php b/dev/tests/verification/Tests/ExtendedGenerationTest.php index 46246c45b..e7bb0a879 100644 --- a/dev/tests/verification/Tests/ExtendedGenerationTest.php +++ b/dev/tests/verification/Tests/ExtendedGenerationTest.php @@ -5,6 +5,8 @@ */ namespace tests\verification\Tests; +use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler; +use Magento\FunctionalTestingFramework\Util\TestGenerator; use tests\util\MftfTestCase; class ExtendedGenerationTest extends MftfTestCase @@ -87,14 +89,23 @@ public function testExtendedTestGenerationRemoveHookAction() } /** - * Tests generation of test that attemps to extend a test that doesn't exist + * Tests to ensure extended tests with no parents are not generated * * @throws \Exception * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException */ public function testExtendedTestGenerationNoParent() { - $this->generateAndCompareTest('ChildExtendedTestNoParent'); + $testObject = TestObjectHandler::getInstance()->getObject('ChildExtendedTestNoParent'); + $test = TestGenerator::getInstance(null, [$testObject]); + $test->createAllTestFiles(); + + $cestFile = $test->getExportDir() . + DIRECTORY_SEPARATOR . + $testObject->getCodeceptionName() . + ".php"; + + $this->assertFalse(file_exists($cestFile)); } /** 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/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/etc/config/command.php b/etc/config/command.php index 6b8208f55..b24bafd31 100644 --- a/etc/config/command.php +++ b/etc/config/command.php @@ -11,7 +11,7 @@ } else { $arguments = null; } - $php = PHP_BINARY ?: (PHP_BINDIR ? PHP_BINDIR . '/php' : 'php'); + $php = PHP_BINDIR ? PHP_BINDIR . '/php' : 'php'; $valid = validateCommand($command); if ($valid) { exec( @@ -60,7 +60,7 @@ function escapeCommand($command) */ function validateCommand($command) { - $php = PHP_BINARY ?: (PHP_BINDIR ? PHP_BINDIR . '/php' : 'php'); + $php = PHP_BINDIR ? PHP_BINDIR . '/php' : 'php'; exec($php . ' -f ../../../../bin/magento list', $commandList); // Trim list of commands after first whitespace $commandList = array_map("trimAfterWhitespace", $commandList); diff --git a/src/Magento/FunctionalTestingFramework/Config/Dom.php b/src/Magento/FunctionalTestingFramework/Config/Dom.php index 1305574cc..566fbd5b3 100644 --- a/src/Magento/FunctionalTestingFramework/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/Config/Dom.php @@ -6,6 +6,8 @@ namespace Magento\FunctionalTestingFramework\Config; +use Magento\FunctionalTestingFramework\Config\Dom\ValidationException; + /** * Magento configuration XML DOM utility */ @@ -354,13 +356,21 @@ public function getDom() * Create DOM document based on $xml parameter * * @param string $xml + * @param string $filename * @return \DOMDocument * @throws \Magento\FunctionalTestingFramework\Config\Dom\ValidationException */ - protected function initDom($xml) + protected function initDom($xml, $filename = null) { $dom = new \DOMDocument(); - $dom->loadXML($xml); + try { + $domSuccess = $dom->loadXML($xml); + if (!$domSuccess) { + throw new \Exception(); + } + } catch (\Exception $exception) { + throw new ValidationException("XML Parse Error: $filename\n"); + } if ($this->schemaFile) { $errors = self::validateDomDocument($dom, $this->schemaFile, $this->errorFormat); if (count($errors)) { diff --git a/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php b/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php new file mode 100644 index 000000000..d4044c74b --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php @@ -0,0 +1,52 @@ +addOption( + 'remove', + 'r', + InputOption::VALUE_NONE, + 'remove previous generated suites and tests' + ); + } + + /** + * Remove GENERATED_DIR if exists when running generate:tests. + * + * @param OutputInterface $output + * @param bool $verbose + * @return void + */ + protected function removeGeneratedDirectory(OutputInterface $output, bool $verbose) + { + $generatedDirectory = TESTS_MODULE_PATH . DIRECTORY_SEPARATOR . TestGenerator::GENERATED_DIR; + + if (file_exists($generatedDirectory)) { + DirSetupUtil::rmdirRecursive($generatedDirectory); + if ($verbose) { + $output->writeln("removed files and directory $generatedDirectory"); + } + } + } +} diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php index ca9be1fac..815133e4d 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php @@ -8,12 +8,11 @@ namespace Magento\FunctionalTestingFramework\Console; use Magento\FunctionalTestingFramework\Suite\SuiteGenerator; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -class GenerateSuiteCommand extends Command +class GenerateSuiteCommand extends BaseGenerateCommand { /** * Configures the current command. @@ -29,6 +28,8 @@ protected function configure() InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'argument which indicates suite names for generation (separated by space)' ); + + parent::configure(); } /** @@ -41,6 +42,13 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + $remove = $input->getOption('remove'); + + // Remove previous GENERATED_DIR if --remove option is used + if ($remove) { + $this->removeGeneratedDirectory($output, $output->isVerbose()); + } + $suites = $input->getArgument('suites'); foreach ($suites as $suite) { diff --git a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php index 845fb5151..fcd977060 100644 --- a/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php @@ -14,13 +14,12 @@ use Magento\FunctionalTestingFramework\Util\Manifest\ParallelTestManifest; use Magento\FunctionalTestingFramework\Util\Manifest\TestManifestFactory; use Magento\FunctionalTestingFramework\Util\TestGenerator; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class GenerateTestsCommand extends Command +class GenerateTestsCommand extends BaseGenerateCommand { /** * Configures the current command. @@ -52,7 +51,14 @@ protected function configure() 't', InputOption::VALUE_REQUIRED, 'A parameter accepting a JSON string used to determine the test configuration' - )->addOption('debug', 'd', InputOption::VALUE_NONE, 'run extra validation when generating tests'); + )->addOption( + 'debug', + 'd', + InputOption::VALUE_NONE, + 'run extra validation when generating tests' + ); + + parent::configure(); } /** @@ -73,6 +79,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $force = $input->getOption('force'); $time = $input->getOption('time') * 60 * 1000; // convert from minutes to milliseconds $debug = $input->getOption('debug'); + $remove = $input->getOption('remove'); + $verbose = $output->isVerbose(); if ($json !== null && !json_decode($json)) { @@ -85,6 +93,11 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new TestFrameworkException("time option cannot be less than or equal to 0"); } + // Remove previous GENERATED_DIR if --remove option is used + if ($remove) { + $this->removeGeneratedDirectory($output, $verbose || $debug); + } + $testConfiguration = $this->createTestConfiguration($json, $tests, $force, $debug, $verbose); // create our manifest file here @@ -153,7 +166,6 @@ private function createTestConfiguration($json, array $tests, bool $force, bool * * @param string $json * @param array $testConfiguration - * @throws TestFrameworkException * @return array */ private function parseTestsConfigJson($json, array $testConfiguration) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php index 9bf250ed0..097d7dfd8 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php @@ -7,16 +7,15 @@ namespace Magento\FunctionalTestingFramework\Console; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Debug\Debug; use Symfony\Component\Process\Process; +use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; -class RunTestCommand extends Command +class RunTestCommand extends BaseGenerateCommand { /** * Configures the current command. @@ -38,6 +37,8 @@ protected function configure() InputOption::VALUE_NONE, 'force generation of tests regardless of Magento Instance Configuration' ); + + parent::configure(); } /** @@ -55,6 +56,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $tests = $input->getArgument('name'); $skipGeneration = $input->getOption('skip-generate'); $force = $input->getOption('force'); + $remove = $input->getOption('remove'); + + if ($skipGeneration and $remove) { + // "skip-generate" and "remove" options cannot be used at the same time + throw new TestFrameworkException( + "\"skip-generate\" and \"remove\" options can not be used at the same time." + ); + } if (!$skipGeneration) { $command = $this->getApplication()->find('generate:tests'); @@ -63,7 +72,8 @@ protected function execute(InputInterface $input, OutputInterface $output) 'tests' => $tests, 'suites' => null ]), - '--force' => $force + '--force' => $force, + '--remove' => $remove ]; $command->run(new ArrayInput($args), $output); } diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php index 110b86565..3098569fb 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php @@ -10,15 +10,15 @@ use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler; -use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\Process; +use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; -class RunTestGroupCommand extends Command +class RunTestGroupCommand extends BaseGenerateCommand { /** * Configures the current command. @@ -44,6 +44,8 @@ protected function configure() InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'group names to be executed via codeception' ); + + parent::configure(); } /** @@ -61,6 +63,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $skipGeneration = $input->getOption('skip-generate'); $force = $input->getOption('force'); $groups = $input->getArgument('groups'); + $remove = $input->getOption('remove'); + + if ($skipGeneration and $remove) { + // "skip-generate" and "remove" options cannot be used at the same time + throw new TestFrameworkException( + "\"skip-generate\" and \"remove\" options can not be used at the same time." + ); + } // Create Mftf Configuration MftfApplicationConfig::create( @@ -75,7 +85,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $command = $this->getApplication()->find('generate:tests'); $args = [ '--tests' => $testConfiguration, - '--force' => $force + '--force' => $force, + '--remove' => $remove ]; $command->run(new ArrayInput($args), $output); diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Config/Dom.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Config/Dom.php index 1da3e9c0e..abef7390a 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Config/Dom.php @@ -65,7 +65,7 @@ public function __construct( */ public function initDom($xml, $filename = null) { - $dom = parent::initDom($xml); + $dom = parent::initDom($xml, $filename); if (strpos($filename, self::DATA_FILE_NAME_ENDING)) { $entityNodes = $dom->getElementsByTagName('entity'); diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Config/OperationDom.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Config/OperationDom.php index f4617c61e..98694ea47 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Config/OperationDom.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Config/OperationDom.php @@ -65,7 +65,7 @@ public function __construct( */ public function initDom($xml, $filename = null) { - $dom = parent::initDom($xml); + $dom = parent::initDom($xml, $filename); if (strpos($filename, self::METADATA_FILE_NAME_ENDING)) { $operationNodes = $dom->getElementsByTagName('operation'); diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php new file mode 100644 index 000000000..64bb5f0a0 --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -0,0 +1,236 @@ + 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; + } elseif ($scope == self::HOOK_SCOPE) { + $this->hookObjects[$key] = $persistedObject; + } else { + $this->suiteObjects[$key] = $persistedObject; + } + } + + /** + * Retrieves and updates a previously created entity. + * @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 = []) + { + $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; + } elseif ($scope == self::HOOK_SCOPE) { + $this->hookObjects[$key] = $persistedObject; + } else { + $this->suiteObjects[$key] = $persistedObject; + } + } + + /** + * Retrieves a field from an entity, according to key and scope given. + * @param string $stepKey + * @param string $field + * @param string $scope + * @return string + * @throws TestReferenceException + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException + */ + public function retrieveEntityField($stepKey, $field, $scope) + { + return $this->retrieveEntity($stepKey, $scope)->getCreatedDataByName($field); + } + + /** + * Attempts to retrieve Entity from given scope, falling back to outer scopes if not found. + * @param string $stepKey + * @param string $scope + * @return DataPersistenceHandler + * @throws TestReferenceException + */ + private function retrieveEntity($stepKey, $scope) + { + // 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($stepKey, $entityArray)) { + return $entityArray[$stepKey]; + } + } + + throw new TestReferenceException("Entity with a CreateDataKey of {$stepKey} could not be found"); + } + + /** + * Clears store of all test persisted Objects + * @return void + */ + public function clearTestObjects() + { + $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/PageReadinessExtension.php b/src/Magento/FunctionalTestingFramework/Extension/PageReadinessExtension.php index 9b9163a0a..709647096 100644 --- a/src/Magento/FunctionalTestingFramework/Extension/PageReadinessExtension.php +++ b/src/Magento/FunctionalTestingFramework/Extension/PageReadinessExtension.php @@ -43,6 +43,7 @@ class PageReadinessExtension extends Extension */ private $ignoredActions = [ 'saveScreenshot', + 'skipReadinessCheck', 'wait' ]; @@ -119,6 +120,8 @@ public function beforeTest(TestEvent $e) $this->testName = $e->getTest()->getMetadata()->getName(); $this->uri = null; + $this->getDriver()->_setConfig(['skipReadiness' => false]); + $metrics = []; foreach ($this->config['readinessMetrics'] as $metricClass) { $metrics[] = new $metricClass($this, $failThreshold); @@ -137,7 +140,8 @@ public function beforeTest(TestEvent $e) public function beforeStep(StepEvent $e) { $step = $e->getStep(); - if ($this->shouldSkipCheck($step)) { + $manualSkip = $this->getDriver()->_getConfig()['skipReadiness']; + if ($this->shouldSkipCheck($step, $manualSkip)) { return; } @@ -234,12 +238,13 @@ public function getTestName() * Should the given step bypass the readiness checks * todo: Implement step parameter to bypass specific metrics (or all) instead of basing on action type * - * @param Step $step + * @param Step $step + * @param boolean $manualSkip * @return boolean */ - private function shouldSkipCheck($step) + private function shouldSkipCheck($step, $manualSkip) { - if ($step instanceof Step\Comment || in_array($step->getAction(), $this->ignoredActions)) { + if ($step instanceof Step\Comment || in_array($step->getAction(), $this->ignoredActions) || $manualSkip) { return true; } return false; diff --git a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php index d6f365d99..07f177dc3 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; use Magento\FunctionalTestingFramework\Module\MagentoWebDriver; @@ -26,11 +27,23 @@ 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' + Events::TEST_END => 'testEnd' ]; + /** + * Codeception event listener function, triggered on test start. + * @throws \Exception + * @return void + */ + public function testStart() + { + PersistedObjectHandler::getInstance()->clearHookObjects(); + PersistedObjectHandler::getInstance()->clearTestObjects(); + } + /** * Codeception event listener function, triggered on test failure. * @param \Codeception\Event\FailEvent $e @@ -48,11 +61,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/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 269c3a60a..cab4bb7e3 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -19,6 +19,7 @@ use Magento\FunctionalTestingFramework\Util\Protocol\CurlInterface; use Magento\FunctionalTestingFramework\Util\ConfigSanitizerUtil; use Yandex\Allure\Adapter\Support\AttachmentSupport; +use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; /** * MagentoWebDriver module provides common Magento web actions through Selenium WebDriver. @@ -319,6 +320,7 @@ public function searchAndMultiSelectOption($select, array $options, $requireActi * @param string $selectSearchTextField * @param string $selectSearchResult * @param string[] $options + * @throws \Exception * @return void */ public function selectMultipleOptions($selectSearchTextField, $selectSearchResult, array $options) @@ -474,14 +476,17 @@ public function scrollToTopOfPage() * Takes given $command and executes it against exposed MTF CLI entry point. Returns response from server. * @param string $command * @param string $arguments + * @throws TestFrameworkException * @return string */ public function magentoCLI($command, $arguments = null) { - // trim everything after first '/' in URL after (ex http://magento.instance/) - preg_match("/.+\/\/[^\/]+\/?/", $this->config['url'], $trimmed); - $trimmedUrl = $trimmed[0]; - $apiURL = $trimmedUrl . ltrim(getenv('MAGENTO_CLI_COMMAND_PATH'), '/'); + // Remove index.php if it's present in url + $baseUrl = rtrim( + str_replace('index.php', '', rtrim($this->config['url'], '/')), + '/' + ); + $apiURL = $baseUrl . '/' . ltrim(getenv('MAGENTO_CLI_COMMAND_PATH'), '/'); $executor = new CurlTransport(); $executor->write( @@ -501,6 +506,7 @@ public function magentoCLI($command, $arguments = null) /** * Runs DELETE request to delete a Magento entity against the url given. * @param string $url + * @throws TestFrameworkException * @return string */ public function deleteEntityByUrl($url) @@ -690,4 +696,16 @@ public function amOnPage($page) parent::amOnPage($page); $this->waitForPageLoad(); } + + /** + * Turn Readiness check on or off + * + * @param boolean $check + * @throws \Exception + * @return void + */ + public function skipReadinessCheck($check) + { + $this->config['skipReadiness'] = $check; + } } diff --git a/src/Magento/FunctionalTestingFramework/Page/Config/Dom.php b/src/Magento/FunctionalTestingFramework/Page/Config/Dom.php index 0226a286a..0d8739636 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/Page/Config/Dom.php @@ -76,7 +76,7 @@ public function __construct( */ public function initDom($xml, $filename = null) { - $dom = parent::initDom($xml); + $dom = parent::initDom($xml, $filename); $pagesNode = $dom->getElementsByTagName('pages')->item(0); $this->validationUtil->validateChildUniqueness($pagesNode, $filename); diff --git a/src/Magento/FunctionalTestingFramework/Page/Config/SectionDom.php b/src/Magento/FunctionalTestingFramework/Page/Config/SectionDom.php index 7115adb34..c3476e7dd 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Config/SectionDom.php +++ b/src/Magento/FunctionalTestingFramework/Page/Config/SectionDom.php @@ -67,7 +67,7 @@ public function __construct( */ public function initDom($xml, $filename = null) { - $dom = parent::initDom($xml); + $dom = parent::initDom($xml, $filename); $sectionNodes = $dom->getElementsByTagName('section'); foreach ($sectionNodes as $sectionNode) { $sectionNode->setAttribute(self::SECTION_META_FILENAME_ATTRIBUTE, $filename); diff --git a/src/Magento/FunctionalTestingFramework/Suite/Generators/GroupClassGenerator.php b/src/Magento/FunctionalTestingFramework/Suite/Generators/GroupClassGenerator.php index 2b9662a1a..a84f6b1b3 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/Generators/GroupClassGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Suite/Generators/GroupClassGenerator.php @@ -129,9 +129,8 @@ private function extractClassVar($beforeArray, $afterArray) */ private function buildHookMustacheArray($hookObj) { - $mustacheHookArray = []; $actions = []; - $hasWebDriverActions = false; + $mustacheHookArray['actions'][] = ['webDriverInit' => true]; foreach ($hookObj->getActions() as $action) { /** @var ActionObject $action */ @@ -139,10 +138,6 @@ private function buildHookMustacheArray($hookObj) //deleteData contains either url or createDataKey, if it contains the former it needs special formatting if ($action->getType() !== "createData" && !array_key_exists(TestGenerator::REQUIRED_ENTITY_REFERENCE, $action->getCustomActionAttributes())) { - if (!$hasWebDriverActions) { - $hasWebDriverActions = true; - } - $actions = $this->buildWebDriverActionsMustacheArray($action, $actions, $index); continue; } @@ -159,11 +154,8 @@ private function buildHookMustacheArray($hookObj) $entityArray = $this->buildPersistenceMustacheArray($action, $entityArray); $actions[$index] = $entityArray; } - $mustacheHookArray['actions'] = $actions; - if ($hasWebDriverActions) { - array_unshift($mustacheHookArray['actions'], ['webDriverInit' => true]); - $mustacheHookArray['actions'][] = ['webDriverReset' => true]; - } + $mustacheHookArray['actions'] = array_merge($mustacheHookArray['actions'], $actions); + $mustacheHookArray['actions'][] = ['webDriverReset' => true]; return $mustacheHookArray; } @@ -179,7 +171,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 1cbe5c775..953db9d0c 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) @@ -101,6 +97,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 37dbcfbef..2ed5e8d5e 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/views/partials/testActions.mustache +++ b/src/Magento/FunctionalTestingFramework/Suite/views/partials/testActions.mustache @@ -15,11 +15,18 @@ $webDriver->_initializeSession(); {{{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/Test/Config/ActionGroupDom.php b/src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php index ab8bc66f5..36f7a4384 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php +++ b/src/Magento/FunctionalTestingFramework/Test/Config/ActionGroupDom.php @@ -26,7 +26,7 @@ class ActionGroupDom extends Dom */ public function initDom($xml, $filename = null) { - $dom = parent::initDom($xml); + $dom = parent::initDom($xml, $filename); if (strpos($filename, self::ACTION_GROUP_FILE_NAME_ENDING)) { $actionGroupNodes = $dom->getElementsByTagName('actionGroup'); diff --git a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php index ae301b5b1..828586b3c 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php +++ b/src/Magento/FunctionalTestingFramework/Test/Config/Dom.php @@ -79,7 +79,7 @@ public function __construct( */ public function initDom($xml, $filename = null) { - $dom = parent::initDom($xml); + $dom = parent::initDom($xml, $filename); if (strpos($filename, self::TEST_FILE_NAME_ENDING)) { $testNodes = $dom->getElementsByTagName('test'); diff --git a/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php b/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php index 8e97b27d8..19cd025c9 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Test/Handlers/TestObjectHandler.php @@ -151,6 +151,7 @@ private function initTestData() $exceptionCollector->throwException(); $testObjectExtractor->getAnnotationExtractor()->validateStoryTitleUniqueness(); + $testObjectExtractor->getAnnotationExtractor()->validateTestCaseIdTitleUniqueness(); } /** diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index 659cc0a74..2b63709fc 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -19,6 +19,23 @@ class ActionGroupObject { const ACTION_GROUP_ORIGIN_NAME = "actionGroupName"; const ACTION_GROUP_ORIGIN_TEST_REF = "testInvocationRef"; + const STEPKEY_REPLACEMENT_ENABLED_TYPES = [ + "executeJS", + "magentoCLI", + "generateDate", + "formatMoney", + "deleteData", + "getData", + "updateData", + "createData", + "grabAttributeFrom", + "grabCookie", + "grabFromCurrentUrl", + "grabMultiple", + "grabPageSource", + "grabTextFrom", + "grabValueFrom" + ]; /** * Array of variable-enabled attributes. @@ -372,7 +389,12 @@ public function extractStepKeys() { $originalKeys = []; foreach ($this->parsedActions as $action) { - $originalKeys[] = $action->getStepKey(); + //limit actions returned to list that are relevant + foreach (self::STEPKEY_REPLACEMENT_ENABLED_TYPES as $actionValue) { + if ($actionValue === $action->getType()) { + $originalKeys[] = $action->getStepKey(); + } + } } return $originalKeys; } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index f229ccf8a..9f851b130 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -521,7 +521,11 @@ private function findAndReplaceReferences($objectHandler, $inputString) } elseif (get_class($obj) == SectionObject::class) { list(,$objField) = $this->stripAndSplitReference($match); if ($obj->getElement($objField) == null) { - throw new TestReferenceException("Could not resolve entity reference", ["input" => $inputString]); + throw new TestReferenceException( + "Could not resolve entity reference \"{$inputString}\" " + . "in Action with stepKey \"{$this->getStepKey()}\"", + ["input" => $inputString, "stepKey" => $this->getStepKey()] + ); } $parameterized = $obj->getElement($objField)->isParameterized(); $replacement = $obj->getElement($objField)->getPrioritizedSelector(); @@ -538,7 +542,11 @@ private function findAndReplaceReferences($objectHandler, $inputString) if (get_class($objectHandler) != DataObjectHandler::class) { return $this->findAndReplaceReferences(DataObjectHandler::getInstance(), $outputString); } else { - throw new TestReferenceException("Could not resolve entity reference", ["input" => $inputString]); + throw new TestReferenceException( + "Could not resolve entity reference \"{$inputString}\" " + . "in Action with stepKey \"{$this->getStepKey()}\"", + ["input" => $inputString, "stepKey" => $this->getStepKey()] + ); } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php index fb562c626..0a6bc7957 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php @@ -23,6 +23,11 @@ class ActionMergeUtil const WAIT_ATTR = 'timeout'; const WAIT_ACTION_NAME = 'waitForPageLoad'; const WAIT_ACTION_SUFFIX = 'WaitForPageLoad'; + const SKIP_READINESS_ACTION_NAME = 'skipReadinessCheck'; + const SKIP_READINESS_OFF_SUFFIX = 'SkipReadinessOff'; + const SKIP_READINESS_ON_SUFFIX = 'SkipReadinessOn'; + const DEFAULT_SKIP_ON_ORDER = 'before'; + const DEFAULT_SKIP_OFF_ORDER = 'after'; const DEFAULT_WAIT_ORDER = 'after'; /** @@ -78,6 +83,7 @@ public function resolveActionSteps($parsedSteps, $skipActionGroupResolution = fa { $this->mergeActions($parsedSteps); $this->insertWaits(); + $this->insertReadinessSkips(); if ($skipActionGroupResolution) { return $this->orderedSteps; @@ -217,6 +223,39 @@ private function insertWaits() } } + /** + * Runs through the prepared orderedSteps and calls insertWait if a step requires a wait after it. + * + * @return void + */ + private function insertReadinessSkips() + { + foreach ($this->orderedSteps as $step) { + if (array_key_exists("skipReadiness", $step->getCustomActionAttributes())) { + if ($step->getCustomActionAttributes()['skipReadiness'] == "true") { + $skipReadinessOn = new ActionObject( + $step->getStepKey() . self::SKIP_READINESS_ON_SUFFIX, + self::SKIP_READINESS_ACTION_NAME, + ['state' => "true"], + $step->getStepKey(), + self::DEFAULT_SKIP_ON_ORDER + ); + + $skipReadinessOff = new ActionObject( + $step->getStepKey() . self::SKIP_READINESS_OFF_SUFFIX, + self::SKIP_READINESS_ACTION_NAME, + ['state' => "false"], + $step->getStepKey(), + self::DEFAULT_SKIP_OFF_ORDER + ); + + $this->insertStep($skipReadinessOn); + $this->insertStep($skipReadinessOff); + } + } + } + } + /** * This method takes the steps from the parser and splits steps which need merge from steps that are ordered. * diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php index 805a010c2..3b857e29f 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php @@ -22,6 +22,11 @@ class AnnotationExtractor extends BaseObjectExtractor */ private $storyToTitleMappings = []; + /** + * @var array + */ + private $testCaseToTitleMappings = []; + const ANNOTATION_VALUE = 'value'; const MAGENTO_TO_ALLURE_SEVERITY_MAP = [ "BLOCKER" => "BLOCKER", @@ -90,8 +95,8 @@ public function extractAnnotations($testAnnotations, $filename) $annotationObjects[$annotationKey] = $annotationValues; } + $this->addTestCaseIdToTitle($annotationObjects, $filename); $this->validateMissingAnnotations($annotationObjects, $filename); - $this->addStoryTitleToMap($annotationObjects, $filename); return $annotationObjects; @@ -112,6 +117,30 @@ public function addStoryTitleToMap($annotations, $filename) } } + /** + * Appends TestCaseId or [NO TESTCASEID] to test titles (to prevent Allure collision). + * @param array $annotations + * @param string $filename + * @return void + */ + private function addTestCaseIdToTitle(&$annotations, $filename) + { + if (!isset($annotations['title'])) { + return; + } + + $testCaseId = "[NO TESTCASEID]"; + + if (isset($annotations['testCaseId'])) { + $testCaseId = $annotations['testCaseId'][0]; + } + + $newTitle = "{$testCaseId}: " . $annotations['title'][0]; + + $annotations['title'][0] = $newTitle; + $this->testCaseToTitleMappings[$newTitle][] = $filename; + } + /** * Validates given annotations against list of required annotations. * @param array $annotationObjects @@ -162,6 +191,32 @@ public function validateStoryTitleUniqueness() } } + /** + * Validates uniqueness between Test Case ID and Titles globally + * @returns void + * @throws XmlException + * @return void + */ + public function validateTestCaseIdTitleUniqueness() + { + $dupes = []; + foreach ($this->testCaseToTitleMappings as $newTitle => $files) { + if (count($files) > 1) { + $dupes[$newTitle] = "'" . implode("', '", $files) . "'"; + } + } + if (!empty($dupes)) { + $message = "TestCaseId and Title pairs must be unique:\n\n"; + foreach ($dupes as $newTitle => $tests) { + $testCaseTitleArray = explode(": ", $newTitle); + $testCaseId = $testCaseTitleArray[0]; + $title = $testCaseTitleArray[1]; + $message .= "TestCaseId: '{$testCaseId}' Title: '{$title}' in Tests {$tests}\n\n"; + } + throw new XmlException($message); + } + } + /** * Validates that all issueId tags contain a non-empty value * @param array $issues diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php b/src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php index 97f67004a..e67037940 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ObjectExtensionUtil.php @@ -210,10 +210,10 @@ public function skipTest($testObject) $annotations = $testObject->getAnnotations(); // Add skip to the group array if it doesn't already exist - if (array_key_exists('group', $annotations) && !in_array('skip', $annotations['group'])) { - array_push($annotations['group'], 'skip'); - } elseif (!array_key_exists('group', $annotations)) { - $annotations['group'] = ['skip']; + if (array_key_exists('skip', $annotations)) { + return $testObject; + } elseif (!array_key_exists('skip', $annotations)) { + $annotations['skip'] = ['issueId' => "ParentTestDoesNotExist"]; } $skippedTest = new TestObject( diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/commonAttributes.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/commonAttributes.xsd index 895936602..22c05ea7d 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/commonAttributes.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/commonAttributes.xsd @@ -30,6 +30,14 @@ + + + + + Flag for skipping readiness check + + + 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/Test/etc/mergedTestSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd index b65843bae..b663bb99d 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd @@ -130,5 +130,6 @@ + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index be9ad9996..eebaccf26 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; @@ -33,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. @@ -69,6 +73,13 @@ class TestGenerator */ private $debug; + /** + * Current generation scope. + * + * @var string + */ + private $currentGenerationScope; + /** * TestGenerator constructor. * @@ -244,6 +255,16 @@ private function assembleAllTestPhp($testManifest, array $testsToIgnore) $cestPhpArray = []; foreach ($testObjects as $test) { + // Do not generate test if it is an extended test and parent does not exist + if ($test->isSkipped() && !empty($test->getParentName())) { + try { + TestObjectHandler::getInstance()->getObject($test->getParentName()); + } catch (TestReferenceException $e) { + print("{$test->getName()} will not be generated. Parent {$e->getMessage()} \n"); + continue; + } + } + $this->debug("Start creating test: " . $test->getCodeceptionName() . ""); $php = $this->assembleTestPhp($test); $cestPhpArray[] = [$test->getCodeceptionName(), $php]; @@ -286,11 +307,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 = [ @@ -451,18 +469,19 @@ 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 * @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 = ""; + $this->currentGenerationScope = $generationScope; foreach ($actionObjects as $actionObject) { $stepKey = $actionObject->getStepKey(); @@ -684,91 +703,77 @@ 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; } } - - 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 - ); + // Build array of requiredEntities + $requiredEntityKeysArray = ""; + if (!empty($requiredEntityKeys)) { + $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; } - - if ($storeCode) { - $createEntityFunctionCall .= sprintf("\"%s\");\n", $storeCode); - } else { - $createEntityFunctionCall .= ");\n"; + //Determine Scope + $scope = PersistedObjectHandler::TEST_SCOPE; + if ($generationScope == TestGenerator::HOOK_SCOPE) { + $scope = PersistedObjectHandler::HOOK_SCOPE; + } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { + $scope = PersistedObjectHandler::SUITE_SCOPE; } - - // 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) - ); - + + $createEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->createEntity("; + $createEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; + $createEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; + $createEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; + $createEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; if (count($customEntityFields) > 1) { - $dataPersistenceHandlerFunctionCall .= ", \${$stepKey}Fields"; + $createEntityFunctionCall .= ",\n\t\t\t\${$stepKey}Fields"; + } else { + $createEntityFunctionCall .= ",\n\t\t\tnull"; } - - $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']; + $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", $actor, $key ); - $deleteEntityFunctionCall = ""; - if ($hookObject) { - $deleteEntityFunctionCall .= sprintf("\t\t\$this->%s->deleteEntity();\n", $key); - } else { - $deleteEntityFunctionCall .= sprintf("\t\t$%s->deleteEntity();\n", $key); + //Determine 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);\n"; + $testSteps .= $contextSetter; $testSteps .= $deleteEntityFunctionCall; } else { @@ -783,8 +788,14 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " } 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( @@ -792,128 +803,91 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $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]; - } + + // 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 ($hookObject) { - $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 ($generationScope == TestGenerator::HOOK_SCOPE) { + $scope = PersistedObjectHandler::HOOK_SCOPE; + } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { + $scope = PersistedObjectHandler::SUITE_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}\""; + $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; } } - - 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 - ); + $requiredEntityKeysArray = ""; + if (!empty($requiredEntityKeys)) { + $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; } - if (isset($customActionAttributes['index'])) { - $getEntityFunctionCall .= sprintf("%s", (int)$customActionAttributes['index']); - } else { - $getEntityFunctionCall .= 'null'; + //Determine Scope + $scope = PersistedObjectHandler::TEST_SCOPE; + if ($generationScope == TestGenerator::HOOK_SCOPE) { + $scope = PersistedObjectHandler::HOOK_SCOPE; + } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { + $scope = PersistedObjectHandler::SUITE_SCOPE; } - if ($storeCode) { - $getEntityFunctionCall .= sprintf(", \"%s\");\n", $storeCode); + //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}\""; + $getEntityFunctionCall .= ",\n\t\t\t[{$requiredEntityKeysArray}]"; + if ($storeCode !== null) { + $getEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; } else { - $getEntityFunctionCall .= ");\n"; + $getEntityFunctionCall .= ",\n\t\t\tnull"; } - - //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( @@ -954,7 +928,12 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " case "dontSeeCookie": case "resetCookie": case "seeCookie": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $parameterArray); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $input, + $parameterArray + ); break; case "grabCookie": $testSteps .= $this->wrapFunctionCallWithReturnValue( @@ -971,7 +950,12 @@ 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, + $selector, + $parameterArray + ); break; case "pressKey": $parameterArray = $customActionAttributes['parameterArray'] ?? null; @@ -995,17 +979,42 @@ 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, + $selector, + $input, + $parameterArray + ); break; case "selectOption": case "unselectOption": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input, $parameterArray); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $selector, + $input, + $parameterArray + ); break; case "submitForm": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $parameterArray, $button); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $selector, + $parameterArray, + $button + ); break; case "dragAndDrop": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector1, $selector2, $x, $y); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $selector1, + $selector2, + $x, + $y + ); break; case "selectMultipleOptions": $testSteps .= $this->wrapFunctionCall( @@ -1030,7 +1039,13 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " break; case "performOn": case "waitForElementChange": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $function, $time); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $selector, + $function, + $time + ); break; case "waitForJS": $testSteps .= $this->wrapFunctionCall( @@ -1049,7 +1064,13 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " break; case "waitForPageLoad": case "waitForText": - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $input, $time, $selector); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $input, + $time, + $selector + ); break; case "formatMoney": $testSteps .= $this->wrapFunctionCallWithReturnValue( @@ -1253,7 +1274,10 @@ 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() + )[0]; $argRef = "\t\t\$"; $argRef .= str_replace(ucfirst($fieldKey), "", $stepKey) . "Fields['{$fieldKey}'] = ${input};\n"; $testSteps .= $argRef; @@ -1271,8 +1295,17 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = " $testSteps .= $dateGenerateCode; break; + case "skipReadinessCheck": + $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $customActionAttributes['state']); + break; default: - $testSteps .= $this->wrapFunctionCall($actor, $actionObject, $selector, $input, $parameter); + $testSteps .= $this->wrapFunctionCall( + $actor, + $actionObject, + $selector, + $input, + $parameter + ); } } @@ -1311,13 +1344,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); //trim "{$variable}" into $variable $outputArg = $this->trimVariableIfNeeded($outputArg); @@ -1351,16 +1380,16 @@ private function trimVariableIfNeeded($input) * * @param array $matches * @param string $outputArg - * @param string $delimiter * @return void * @throws \Exception */ - private function replaceMatchesIntoArg($matches, &$outputArg, $delimiter) + private function replaceMatchesIntoArg($matches, &$outputArg) { // 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( @@ -1368,11 +1397,9 @@ 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"; + $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) { @@ -1410,7 +1437,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; @@ -1426,14 +1453,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; @@ -1501,29 +1535,11 @@ private function stripAndSplitReference($reference, $delimiter) private function generateHooksPhp($hookObjects) { $hooks = ""; - $createData = false; foreach ($hookObjects as $hookObject) { $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()); - $createData = true; - } - } - $hooks .= "\t/**\n"; $hooks .= "\t * @param AcceptanceTester \$I\n"; $hooks .= "\t * @throws \Exception\n"; @@ -1532,7 +1548,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 . "\""); @@ -1701,6 +1717,7 @@ private function addDollarSign($input) * * @param string $actor * @param actionObject $action + * @param string $scope * @param array ...$args * @return string * @throws \Exception @@ -1732,6 +1749,7 @@ 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