From ebe8b149ad4aefc40e43c8ac5aa57fac1d1362f7 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 27 Nov 2019 13:11:33 -0600 Subject: [PATCH 01/67] MQE-1379: Fix MFTF custom actions to fully support Codeception dry-run functionality --- .../ActionGroupContainsStepKeyInArgText.txt | 2 - .../ActionGroupMergedViaInsertAfter.txt | 2 - .../ActionGroupMergedViaInsertBefore.txt | 2 - .../Resources/ActionGroupSkipReadiness.txt | 2 - .../Resources/ActionGroupToExtend.txt | 2 - .../Resources/ActionGroupUsingCreateData.txt | 6 +- .../ActionGroupUsingNestedArgument.txt | 2 - .../ActionGroupWithDataOverrideTest.txt | 4 +- .../Resources/ActionGroupWithDataTest.txt | 4 +- ...hDefaultArgumentAndStringSelectorParam.txt | 2 - ...eParameterSelectorsFromDefaultArgument.txt | 2 - .../Resources/ActionGroupWithNoArguments.txt | 2 - .../ActionGroupWithNoDefaultTest.txt | 4 +- ...roupWithParameterizedElementWithHyphen.txt | 2 - ...meterizedElementsWithStepKeyReferences.txt | 6 +- ...thPassedArgumentAndStringSelectorParam.txt | 2 - .../ActionGroupWithPersistedData.txt | 16 +- ...tionGroupWithSectionAndDataAsArguments.txt | 2 - ...WithSimpleDataUsageFromDefaultArgument.txt | 2 - ...pWithSimpleDataUsageFromPassedArgument.txt | 10 +- ...leParameterSelectorFromDefaultArgument.txt | 2 - ...gleParameterSelectorFromPassedArgument.txt | 2 - .../ActionGroupWithStepKeyReferences.txt | 14 +- .../ActionGroupWithTopLevelPersistedData.txt | 14 +- .../ArgumentWithSameNameAsElement.txt | 4 +- .../verification/Resources/AssertTest.txt | 28 ++-- .../Resources/BasicActionGroupTest.txt | 4 +- .../Resources/BasicFunctionalTest.txt | 4 +- .../verification/Resources/BasicMergeTest.txt | 2 - .../Resources/CharacterReplacementTest.txt | 2 - .../Resources/ChildExtendedTestAddHooks.txt | 2 - .../Resources/ChildExtendedTestMerging.txt | 2 - .../Resources/ChildExtendedTestNoParent.txt | 2 - .../ChildExtendedTestRemoveAction.txt | 2 - .../ChildExtendedTestRemoveHookAction.txt | 2 - .../Resources/ChildExtendedTestReplace.txt | 2 - .../ChildExtendedTestReplaceHook.txt | 2 - .../Resources/DataActionsTest.txt | 18 +- .../Resources/DataReplacementTest.txt | 2 - .../Resources/ExecuteInSeleniumTest.txt | 2 - .../Resources/ExecuteJsEscapingTest.txt | 8 +- .../Resources/ExtendParentDataTest.txt | 4 +- .../Resources/ExtendedActionGroup.txt | 2 - .../ExtendedChildTestInSuiteCest.txt | 2 - .../Resources/ExtendedChildTestNotInSuite.txt | 2 - .../Resources/ExtendedParameterArrayTest.txt | 4 +- .../Resources/ExtendedRemoveActionGroup.txt | 2 - .../Resources/ExtendingSkippedTest.txt | 2 - .../Resources/HookActionsTest.txt | 12 +- .../Resources/LocatorFunctionTest.txt | 12 +- .../Resources/MergeMassViaInsertAfter.txt | 2 - .../Resources/MergeMassViaInsertBefore.txt | 2 - .../verification/Resources/MergeSkip.txt | 2 - .../Resources/MergedActionGroupTest.txt | 4 +- .../Resources/MergedReferencesTest.txt | 2 - .../Resources/MultipleActionGroupsTest.txt | 4 +- .../Resources/PageReplacementTest.txt | 10 +- .../Resources/ParameterArrayTest.txt | 24 ++- .../Resources/ParentExtendedTest.txt | 2 - .../PersistedAndXmlEntityArguments.txt | 4 +- .../Resources/PersistedReplacementTest.txt | 50 +++--- .../PersistenceActionGroupAppendingTest.txt | 22 ++- .../Resources/PersistenceCustomFieldsTest.txt | 30 ++-- .../Resources/SectionReplacementTest.txt | 20 +-- .../verification/Resources/SkippedTest.txt | 2 - .../Resources/SkippedTestNoIssues.txt | 2 - .../Resources/SkippedTestTwoIssues.txt | 2 - .../Resources/SkippedTestWithHooks.txt | 2 - .../Resources/XmlCommentedActionGroupTest.txt | 2 - .../Resources/XmlCommentedTest.txt | 2 - .../Tests/SecretCredentialDataTest.php | 12 +- etc/config/functional.suite.dist.yml | 1 + .../Handlers/PersistedObjectHandler.php | 1 - .../DataGenerator/Persist/CurlHandler.php | 8 +- .../Module/MagentoActionProxies.php | 157 ++++++++++++++++++ .../Test/Objects/ActionObject.php | 2 +- .../Util/TestGenerator.php | 40 +++-- 77 files changed, 341 insertions(+), 308 deletions(-) create mode 100644 src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php diff --git a/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt b/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt index d7e31b5f2..1eb3d6566 100644 --- a/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt +++ b/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 127b9cc59..b4745e0c0 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 1486d042e..b27328275 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 index d11d5c238..11025fefe 100644 --- a/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt +++ b/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupToExtend.txt b/dev/tests/verification/Resources/ActionGroupToExtend.txt index d7e72260d..133c9fb9b 100644 --- a/dev/tests/verification/Resources/ActionGroupToExtend.txt +++ b/dev/tests/verification/Resources/ActionGroupToExtend.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 96134fd86..8ec0a88a8 100644 --- a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt +++ b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class ActionGroupUsingCreateDataCest { $I->comment("Entering Action Group [Key1] actionGroupWithCreateData"); $I->comment("[createCategoryKey1] create 'ApiCategory' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createCategoryKey1", "hook", "ApiCategory", @@ -36,7 +34,7 @@ class ActionGroupUsingCreateDataCest ); $I->comment("[createConfigProductKey1] create 'ApiConfigurableProduct' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createConfigProductKey1", "hook", "ApiConfigurableProduct", diff --git a/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt b/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt index b69ee6c9d..5814e85e0 100644 --- a/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 c0498101d..9ad3f7127 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class ActionGroupWithDataOverrideTestCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", diff --git a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt index 01a87104d..f1a0f6219 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class ActionGroupWithDataTestCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", diff --git a/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt b/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt index ce8a4aed8..289bbe4e1 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt index b7bef0135..4e94978ad 100644 --- a/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt b/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt index 6b81a187f..6158b5af7 100644 --- a/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt +++ b/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt index 6125c7697..99615c728 100644 --- a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class ActionGroupWithNoDefaultTestCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", diff --git a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt index 163ebc6ba..52dc8bd1b 100644 --- a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt +++ b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt index de7af8209..561f4d1b2 100644 --- a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -32,7 +30,7 @@ class ActionGroupWithParameterizedElementsWithStepKeyReferencesCest $testVariableActionGroup = $I->executeJS("return 1"); // stepKey: testVariableActionGroup $testVariable2ActionGroup = $I->executeJS("return 'test'"); // stepKey: testVariable2ActionGroup $I->comment("[createSimpleDataActionGroup] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createSimpleDataActionGroup", "test", "simpleData", @@ -42,7 +40,7 @@ class ActionGroupWithParameterizedElementsWithStepKeyReferencesCest $I->click("#{$testVariable2ActionGroup} .John"); // stepKey: click1ActionGroup $I->click("#Doe-" . msq("simpleParamData") . "prename .{$testVariableActionGroup}"); // stepKey: click2ActionGroup - $I->seeElement("//div[@name='Tiberius'][@class={$testVariableActionGroup}][@data-element='{$testVariable2ActionGroup}'][" . PersistedObjectHandler::getInstance()->retrieveEntityField('createSimpleData', 'name', 'test') . "]"); // stepKey: see1ActionGroup + $I->seeElement("//div[@name='Tiberius'][@class={$testVariableActionGroup}][@data-element='{$testVariable2ActionGroup}'][" . $I->retrieveEntityField('createSimpleData', 'name', 'test') . "]"); // stepKey: see1ActionGroup $I->comment("Exiting Action Group [actionGroup] actionGroupWithParametrizedSelectors"); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt b/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt index 9720595e0..254fbe0f2 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt index da0480379..0bec544bf 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class ActionGroupWithPersistedDataCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", @@ -74,7 +72,7 @@ class ActionGroupWithPersistedDataCest public function ActionGroupWithPersistedData(AcceptanceTester $I) { $I->comment("[createPerson] create 'DefaultPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPerson", "test", "DefaultPerson", @@ -83,11 +81,11 @@ class ActionGroupWithPersistedDataCest ); $I->comment("Entering Action Group [actionGroupWithPersistedData1] FunctionalActionGroupWithData"); - $I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'firstname', 'test') . "/" . PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'lastname', 'test') . ".html"); // stepKey: amOnPage1ActionGroupWithPersistedData1 - $I->fillField("#foo", PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'firstname', 'test')); // stepKey: fillField1ActionGroupWithPersistedData1 - $I->fillField("#bar", PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'lastname', 'test')); // stepKey: fillField2ActionGroupWithPersistedData1 - $I->searchAndMultiSelectOption("#foo", [PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'lastname', 'test')]); // stepKey: multi1ActionGroupWithPersistedData1 - $I->see("#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('createPerson', 'firstname', 'test')); // stepKey: see1ActionGroupWithPersistedData1 + $I->amOnPage("/" . $I->retrieveEntityField('createPerson', 'firstname', 'test') . "/" . $I->retrieveEntityField('createPerson', 'lastname', 'test') . ".html"); // stepKey: amOnPage1ActionGroupWithPersistedData1 + $I->fillField("#foo", $I->retrieveEntityField('createPerson', 'firstname', 'test')); // stepKey: fillField1ActionGroupWithPersistedData1 + $I->fillField("#bar", $I->retrieveEntityField('createPerson', 'lastname', 'test')); // stepKey: fillField2ActionGroupWithPersistedData1 + $I->searchAndMultiSelectOption("#foo", [$I->retrieveEntityField('createPerson', 'firstname', 'test'), $I->retrieveEntityField('createPerson', 'lastname', 'test')]); // stepKey: multi1ActionGroupWithPersistedData1 + $I->see("#element ." . $I->retrieveEntityField('createPerson', 'firstname', 'test')); // stepKey: see1ActionGroupWithPersistedData1 $I->comment("Exiting Action Group [actionGroupWithPersistedData1] FunctionalActionGroupWithData"); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt b/dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt index a0b6d0074..ec6111062 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt index 4d3da18a4..f4faf0773 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt index d866c3992..86791407d 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -46,19 +44,19 @@ class ActionGroupWithSimpleDataUsageFromPassedArgumentCest $I->see("simpleData.firstname", "#element .simpleData.firstname"); // stepKey: see1ActionGroup2 $I->comment("Exiting Action Group [actionGroup2] actionGroupWithStringUsage"); $I->comment("Entering Action Group [actionGroup3] actionGroupWithStringUsage"); - $I->see(PersistedObjectHandler::getInstance()->retrieveEntityField('persisted', 'data', 'test'), "#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('persisted', 'data', 'test')); // stepKey: see1ActionGroup3 + $I->see($I->retrieveEntityField('persisted', 'data', 'test'), "#element ." . $I->retrieveEntityField('persisted', 'data', 'test')); // stepKey: see1ActionGroup3 $I->comment("Exiting Action Group [actionGroup3] actionGroupWithStringUsage"); $I->comment("Entering Action Group [actionGroup4] actionGroupWithEntityUsage"); $I->see("John", "#element .John"); // stepKey: see1ActionGroup4 $I->comment("Exiting Action Group [actionGroup4] actionGroupWithEntityUsage"); $I->comment("Entering Action Group [actionGroup5] actionGroupWithEntityUsage"); - $I->see(PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname', 'test'), "#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname', 'test')); // stepKey: see1ActionGroup5 + $I->see($I->retrieveEntityField('simpleData', 'firstname', 'test'), "#element ." . $I->retrieveEntityField('simpleData', 'firstname', 'test')); // stepKey: see1ActionGroup5 $I->comment("Exiting Action Group [actionGroup5] actionGroupWithEntityUsage"); $I->comment("Entering Action Group [actionGroup6] actionGroupWithEntityUsage"); - $I->see(PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname[0]', 'test'), "#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname[0]', 'test')); // stepKey: see1ActionGroup6 + $I->see($I->retrieveEntityField('simpleData', 'firstname[0]', 'test'), "#element ." . $I->retrieveEntityField('simpleData', 'firstname[0]', 'test')); // stepKey: see1ActionGroup6 $I->comment("Exiting Action Group [actionGroup6] actionGroupWithEntityUsage"); $I->comment("Entering Action Group [actionGroup7] actionGroupWithEntityUsage"); - $I->see(PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname[data_index]', 'test'), "#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('simpleData', 'firstname[data_index]', 'test')); // stepKey: see1ActionGroup7 + $I->see($I->retrieveEntityField('simpleData', 'firstname[data_index]', 'test'), "#element ." . $I->retrieveEntityField('simpleData', 'firstname[data_index]', 'test')); // stepKey: see1ActionGroup7 $I->comment("Exiting Action Group [actionGroup7] actionGroupWithEntityUsage"); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt index af7af43a4..5d8298108 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt index 096623789..283a9fdd7 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt index eddaaf784..c8ddb15bf 100644 --- a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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,7 +28,7 @@ class ActionGroupWithStepKeyReferencesCest { $I->comment("Entering Action Group [actionGroup] FunctionActionGroupWithStepKeyReferences"); $I->comment("[createSimpleDataActionGroup] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createSimpleDataActionGroup", "test", "simpleData", @@ -39,7 +37,7 @@ class ActionGroupWithStepKeyReferencesCest ); $grabTextDataActionGroup = $I->grabTextFrom(".class"); // stepKey: grabTextDataActionGroup - $I->fillField(".{$grabTextDataActionGroup}", PersistedObjectHandler::getInstance()->retrieveEntityField('createSimpleDataActionGroup', 'field', 'test')); // stepKey: fill1ActionGroup + $I->fillField(".{$grabTextDataActionGroup}", $I->retrieveEntityField('createSimpleDataActionGroup', 'field', 'test')); // stepKey: fill1ActionGroup $I->comment("Invocation stepKey will not be appended in non stepKey instances"); $I->click($action0); // stepKey: action0ActionGroup $I->fillField($action1); // stepKey: action1ActionGroup @@ -54,13 +52,13 @@ class ActionGroupWithStepKeyReferencesCest $action6ActionGroup = $I->formatMoney($action6ActionGroup); // stepKey: action6ActionGroup $I->comment("[action7ActionGroup] delete entity '{$action7ActionGroupActionGroup}'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "{$action7ActionGroupActionGroup}", "test" ); $I->comment("[action8ActionGroup] get '{$action8}' entity"); - PersistedObjectHandler::getInstance()->getEntity( + $I->getEntity( "action8ActionGroup", "test", "{$action8}", @@ -69,7 +67,7 @@ class ActionGroupWithStepKeyReferencesCest ); $I->comment("[action9ActionGroup] update '1' entity to '{$action9}'"); - PersistedObjectHandler::getInstance()->updateEntity( + $I->updateEntity( "1", "test", "{$action9}", @@ -77,7 +75,7 @@ class ActionGroupWithStepKeyReferencesCest ); $I->comment("[action10ActionGroup] create '{$action10}' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "action10ActionGroup", "test", "{$action10}", diff --git a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt index ef1a5636c..6567bdbb0 100644 --- a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class ActionGroupWithTopLevelPersistedDataCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", @@ -74,11 +72,11 @@ class ActionGroupWithTopLevelPersistedDataCest public function ActionGroupWithTopLevelPersistedData(AcceptanceTester $I) { $I->comment("Entering Action Group [actionGroupWithPersistedData1] FunctionalActionGroupWithData"); - $I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'firstname', 'test') . "/" . PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'lastname', 'test') . ".html"); // stepKey: amOnPage1ActionGroupWithPersistedData1 - $I->fillField("#foo", PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'firstname', 'test')); // stepKey: fillField1ActionGroupWithPersistedData1 - $I->fillField("#bar", PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'lastname', 'test')); // stepKey: fillField2ActionGroupWithPersistedData1 - $I->searchAndMultiSelectOption("#foo", [PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'lastname', 'test')]); // stepKey: multi1ActionGroupWithPersistedData1 - $I->see("#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('createPersonParam', 'firstname', 'test')); // stepKey: see1ActionGroupWithPersistedData1 + $I->amOnPage("/" . $I->retrieveEntityField('createPersonParam', 'firstname', 'test') . "/" . $I->retrieveEntityField('createPersonParam', 'lastname', 'test') . ".html"); // stepKey: amOnPage1ActionGroupWithPersistedData1 + $I->fillField("#foo", $I->retrieveEntityField('createPersonParam', 'firstname', 'test')); // stepKey: fillField1ActionGroupWithPersistedData1 + $I->fillField("#bar", $I->retrieveEntityField('createPersonParam', 'lastname', 'test')); // stepKey: fillField2ActionGroupWithPersistedData1 + $I->searchAndMultiSelectOption("#foo", [$I->retrieveEntityField('createPersonParam', 'firstname', 'test'), $I->retrieveEntityField('createPersonParam', 'lastname', 'test')]); // stepKey: multi1ActionGroupWithPersistedData1 + $I->see("#element ." . $I->retrieveEntityField('createPersonParam', 'firstname', 'test')); // stepKey: see1ActionGroupWithPersistedData1 $I->comment("Exiting Action Group [actionGroupWithPersistedData1] FunctionalActionGroupWithData"); } } diff --git a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt index 2da03b506..54bb012e9 100644 --- a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt +++ b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class ArgumentWithSameNameAsElementCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", diff --git a/dev/tests/verification/Resources/AssertTest.txt b/dev/tests/verification/Resources/AssertTest.txt index 28c38bc0b..50eb50e24 100644 --- a/dev/tests/verification/Resources/AssertTest.txt +++ b/dev/tests/verification/Resources/AssertTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -26,7 +24,7 @@ class AssertTestCest public function _before(AcceptanceTester $I) { $I->comment("[createData1] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createData1", "hook", "ReplacementPerson", @@ -46,7 +44,7 @@ class AssertTestCest public function AssertTest(AcceptanceTester $I) { $I->comment("[createData2] create 'UniquePerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createData2", "test", "UniquePerson", @@ -138,15 +136,15 @@ class AssertTestCest $I->expectException(new MyException('exception msg'), function() {$this->doSomethingBad();}); // stepKey: expectExceptionBackwardCompatible $I->comment("string type that use created data"); $I->comment("string type that use created data"); - $I->assertStringStartsWith("D", PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test') . ", " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test'), "fail"); // stepKey: assert1 - $I->assertStringStartsNotWith("W", PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test') . ", " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'lastname', 'test'), "pass"); // stepKey: assert2 - $I->assertEquals(PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test'), "pass"); // stepKey: assert5 + $I->assertStringStartsWith("D", $I->retrieveEntityField('createData1', 'lastname', 'test') . ", " . $I->retrieveEntityField('createData1', 'firstname', 'test'), "fail"); // stepKey: assert1 + $I->assertStringStartsNotWith("W", $I->retrieveEntityField('createData2', 'firstname', 'test') . ", " . $I->retrieveEntityField('createData2', 'lastname', 'test'), "pass"); // stepKey: assert2 + $I->assertEquals($I->retrieveEntityField('createData1', 'lastname', 'test'), $I->retrieveEntityField('createData1', 'lastname', 'test'), "pass"); // stepKey: assert5 $I->comment("array type that use created data"); $I->comment("array type that use created data"); - $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"); // stepKey: assert9 - $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"); // stepKey: assert10 - $I->assertArrayHasKey("lastname", ['lastname' => PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test'), 'firstname' => PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test')], "pass"); // stepKey: assert3 - $I->assertArrayHasKey("lastname", ['lastname' => PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'lastname', 'test'), 'firstname' => PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test')], "pass"); // stepKey: assert4 + $I->assertArraySubset([$I->retrieveEntityField('createData1', 'lastname', 'test'), $I->retrieveEntityField('createData1', 'firstname', 'test')], [$I->retrieveEntityField('createData1', 'lastname', 'test'), $I->retrieveEntityField('createData1', 'firstname', 'test'), "1"], "pass"); // stepKey: assert9 + $I->assertArraySubset([$I->retrieveEntityField('createData2', 'firstname', 'test'), $I->retrieveEntityField('createData2', 'lastname', 'test')], [$I->retrieveEntityField('createData2', 'firstname', 'test'), $I->retrieveEntityField('createData2', 'lastname', 'test'), "1"], "pass"); // stepKey: assert10 + $I->assertArrayHasKey("lastname", ['lastname' => $I->retrieveEntityField('createData1', 'lastname', 'test'), 'firstname' => $I->retrieveEntityField('createData1', 'firstname', 'test')], "pass"); // stepKey: assert3 + $I->assertArrayHasKey("lastname", ['lastname' => $I->retrieveEntityField('createData2', 'lastname', 'test'), 'firstname' => $I->retrieveEntityField('createData2', 'firstname', 'test')], "pass"); // stepKey: assert4 $I->comment("this section can only be generated and cannot run"); $I->assertInstanceOf(User::class, $text, "pass"); // stepKey: assertInstanceOf $I->assertNotInstanceOf(User::class, 21, "pass"); // stepKey: assertNotInstanceOf @@ -156,8 +154,8 @@ class AssertTestCest $I->assertNull($text, "pass"); // stepKey: assertNull $I->expectException(new MyException('exception msg'), function() {$this->doSomethingBad();}); // stepKey: expectException $I->fail("fail"); // stepKey: fail - $I->fail(PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test') . " " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'lastname', 'test')); // stepKey: assert7 - $I->fail(PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test') . " " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'lastname', 'test')); // stepKey: assert8 + $I->fail($I->retrieveEntityField('createData2', 'firstname', 'test') . " " . $I->retrieveEntityField('createData2', 'lastname', 'test')); // stepKey: assert7 + $I->fail($I->retrieveEntityField('createData1', 'firstname', 'test') . " " . $I->retrieveEntityField('createData1', 'lastname', 'test')); // stepKey: assert8 $I->comment("assertElementContainsAttribute examples"); $I->assertElementContainsAttribute("#username", "class", "admin__control-text"); // stepKey: assertElementContainsAttribute1 $I->assertElementContainsAttribute("#username", "name", "login[username]"); // stepKey: assertElementContainsAttribute2 @@ -165,8 +163,8 @@ class AssertTestCest $I->assertElementContainsAttribute("#username", "data-validate", "{required:true}"); // stepKey: assertElementContainsAttribute4 $I->assertElementContainsAttribute(".admin__menu-overlay", "style", "display: none;"); // stepKey: assertElementContainsAttribute5 $I->assertElementContainsAttribute(".admin__menu-overlay", "border", "0"); // stepKey: assertElementContainsAttribute6 - $I->assertElementContainsAttribute("#username", "value", PersistedObjectHandler::getInstance()->retrieveEntityField('createData2', 'firstname', 'test')); // stepKey: assertElementContainsAttribute7 - $I->assertElementContainsAttribute("#username", "value", PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test')); // stepKey: assertElementContainsAttribute8 + $I->assertElementContainsAttribute("#username", "value", $I->retrieveEntityField('createData2', 'firstname', 'test')); // stepKey: assertElementContainsAttribute7 + $I->assertElementContainsAttribute("#username", "value", $I->retrieveEntityField('createData1', 'firstname', 'test')); // stepKey: assertElementContainsAttribute8 $I->comment("assert entity resolution"); $I->assertEquals("John", "Doe", "pass"); // stepKey: assertEqualsEntity } diff --git a/dev/tests/verification/Resources/BasicActionGroupTest.txt b/dev/tests/verification/Resources/BasicActionGroupTest.txt index 4bb9c1a95..79fbd3513 100644 --- a/dev/tests/verification/Resources/BasicActionGroupTest.txt +++ b/dev/tests/verification/Resources/BasicActionGroupTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class BasicActionGroupTestCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index f82c84119..6f95df23d 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; @@ -77,7 +75,7 @@ class BasicFunctionalTestCest $I->closeTab(); // stepKey: closeTabKey1 $I->conditionalClick(".functionalTestSelector", ".functionalDependentTestSelector", true); // stepKey: conditionalClickKey1 $I->comment("[deleteKey1] delete entity 'createKey1'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "createKey1", "test" ); diff --git a/dev/tests/verification/Resources/BasicMergeTest.txt b/dev/tests/verification/Resources/BasicMergeTest.txt index 5421efe33..c6fb58e3a 100644 --- a/dev/tests/verification/Resources/BasicMergeTest.txt +++ b/dev/tests/verification/Resources/BasicMergeTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/CharacterReplacementTest.txt b/dev/tests/verification/Resources/CharacterReplacementTest.txt index db3852b17..61729cc8b 100644 --- a/dev/tests/verification/Resources/CharacterReplacementTest.txt +++ b/dev/tests/verification/Resources/CharacterReplacementTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 e03501707..8362cf513 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestMerging.txt b/dev/tests/verification/Resources/ChildExtendedTestMerging.txt index a99843b48..590ba6003 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestMerging.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestMerging.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt b/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt index 1eec9e48c..5d72176c5 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt b/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt index 20aa62e28..766bfd331 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt b/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt index 561fd24fa..8497c29af 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestReplace.txt b/dev/tests/verification/Resources/ChildExtendedTestReplace.txt index 8d131a83f..3b2e9d369 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestReplace.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestReplace.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt b/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt index ae0b02c20..53ae22361 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/DataActionsTest.txt b/dev/tests/verification/Resources/DataActionsTest.txt index 380db238d..bbfbafa21 100644 --- a/dev/tests/verification/Resources/DataActionsTest.txt +++ b/dev/tests/verification/Resources/DataActionsTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -26,7 +24,7 @@ class DataActionsTestCest public function _before(AcceptanceTester $I) { $I->comment("[createdInBefore] create 'entity' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createdInBefore", "hook", "entity", @@ -35,7 +33,7 @@ class DataActionsTestCest ); $I->comment("[updateInBefore] update 'createdInBefore' entity to 'entity'"); - PersistedObjectHandler::getInstance()->updateEntity( + $I->updateEntity( "createdInBefore", "hook", "entity", @@ -43,7 +41,7 @@ class DataActionsTestCest ); $I->comment("[deleteInBefore] delete entity 'createdInBefore'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "createdInBefore", "hook" ); @@ -60,7 +58,7 @@ class DataActionsTestCest public function DataActionsTest(AcceptanceTester $I) { $I->comment("[createdInTest] create 'entity' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createdInTest", "test", "entity", @@ -69,7 +67,7 @@ class DataActionsTestCest ); $I->comment("[updateInTest] update 'createdInTest' entity to 'entity'"); - PersistedObjectHandler::getInstance()->updateEntity( + $I->updateEntity( "createdInTest", "test", "entity", @@ -77,13 +75,13 @@ class DataActionsTestCest ); $I->comment("[deleteInTest] delete entity 'createdInTest'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "createdInTest", "test" ); $I->comment("[updatedDataOutOfScope] update 'createdInBefore' entity to 'entity'"); - PersistedObjectHandler::getInstance()->updateEntity( + $I->updateEntity( "createdInBefore", "test", "entity", @@ -91,7 +89,7 @@ class DataActionsTestCest ); $I->comment("[deleteDataOutOfScope] delete entity 'createdInBefore'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "createdInBefore", "test" ); diff --git a/dev/tests/verification/Resources/DataReplacementTest.txt b/dev/tests/verification/Resources/DataReplacementTest.txt index 731ae63f8..461a1e928 100644 --- a/dev/tests/verification/Resources/DataReplacementTest.txt +++ b/dev/tests/verification/Resources/DataReplacementTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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/ExecuteInSeleniumTest.txt b/dev/tests/verification/Resources/ExecuteInSeleniumTest.txt index 6b709a0cb..cfd7a14ce 100644 --- a/dev/tests/verification/Resources/ExecuteInSeleniumTest.txt +++ b/dev/tests/verification/Resources/ExecuteInSeleniumTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 f7618cbf9..d0b7acc83 100644 --- a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt +++ b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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,8 +28,8 @@ class ExecuteJsEscapingTestCest { $javaVariableEscape = $I->executeJS("return \$javascriptVariable"); // stepKey: javaVariableEscape $mftfVariableNotEscaped = $I->executeJS("return {$doNotEscape}"); // stepKey: mftfVariableNotEscaped - $persistedDataNotEscaped = $I->executeJS("return " . PersistedObjectHandler::getInstance()->retrieveEntityField('persisted', 'data', 'test')); // stepKey: persistedDataNotEscaped - $hookPersistedDataNotEscaped = $I->executeJS("return " . PersistedObjectHandler::getInstance()->retrieveEntityField('persisted', 'data', 'test')); // stepKey: hookPersistedDataNotEscaped - $addNewAttributeForRule = $I->executeJS("document.querySelector('entity option[value=" . PersistedObjectHandler::getInstance()->retrieveEntityField('productAttribute', 'attribute_code', 'test') . "]').setAttribute('selected', 'selected')"); // stepKey: addNewAttributeForRule + $persistedDataNotEscaped = $I->executeJS("return " . $I->retrieveEntityField('persisted', 'data', 'test')); // stepKey: persistedDataNotEscaped + $hookPersistedDataNotEscaped = $I->executeJS("return " . $I->retrieveEntityField('persisted', 'data', 'test')); // stepKey: hookPersistedDataNotEscaped + $addNewAttributeForRule = $I->executeJS("document.querySelector('entity option[value=" . $I->retrieveEntityField('productAttribute', 'attribute_code', 'test') . "]').setAttribute('selected', 'selected')"); // stepKey: addNewAttributeForRule } } diff --git a/dev/tests/verification/Resources/ExtendParentDataTest.txt b/dev/tests/verification/Resources/ExtendParentDataTest.txt index fb90599e3..5a698b55f 100644 --- a/dev/tests/verification/Resources/ExtendParentDataTest.txt +++ b/dev/tests/verification/Resources/ExtendParentDataTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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,7 +27,7 @@ class ExtendParentDataTestCest public function ExtendParentDataTest(AcceptanceTester $I) { $I->comment("[simpleDataKey] create 'extendParentData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "simpleDataKey", "test", "extendParentData", diff --git a/dev/tests/verification/Resources/ExtendedActionGroup.txt b/dev/tests/verification/Resources/ExtendedActionGroup.txt index 7456d99ce..3158161d9 100644 --- a/dev/tests/verification/Resources/ExtendedActionGroup.txt +++ b/dev/tests/verification/Resources/ExtendedActionGroup.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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/ExtendedChildTestInSuiteCest.txt b/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt index f52a46c2f..bde2ce2b3 100644 --- a/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt +++ b/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_suiteExtends\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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/ExtendedChildTestNotInSuite.txt b/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt index 3dfeac8f3..fc67be840 100644 --- a/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt +++ b/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 21212ba1a..e5016216d 100644 --- a/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt +++ b/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -28,7 +26,7 @@ class ExtendParentDataTestCest public function ExtendParentDataTest(AcceptanceTester $I) { $I->amGoingTo("create entity that has the stepKey: simpleDataKey"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "simpleDataKey", "test", "extendParentData", diff --git a/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt b/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt index a9c971b96..5ba7a3cce 100644 --- a/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt +++ b/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 681af0fef..73a1c89d7 100644 --- a/dev/tests/verification/Resources/ExtendingSkippedTest.txt +++ b/dev/tests/verification/Resources/ExtendingSkippedTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/HookActionsTest.txt b/dev/tests/verification/Resources/HookActionsTest.txt index 231353bc9..9ed9c0bc5 100644 --- a/dev/tests/verification/Resources/HookActionsTest.txt +++ b/dev/tests/verification/Resources/HookActionsTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -26,7 +24,7 @@ class HookActionsTestCest public function _before(AcceptanceTester $I) { $I->comment("[sampleCreateBefore] create 'sampleCreatedEntity' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "sampleCreateBefore", "hook", "sampleCreatedEntity", @@ -35,13 +33,13 @@ class HookActionsTestCest ); $I->comment("[sampleDeleteBefore] delete entity 'sampleCreateBefore'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "sampleCreateBefore", "hook" ); $I->comment("[sampleCreateForAfter] create 'sampleCreatedEntity' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "sampleCreateForAfter", "hook", "sampleCreatedEntity", @@ -58,7 +56,7 @@ class HookActionsTestCest public function _after(AcceptanceTester $I) { $I->comment("[sampleCreateAfter] create 'sampleCreatedEntity' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "sampleCreateAfter", "hook", "sampleCreatedEntity", @@ -67,7 +65,7 @@ class HookActionsTestCest ); $I->comment("[sampleDeleteAfter] delete entity 'sampleCreateForAfter'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "sampleCreateForAfter", "hook" ); diff --git a/dev/tests/verification/Resources/LocatorFunctionTest.txt b/dev/tests/verification/Resources/LocatorFunctionTest.txt index 00baeeac5..67f92543f 100644 --- a/dev/tests/verification/Resources/LocatorFunctionTest.txt +++ b/dev/tests/verification/Resources/LocatorFunctionTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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,7 +27,7 @@ class LocatorFunctionTestCest public function LocatorFunctionTest(AcceptanceTester $I) { $I->comment("[data] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "data", "test", "ReplacementPerson", @@ -42,12 +40,12 @@ class LocatorFunctionTestCest $I->click(Locator::find("'img'", ['title' => 'diagram'])); // stepKey: ArrayLocator $I->click(Locator::contains("string", "'Name'")); // stepKey: OneParamLiteral $I->click(Locator::contains("John", "'Name'")); // stepKey: OneParamData - $I->click(Locator::contains(PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key', 'test'), "'Name'")); // stepKey: OneParamPersisted + $I->click(Locator::contains($I->retrieveEntityField('data', 'key', 'test'), "'Name'")); // stepKey: OneParamPersisted $I->click(Locator::contains("string1", "string2")); // stepKey: TwoParamLiteral $I->click(Locator::contains("John", "Doe")); // stepKey: TwoParamData - $I->click(Locator::contains(PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key2', 'test'))); // stepKey: TwoParamPersisted + $I->click(Locator::contains($I->retrieveEntityField('data', 'key1', 'test'), $I->retrieveEntityField('data', 'key2', 'test'))); // stepKey: TwoParamPersisted $I->click(Locator::contains("string1", "John")); // stepKey: TwoParamMix1 - $I->click(Locator::contains("string1", PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test'))); // stepKey: TwoParamMix2 - $I->click(Locator::contains("John", PersistedObjectHandler::getInstance()->retrieveEntityField('data', 'key1', 'test'))); // stepKey: TwoParamMix3 + $I->click(Locator::contains("string1", $I->retrieveEntityField('data', 'key1', 'test'))); // stepKey: TwoParamMix2 + $I->click(Locator::contains("John", $I->retrieveEntityField('data', 'key1', 'test'))); // stepKey: TwoParamMix3 } } diff --git a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt index 7d3bfec09..90c8c5373 100644 --- a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt +++ b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 42a0fcf89..df569d66b 100644 --- a/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt +++ b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 fdfbdbfe4..bf5903065 100644 --- a/dev/tests/verification/Resources/MergeSkip.txt +++ b/dev/tests/verification/Resources/MergeSkip.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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 636c28627..b2a4d4cd3 100644 --- a/dev/tests/verification/Resources/MergedActionGroupTest.txt +++ b/dev/tests/verification/Resources/MergedActionGroupTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class MergedActionGroupTestCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", diff --git a/dev/tests/verification/Resources/MergedReferencesTest.txt b/dev/tests/verification/Resources/MergedReferencesTest.txt index 794ba6370..c4cc7276e 100644 --- a/dev/tests/verification/Resources/MergedReferencesTest.txt +++ b/dev/tests/verification/Resources/MergedReferencesTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt index 186cd404c..bd40b3fa6 100644 --- a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt +++ b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class MultipleActionGroupsTestCest public function _before(AcceptanceTester $I) { $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createPersonParam", "hook", "ReplacementPerson", diff --git a/dev/tests/verification/Resources/PageReplacementTest.txt b/dev/tests/verification/Resources/PageReplacementTest.txt index f6c6b1bac..6cfcce367 100644 --- a/dev/tests/verification/Resources/PageReplacementTest.txt +++ b/dev/tests/verification/Resources/PageReplacementTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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,7 +27,7 @@ class PageReplacementTestCest public function PageReplacementTest(AcceptanceTester $I) { $I->comment("[datakey] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "datakey", "test", "simpleData", @@ -40,11 +38,11 @@ class PageReplacementTestCest $I->amOnPage("/page.html"); // stepKey: noParamPage $I->amOnPage("/StringLiteral/page.html"); // stepKey: oneParamPageString $I->amOnPage("/John/page.html"); // stepKey: oneParamPageData - $I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . "/page.html"); // stepKey: oneParamPagePersist + $I->amOnPage("/" . $I->retrieveEntityField('datakey', 'firstname', 'test') . "/page.html"); // stepKey: oneParamPagePersist $I->amOnPage("/StringLiteral1/StringLiteral2.html"); // stepKey: twoParamPageString $I->amOnPage("/John/StringLiteral2.html"); // stepKey: twoParamPageStringData - $I->amOnPage("/John/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . ".html"); // stepKey: twoParamPageDataPersist - $I->amOnPage("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('datakey', 'firstname', 'test') . "/StringLiteral2.html"); // stepKey: twoParamPagePersistString + $I->amOnPage("/John/" . $I->retrieveEntityField('datakey', 'firstname', 'test') . ".html"); // stepKey: twoParamPageDataPersist + $I->amOnPage("/" . $I->retrieveEntityField('datakey', 'firstname', 'test') . "/StringLiteral2.html"); // stepKey: twoParamPagePersistString $I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/backend"); // stepKey: onAdminPage $I->amOnPage("/" . getenv("MAGENTO_BACKEND_NAME") . "/StringLiteral/page.html"); // stepKey: oneParamAdminPageString $I->amOnUrl("http://myFullUrl.com/"); // stepKey: onExternalPage diff --git a/dev/tests/verification/Resources/ParameterArrayTest.txt b/dev/tests/verification/Resources/ParameterArrayTest.txt index 52332217b..f66ce9c47 100644 --- a/dev/tests/verification/Resources/ParameterArrayTest.txt +++ b/dev/tests/verification/Resources/ParameterArrayTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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,7 +27,7 @@ class ParameterArrayTestCest public function ParameterArrayTest(AcceptanceTester $I) { $I->comment("[simpleDataKey] create 'simpleParamData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "simpleDataKey", "test", "simpleParamData", @@ -40,9 +38,9 @@ class ParameterArrayTestCest $I->searchAndMultiSelectOption("#selector", ["name"]); // stepKey: xmlSimpleReplace $I->searchAndMultiSelectOption("#selector", [msq("simpleParamData") . "prename"]); // stepKey: xmlPrefix $I->searchAndMultiSelectOption("#selector", ["postname" . msq("simpleParamData")]); // stepKey: xmlSuffix - $I->searchAndMultiSelectOption("#selector", [PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: persistSimple - $I->searchAndMultiSelectOption("#selector", ["name", PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: persistXmlSimple - $I->searchAndMultiSelectOption("#selector", ['someKey' => PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: literalKeyToPersist + $I->searchAndMultiSelectOption("#selector", [$I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: persistSimple + $I->searchAndMultiSelectOption("#selector", ["name", $I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: persistXmlSimple + $I->searchAndMultiSelectOption("#selector", ['someKey' => $I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: literalKeyToPersist $I->searchAndMultiSelectOption("#selector", ['someKey' => "name"]); // stepKey: literalKeyToStatic $I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData") . "prename"]); // stepKey: literalKeyToPrefixUnique $I->searchAndMultiSelectOption("#selector", ['someKey' => "postname" . msq("simpleParamData")]); // stepKey: literalKeyToSuffixUnique @@ -51,13 +49,13 @@ class ParameterArrayTestCest $I->unselectOption("#selector", ["name"]); // stepKey: 002 $I->unselectOption("#selector", [msq("simpleParamData") . "prename"]); // stepKey: 003 $I->unselectOption("#selector", ["postname" . msq("simpleParamData")]); // stepKey: 004 - $I->unselectOption("#selector", [PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: 005 - $I->unselectOption("#selector", ["name", PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: 006 - $I->pressKey("#selector", PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test'), ['ctrl', 'a'],\Facebook\WebDriver\WebDriverKeys::DELETE,PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey001 - $I->pressKey("#selector", ['ctrl', 'a'], 10, 20,\Facebook\WebDriver\WebDriverKeys::DELETE,PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey002 - $I->pressKey("#selector", ['ctrl', 'a'],'new', 10, 20,\Facebook\WebDriver\WebDriverKeys::DELETE,PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey003 - $I->pressKey("#selector", ['ctrl', 'a'],'new', 1, ['ctrl'], ['shift', 'ctrl', 'del'], [PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test'), 'a', "name"]); // stepKey: pressKey004 - $I->pressKey("#selector", ['ctrl', 'a'],'new', 1, ['ctrl'], ['shift', 'ctrl', 'del'], 0, [PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: pressKey005 + $I->unselectOption("#selector", [$I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: 005 + $I->unselectOption("#selector", ["name", $I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: 006 + $I->pressKey("#selector", $I->retrieveEntityField('simpleDataKey', 'name', 'test'), ['ctrl', 'a'],\Facebook\WebDriver\WebDriverKeys::DELETE,$I->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey001 + $I->pressKey("#selector", ['ctrl', 'a'], 10, 20,\Facebook\WebDriver\WebDriverKeys::DELETE,$I->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey002 + $I->pressKey("#selector", ['ctrl', 'a'],'new', 10, 20,\Facebook\WebDriver\WebDriverKeys::DELETE,$I->retrieveEntityField('simpleDataKey', 'name', 'test')); // stepKey: pressKey003 + $I->pressKey("#selector", ['ctrl', 'a'],'new', 1, ['ctrl'], ['shift', 'ctrl', 'del'], [$I->retrieveEntityField('simpleDataKey', 'name', 'test'), 'a', "name"]); // stepKey: pressKey004 + $I->pressKey("#selector", ['ctrl', 'a'],'new', 1, ['ctrl'], ['shift', 'ctrl', 'del'], 0, [$I->retrieveEntityField('simpleDataKey', 'name', 'test'), $I->retrieveEntityField('simpleDataKey', 'name', 'test')]); // stepKey: pressKey005 $I->pressKey("#selector", ['ctrl', 'a'],'new', 1, ['ctrl'], ['shift', 'ctrl', 'del'], [msq("simpleParamData") . "prename", "postname" . msq("simpleParamData")]); // stepKey: pressKey006 } } diff --git a/dev/tests/verification/Resources/ParentExtendedTest.txt b/dev/tests/verification/Resources/ParentExtendedTest.txt index aeae567a2..5662da744 100644 --- a/dev/tests/verification/Resources/ParentExtendedTest.txt +++ b/dev/tests/verification/Resources/ParentExtendedTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt b/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt index c6c09c9c7..2f86f0af7 100644 --- a/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt +++ b/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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,7 +27,7 @@ class PersistedAndXmlEntityArgumentsCest public function PersistedAndXmlEntityArguments(AcceptanceTester $I) { $I->comment("Entering Action Group [afterGroup] FunctionalActionGroupWithXmlAndPersistedData"); - $I->seeInCurrentUrl("/" . PersistedObjectHandler::getInstance()->retrieveEntityField('persistedInTest', 'urlKey', 'test') . ".html?___store=" . msq("uniqueData") . "John"); // stepKey: checkUrlAfterGroup + $I->seeInCurrentUrl("/" . $I->retrieveEntityField('persistedInTest', 'urlKey', 'test') . ".html?___store=" . msq("uniqueData") . "John"); // stepKey: checkUrlAfterGroup $I->comment("Exiting Action Group [afterGroup] FunctionalActionGroupWithXmlAndPersistedData"); } } diff --git a/dev/tests/verification/Resources/PersistedReplacementTest.txt b/dev/tests/verification/Resources/PersistedReplacementTest.txt index eb3642ed1..5d8a0f1e5 100644 --- a/dev/tests/verification/Resources/PersistedReplacementTest.txt +++ b/dev/tests/verification/Resources/PersistedReplacementTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -26,7 +24,7 @@ class PersistedReplacementTestCest public function _before(AcceptanceTester $I) { $I->comment("[createData1] create 'ReplacementPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createData1", "hook", "ReplacementPerson", @@ -46,7 +44,7 @@ class PersistedReplacementTestCest public function PersistedReplacementTest(AcceptanceTester $I) { $I->comment("[createdData] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createdData", "test", "simpleData", @@ -54,27 +52,27 @@ class PersistedReplacementTestCest [] ); - $I->fillField("#selector", "StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: inputReplace - $I->fillField("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), "input"); // stepKey: selectorReplace - $I->fillField("#" . getenv("MAGENTO_BASE_URL") . "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), "input"); // stepKey: selectorReplace2 - $I->fillSecretField("#" . CredentialStore::getInstance()->getSecret("SECRET_PARAM") . "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), "input"); // stepKey: selectorReplace3 - $I->dragAndDrop("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'lastname', 'test')); // stepKey: selector12Replace - $I->conditionalClick(PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'lastname', 'test'), "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), true); // stepKey: dependentSelectorReplace - $I->amOnUrl(PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . ".html"); // stepKey: urlReplace - $I->searchAndMultiSelectOption("#selector", [PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'lastname', 'test')]); // stepKey: parameterArrayReplacement - $I->fillField("#selector", "John " . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " stringLiteral"); // stepKey: allTypesMixed - $I->searchAndMultiSelectOption("#selector", [PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test'), "John", "stringLiteral"]); // stepKey: parameterArrayMixed - $I->seeInPageSource("StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace1 - $I->seeInPageSource("StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace2 - $I->seeInPageSource("#" . getenv("MAGENTO_BASE_URL") . "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: htmlReplace3 - $I->dontSeeInPageSource("StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace4 - $I->dontSeeInPageSource("StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace5 - $I->dontSeeInPageSource("#" . getenv("MAGENTO_BASE_URL") . "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: htmlReplace6 - $I->seeInSource("StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace7 - $I->seeInSource("StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace8 - $I->seeInSource("#" . getenv("MAGENTO_BASE_URL") . "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: htmlReplace9 - $I->dontSeeInSource("StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace10 - $I->dontSeeInSource("StringBefore " . PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace11 - $I->dontSeeInSource("#" . getenv("MAGENTO_BASE_URL") . "#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: htmlReplace12 + $I->fillField("#selector", "StringBefore " . $I->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: inputReplace + $I->fillField("#" . $I->retrieveEntityField('createdData', 'firstname', 'test'), "input"); // stepKey: selectorReplace + $I->fillField("#" . getenv("MAGENTO_BASE_URL") . "#" . $I->retrieveEntityField('createdData', 'firstname', 'test'), "input"); // stepKey: selectorReplace2 + $I->fillSecretField("#" . $I->getSecret("SECRET_PARAM") . "#" . $I->retrieveEntityField('createdData', 'firstname', 'test'), "input"); // stepKey: selectorReplace3 + $I->dragAndDrop("#" . $I->retrieveEntityField('createdData', 'firstname', 'test'), $I->retrieveEntityField('createdData', 'lastname', 'test')); // stepKey: selector12Replace + $I->conditionalClick($I->retrieveEntityField('createdData', 'lastname', 'test'), "#" . $I->retrieveEntityField('createdData', 'firstname', 'test'), true); // stepKey: dependentSelectorReplace + $I->amOnUrl($I->retrieveEntityField('createdData', 'firstname', 'test') . ".html"); // stepKey: urlReplace + $I->searchAndMultiSelectOption("#selector", [$I->retrieveEntityField('createdData', 'firstname', 'test'), $I->retrieveEntityField('createdData', 'lastname', 'test')]); // stepKey: parameterArrayReplacement + $I->fillField("#selector", "John " . $I->retrieveEntityField('createdData', 'firstname', 'test') . " stringLiteral"); // stepKey: allTypesMixed + $I->searchAndMultiSelectOption("#selector", [$I->retrieveEntityField('createdData', 'firstname', 'test'), "John", "stringLiteral"]); // stepKey: parameterArrayMixed + $I->seeInPageSource("StringBefore " . $I->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace1 + $I->seeInPageSource("StringBefore " . $I->retrieveEntityField('createData1', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace2 + $I->seeInPageSource("#" . getenv("MAGENTO_BASE_URL") . "#" . $I->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: htmlReplace3 + $I->dontSeeInPageSource("StringBefore " . $I->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace4 + $I->dontSeeInPageSource("StringBefore " . $I->retrieveEntityField('createData1', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace5 + $I->dontSeeInPageSource("#" . getenv("MAGENTO_BASE_URL") . "#" . $I->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: htmlReplace6 + $I->seeInSource("StringBefore " . $I->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace7 + $I->seeInSource("StringBefore " . $I->retrieveEntityField('createData1', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace8 + $I->seeInSource("#" . getenv("MAGENTO_BASE_URL") . "#" . $I->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: htmlReplace9 + $I->dontSeeInSource("StringBefore " . $I->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace10 + $I->dontSeeInSource("StringBefore " . $I->retrieveEntityField('createData1', 'firstname', 'test') . " StringAfter"); // stepKey: htmlReplace11 + $I->dontSeeInSource("#" . getenv("MAGENTO_BASE_URL") . "#" . $I->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: htmlReplace12 } } diff --git a/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt b/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt index 95aab913f..2a3444324 100644 --- a/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt +++ b/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -27,7 +25,7 @@ class PersistenceActionGroupAppendingTestCest { $I->comment("Entering Action Group [ACTIONGROUPBEFORE] DataPersistenceAppendingActionGroup"); $I->comment("[createDataACTIONGROUPBEFORE] create 'entity' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createDataACTIONGROUPBEFORE", "hook", "entity", @@ -36,7 +34,7 @@ class PersistenceActionGroupAppendingTestCest ); $I->comment("[updateDataACTIONGROUPBEFORE] update 'createDataACTIONGROUPBEFORE' entity to 'newEntity'"); - PersistedObjectHandler::getInstance()->updateEntity( + $I->updateEntity( "createDataACTIONGROUPBEFORE", "hook", "newEntity", @@ -44,13 +42,13 @@ class PersistenceActionGroupAppendingTestCest ); $I->comment("[deleteDataACTIONGROUPBEFORE] delete entity 'createDataACTIONGROUPBEFORE'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "createDataACTIONGROUPBEFORE", "hook" ); $I->comment("[getDataACTIONGROUPBEFORE] get 'someEneity' entity"); - PersistedObjectHandler::getInstance()->getEntity( + $I->getEntity( "getDataACTIONGROUPBEFORE", "hook", "someEneity", @@ -58,7 +56,7 @@ class PersistenceActionGroupAppendingTestCest null ); - $I->comment(PersistedObjectHandler::getInstance()->retrieveEntityField('createData', 'field', 'hook')); + $I->comment($I->retrieveEntityField('createData', 'field', 'hook')); $I->comment("Exiting Action Group [ACTIONGROUPBEFORE] DataPersistenceAppendingActionGroup"); } @@ -73,7 +71,7 @@ class PersistenceActionGroupAppendingTestCest { $I->comment("Entering Action Group [ACTIONGROUP] DataPersistenceAppendingActionGroup"); $I->comment("[createDataACTIONGROUP] create 'entity' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createDataACTIONGROUP", "test", "entity", @@ -82,7 +80,7 @@ class PersistenceActionGroupAppendingTestCest ); $I->comment("[updateDataACTIONGROUP] update 'createDataACTIONGROUP' entity to 'newEntity'"); - PersistedObjectHandler::getInstance()->updateEntity( + $I->updateEntity( "createDataACTIONGROUP", "test", "newEntity", @@ -90,13 +88,13 @@ class PersistenceActionGroupAppendingTestCest ); $I->comment("[deleteDataACTIONGROUP] delete entity 'createDataACTIONGROUP'"); - PersistedObjectHandler::getInstance()->deleteEntity( + $I->deleteEntity( "createDataACTIONGROUP", "test" ); $I->comment("[getDataACTIONGROUP] get 'someEneity' entity"); - PersistedObjectHandler::getInstance()->getEntity( + $I->getEntity( "getDataACTIONGROUP", "test", "someEneity", @@ -104,7 +102,7 @@ class PersistenceActionGroupAppendingTestCest null ); - $I->comment(PersistedObjectHandler::getInstance()->retrieveEntityField('createDataACTIONGROUP', 'field', 'test')); + $I->comment($I->retrieveEntityField('createDataACTIONGROUP', 'field', 'test')); $I->comment("Exiting Action Group [ACTIONGROUP] DataPersistenceAppendingActionGroup"); } } diff --git a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt index 0a6deaca8..517bea53a 100644 --- a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt +++ b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -28,7 +26,7 @@ class PersistenceCustomFieldsTestCest $createData1Fields['firstname'] = "Mac"; $createData1Fields['lastname'] = "Doe"; $I->comment("[createData1] create 'DefaultPerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createData1", "hook", "DefaultPerson", @@ -36,9 +34,9 @@ class PersistenceCustomFieldsTestCest $createData1Fields ); - $createData2Fields['firstname'] = PersistedObjectHandler::getInstance()->retrieveEntityField('createData1', 'firstname', 'hook'); + $createData2Fields['firstname'] = $I->retrieveEntityField('createData1', 'firstname', 'hook'); $I->comment("[createData2] create 'uniqueData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createData2", "hook", "uniqueData", @@ -60,7 +58,7 @@ class PersistenceCustomFieldsTestCest $createdDataFields['favoriteIndex'] = "1"; $createdDataFields['middlename'] = "Kovacs"; $I->comment("[createdData] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createdData", "test", "simpleData", @@ -71,7 +69,7 @@ class PersistenceCustomFieldsTestCest $createdData3Fields['firstname'] = "Takeshi"; $createdData3Fields['lastname'] = "Kovacs"; $I->comment("[createdData3] create 'UniquePerson' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createdData3", "test", "UniquePerson", @@ -82,7 +80,7 @@ class PersistenceCustomFieldsTestCest $I->comment("Entering Action Group [createdAG] PersistenceActionGroup"); $createDataAG1CreatedAGFields['firstname'] = "string1"; $I->comment("[createDataAG1CreatedAG] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createDataAG1CreatedAG", "test", "simpleData", @@ -92,7 +90,7 @@ class PersistenceCustomFieldsTestCest $createDataAG2CreatedAGFields['firstname'] = "Jane"; $I->comment("[createDataAG2CreatedAG] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createDataAG2CreatedAG", "test", "simpleData", @@ -100,9 +98,9 @@ class PersistenceCustomFieldsTestCest $createDataAG2CreatedAGFields ); - $createDataAG3CreatedAGFields['firstname'] = PersistedObjectHandler::getInstance()->retrieveEntityField('createdData3', 'firstname', 'test'); + $createDataAG3CreatedAGFields['firstname'] = $I->retrieveEntityField('createdData3', 'firstname', 'test'); $I->comment("[createDataAG3CreatedAG] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createDataAG3CreatedAG", "test", "simpleData", @@ -113,7 +111,7 @@ class PersistenceCustomFieldsTestCest $I->comment("Exiting Action Group [createdAG] PersistenceActionGroup"); $I->comment("Entering Action Group [AGKEY] DataPersistenceSelfReferenceActionGroup"); $I->comment("[createData1AGKEY] create 'entity1' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createData1AGKEY", "test", "entity1", @@ -122,7 +120,7 @@ class PersistenceCustomFieldsTestCest ); $I->comment("[createData2AGKEY] create 'entity2' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createData2AGKEY", "test", "entity2", @@ -130,10 +128,10 @@ class PersistenceCustomFieldsTestCest [] ); - $createData3AGKEYFields['key1'] = PersistedObjectHandler::getInstance()->retrieveEntityField('createData1AGKEY', 'field', 'test'); - $createData3AGKEYFields['key2'] = PersistedObjectHandler::getInstance()->retrieveEntityField('createData2AGKEY', 'field', 'test'); + $createData3AGKEYFields['key1'] = $I->retrieveEntityField('createData1AGKEY', 'field', 'test'); + $createData3AGKEYFields['key2'] = $I->retrieveEntityField('createData2AGKEY', 'field', 'test'); $I->comment("[createData3AGKEY] create 'entity3' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createData3AGKEY", "test", "entity3", diff --git a/dev/tests/verification/Resources/SectionReplacementTest.txt b/dev/tests/verification/Resources/SectionReplacementTest.txt index 5089cfbfd..04efcee4b 100644 --- a/dev/tests/verification/Resources/SectionReplacementTest.txt +++ b/dev/tests/verification/Resources/SectionReplacementTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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; @@ -48,7 +46,7 @@ class SectionReplacementTestCest $I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .stringLiteral3"); // stepKey: selectorReplaceThreeParamDataRefMSQSuffix $I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .Doe" . msq("uniqueData") . " [stringLiteral3]"); // stepKey: selectorReplaceThreeParamOneDupeDataRefMSQSuffix $I->comment("[createdData] create 'simpleData' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createdData", "test", "simpleData", @@ -56,18 +54,18 @@ class SectionReplacementTestCest [] ); - $I->click("#element ." . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: selectorReplaceOneParamPersisted - $I->click("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .stringLiteral2"); // stepKey: selectorReplaceTwoParamPersisted - $I->click("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . "-stringLiteral2 .stringLiteral3"); // stepKey: selectorReplaceThreeParamPersisted - $I->click("#" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . "-stringLiteral2 ." . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " [stringLiteral3]"); // stepKey: selectorReplaceThreeParamOneDupePersisted + $I->click("#element ." . $I->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: selectorReplaceOneParamPersisted + $I->click("#" . $I->retrieveEntityField('createdData', 'firstname', 'test') . " .stringLiteral2"); // stepKey: selectorReplaceTwoParamPersisted + $I->click("#" . $I->retrieveEntityField('createdData', 'firstname', 'test') . "-stringLiteral2 .stringLiteral3"); // stepKey: selectorReplaceThreeParamPersisted + $I->click("#" . $I->retrieveEntityField('createdData', 'firstname', 'test') . "-stringLiteral2 ." . $I->retrieveEntityField('createdData', 'firstname', 'test') . " [stringLiteral3]"); // stepKey: selectorReplaceThreeParamOneDupePersisted $I->click("#element .{$data}"); // stepKey: selectorReplaceOneParamVariable $I->click("#{$data1} .{$data2}"); // stepKey: selectorReplaceTwoParamVariable $I->click("#{$data1}-{$data2} .{$data3}"); // stepKey: selectorReplaceThreeParamVariable $I->click("#John-Doe .John [Tiberius]"); // stepKey: selectorReplaceThreeParamVariableOneDupe - $I->click("#stringLiteral1-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .John"); // stepKey: selectorReplaceThreeParamMixed1 - $I->click("#stringLiteral1-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .{$data}"); // stepKey: selectorReplaceThreeParamMixed2 - $I->click("#stringLiteral1-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " ." . msq("uniqueData") . "John"); // stepKey: selectorReplaceThreeParamMixedMSQPrefix - $I->click("#stringLiteral1-" . PersistedObjectHandler::getInstance()->retrieveEntityField('createdData', 'firstname', 'test') . " .Doe" . msq("uniqueData")); // stepKey: selectorReplaceThreeParamMixedMSQSuffix + $I->click("#stringLiteral1-" . $I->retrieveEntityField('createdData', 'firstname', 'test') . " .John"); // stepKey: selectorReplaceThreeParamMixed1 + $I->click("#stringLiteral1-" . $I->retrieveEntityField('createdData', 'firstname', 'test') . " .{$data}"); // stepKey: selectorReplaceThreeParamMixed2 + $I->click("#stringLiteral1-" . $I->retrieveEntityField('createdData', 'firstname', 'test') . " ." . msq("uniqueData") . "John"); // stepKey: selectorReplaceThreeParamMixedMSQPrefix + $I->click("#stringLiteral1-" . $I->retrieveEntityField('createdData', 'firstname', 'test') . " .Doe" . msq("uniqueData")); // stepKey: selectorReplaceThreeParamMixedMSQSuffix $I->click("#element .1#element .2"); // stepKey: selectorReplaceTwoParamElements $I->click("#element .1#element .{$data}"); // stepKey: selectorReplaceTwoParamMixedTypes $I->click("(//div[@data-role='slide'])[1]/a[@data-element='link'][contains(@href,'')]"); // stepKey: selectorParamWithEmptyString diff --git a/dev/tests/verification/Resources/SkippedTest.txt b/dev/tests/verification/Resources/SkippedTest.txt index 08ff4fd43..dcad67e83 100644 --- a/dev/tests/verification/Resources/SkippedTest.txt +++ b/dev/tests/verification/Resources/SkippedTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/SkippedTestNoIssues.txt b/dev/tests/verification/Resources/SkippedTestNoIssues.txt index 168077458..3a7ca6f59 100644 --- a/dev/tests/verification/Resources/SkippedTestNoIssues.txt +++ b/dev/tests/verification/Resources/SkippedTestNoIssues.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/SkippedTestTwoIssues.txt b/dev/tests/verification/Resources/SkippedTestTwoIssues.txt index 3de81e02f..d3859978f 100644 --- a/dev/tests/verification/Resources/SkippedTestTwoIssues.txt +++ b/dev/tests/verification/Resources/SkippedTestTwoIssues.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use \Codeception\Util\Locator; use Yandex\Allure\Adapter\Annotation\Features; use Yandex\Allure\Adapter\Annotation\Stories; diff --git a/dev/tests/verification/Resources/SkippedTestWithHooks.txt b/dev/tests/verification/Resources/SkippedTestWithHooks.txt index a86924b94..667be6747 100644 --- a/dev/tests/verification/Resources/SkippedTestWithHooks.txt +++ b/dev/tests/verification/Resources/SkippedTestWithHooks.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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/XmlCommentedActionGroupTest.txt b/dev/tests/verification/Resources/XmlCommentedActionGroupTest.txt index 7e43433a1..480e35b73 100644 --- a/dev/tests/verification/Resources/XmlCommentedActionGroupTest.txt +++ b/dev/tests/verification/Resources/XmlCommentedActionGroupTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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/XmlCommentedTest.txt b/dev/tests/verification/Resources/XmlCommentedTest.txt index f77aa5fe4..5b8057099 100644 --- a/dev/tests/verification/Resources/XmlCommentedTest.txt +++ b/dev/tests/verification/Resources/XmlCommentedTest.txt @@ -2,8 +2,6 @@ namespace Magento\AcceptanceTest\_default\Backend; use Magento\FunctionalTestingFramework\AcceptanceTester; -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/Tests/SecretCredentialDataTest.php b/dev/tests/verification/Tests/SecretCredentialDataTest.php index 46391feee..d1ef43745 100644 --- a/dev/tests/verification/Tests/SecretCredentialDataTest.php +++ b/dev/tests/verification/Tests/SecretCredentialDataTest.php @@ -37,7 +37,7 @@ public function secretCredentialDataTest(AcceptanceTester $I) $createProductWithFieldOverridesUsingHardcodedData1Fields['price'] = "12.34"; $I->comment("[createProductWithFieldOverridesUsingHardcodedData1] create '_defaultProduct' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createProductWithFieldOverridesUsingHardcodedData1", "test", "_defaultProduct", @@ -46,13 +46,13 @@ public function secretCredentialDataTest(AcceptanceTester $I) ); $createProductWithFieldOverridesUsingSecretCredData1Fields['qty'] = - CredentialStore::getInstance()->getSecret("payment_authorizenet_trans_key"); + $I->getSecret("payment_authorizenet_trans_key"); $createProductWithFieldOverridesUsingSecretCredData1Fields['price'] = - CredentialStore::getInstance()->getSecret("carriers_dhl_account_eu"); + $I->getSecret("carriers_dhl_account_eu"); $I->comment("[createProductWithFieldOverridesUsingSecretCredData1] create '_defaultProduct' entity"); - PersistedObjectHandler::getInstance()->createEntity( + $I->createEntity( "createProductWithFieldOverridesUsingSecretCredData1", "test", "_defaultProduct", @@ -61,14 +61,14 @@ public function secretCredentialDataTest(AcceptanceTester $I) ); $I->fillField("#username", "Hardcoded"); // stepKey: fillFieldUsingHardCodedData1 - $I->fillSecretField("#username", CredentialStore::getInstance()->getSecret("carriers_dhl_id_eu")); + $I->fillSecretField("#username", $I->getSecret("carriers_dhl_id_eu")); // stepKey: fillFieldUsingSecretCredData1 $magentoCliUsingHardcodedData1 = $I->magentoCLI("config:set cms/wysiwyg/enabled 0"); // stepKey: magentoCliUsingHardcodedData1 $I->comment($magentoCliUsingHardcodedData1); $magentoCliUsingSecretCredData1 = $I->magentoCLI("config:set cms/wysiwyg/enabled " . - CredentialStore::getInstance()->getSecret("payment_authorizenet_login")); + $I->getSecret("payment_authorizenet_login")); // stepKey: magentoCliUsingSecretCredData1 $I->comment($magentoCliUsingSecretCredData1); } diff --git a/etc/config/functional.suite.dist.yml b/etc/config/functional.suite.dist.yml index 5487a3c99..319804d7a 100644 --- a/etc/config/functional.suite.dist.yml +++ b/etc/config/functional.suite.dist.yml @@ -16,6 +16,7 @@ modules: - \Magento\FunctionalTestingFramework\Helper\MagentoFakerData - \Magento\FunctionalTestingFramework\Module\MagentoSequence - \Magento\FunctionalTestingFramework\Module\MagentoAssert + - \Magento\FunctionalTestingFramework\Module\MagentoActionProxies - Asserts config: \Magento\FunctionalTestingFramework\Module\MagentoWebDriver: diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php index 42286564f..2a0f11a01 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -55,7 +55,6 @@ private function __construct() * Return the singleton instance of this class. Initialize it if needed. * * @return PersistedObjectHandler - * @throws \Exception */ public static function getInstance() { diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php index 16584e7a3..05178c915 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php @@ -123,8 +123,8 @@ public function executeRequest($dependentEntities) $returnRegex = $this->operationDefinition->getReturnRegex(); $returnIndex = $this->operationDefinition->getReturnIndex(); $method = $this->operationDefinition->getApiMethod(); - AllureHelper::addAttachmentToLastStep($apiUrl, 'API Endpoint'); - AllureHelper::addAttachmentToLastStep(json_encode($headers, JSON_PRETTY_PRINT), 'Request Headers'); + AllureHelper::addAttachmentToCurrentStep($apiUrl, 'API Endpoint'); + AllureHelper::addAttachmentToCurrentStep(json_encode($headers, JSON_PRETTY_PRINT), 'Request Headers'); $operationDataResolver = new OperationDataArrayResolver($dependentEntities); $this->requestData = $operationDataResolver->resolveOperationDataArray( @@ -169,8 +169,8 @@ public function executeRequest($dependentEntities) $response = $executor->read($successRegex, $returnRegex, $returnIndex); $executor->close(); - AllureHelper::addAttachmentToLastStep(json_encode($this->requestData, JSON_PRETTY_PRINT), 'Request Body'); - AllureHelper::addAttachmentToLastStep( + AllureHelper::addAttachmentToCurrentStep(json_encode($this->requestData, JSON_PRETTY_PRINT), 'Request Body'); + AllureHelper::addAttachmentToCurrentStep( json_encode(json_decode($response, true), JSON_PRETTY_PRINT+JSON_UNESCAPED_UNICODE+JSON_UNESCAPED_SLASHES), 'Response Data' ); diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php b/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php new file mode 100644 index 000000000..1cc02b58f --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php @@ -0,0 +1,157 @@ + Value of override fields. + * @param string $storeCode + * @return void + */ + public function createEntity( + $key, + $scope, + $entity, + $dependentObjectKeys = [], + $overrideFields = [], + $storeCode = '' + ) { + if (!self::$persistHandler) { + self::$persistHandler = PersistedObjectHandler::getInstance(); + } + + self::$persistHandler->createEntity( + $key, + $scope, + $entity, + $dependentObjectKeys, + $overrideFields, + $storeCode + ); + } + + /** + * 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 = []) + { + if (!self::$persistHandler) { + self::$persistHandler = PersistedObjectHandler::getInstance(); + } + + self::$persistHandler->updateEntity( + $key, + $scope, + $updateEntity, + $dependentObjectKeys + ); + } + + /** + * 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) + { + if (!self::$persistHandler) { + self::$persistHandler = PersistedObjectHandler::getInstance(); + } + + self::$persistHandler->getEntity( + $key, + $scope, + $entity, + $dependentObjectKeys, + $storeCode, + $index + ); + } + + /** + * 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) + { + if (!self::$persistHandler) { + self::$persistHandler = PersistedObjectHandler::getInstance(); + } + + self::$persistHandler->deleteEntity($key, $scope); + } + + /** + * Retrieves a field from an entity, according to key and scope given + * + * @param string $stepKey + * @param string $field + * @param string $scope + * @return string + */ + public function retrieveEntityField($stepKey, $field, $scope) + { + if (!self::$persistHandler) { + self::$persistHandler = PersistedObjectHandler::getInstance(); + } + + return self::$persistHandler->retrieveEntityField($stepKey, $field, $scope); + } + + /** + * Get encrypted value by key + * + * @param string $key + * @return string|null + * @throws TestFrameworkException + */ + public function getSecret($key) + { + return CredentialStore::getInstance()->getSecret($key); + } +} diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index 8f60e1e90..447869f38 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -192,7 +192,7 @@ public function getType() /** * Getter for actionOrigin * - * @return string + * @return array */ public function getActionOrigin() { diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 7b0d2916e..19c761d9c 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -57,6 +57,13 @@ class TestGenerator ]; const STEP_KEY_ANNOTATION = " // stepKey: %s"; + /** + * Actor name for AcceptanceTest + * + * @var string + */ + private $actor = 'I'; + /** * Path to the export dir. * @@ -97,7 +104,7 @@ class TestGenerator * * @var string */ - private $currentGenerationScope; + private $currentGenerationScope = TestGenerator::TEST_SCOPE; /** * TestGenerator constructor. @@ -326,8 +333,6 @@ private function debug($messages) private function generateUseStatementsPhp() { $useStatementsPhp = "use Magento\FunctionalTestingFramework\AcceptanceTester;\n"; - $useStatementsPhp .= "use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore;\n"; - $useStatementsPhp .= "use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler;\n"; $useStatementsPhp .= "use \Codeception\Util\Locator;\n"; $allureStatements = [ @@ -499,7 +504,8 @@ private function generateClassAnnotations($annotationType, $annotationName) public function generateStepsPhp($actionObjects, $generationScope = TestGenerator::TEST_SCOPE, $actor = "I") { //TODO: Refactor Method according to PHPMD warnings, remove @SuppressWarnings accordingly. - $testSteps = ""; + $testSteps = ''; + $this->actor = $actor; $this->currentGenerationScope = $generationScope; foreach ($actionObjects as $actionObject) { @@ -754,7 +760,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $scope = PersistedObjectHandler::SUITE_SCOPE; } - $createEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->createEntity("; + $createEntityFunctionCall = "\t\t\${$actor}->createEntity("; $createEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; $createEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $createEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; @@ -795,7 +801,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $scope = PersistedObjectHandler::SUITE_SCOPE; } - $deleteEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->deleteEntity("; + $deleteEntityFunctionCall = "\t\t\${$actor}->deleteEntity("; $deleteEntityFunctionCall .= "\n\t\t\t\"{$key}\","; $deleteEntityFunctionCall .= "\n\t\t\t\"{$scope}\""; $deleteEntityFunctionCall .= "\n\t\t);\n"; @@ -853,7 +859,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $scope = PersistedObjectHandler::SUITE_SCOPE; } - $updateEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->updateEntity("; + $updateEntityFunctionCall = "\t\t\${$actor}->updateEntity("; $updateEntityFunctionCall .= "\n\t\t\t\"{$key}\","; $updateEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $updateEntityFunctionCall .= "\n\t\t\t\"{$updateEntity}\""; @@ -901,7 +907,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato } //Create Function - $getEntityFunctionCall = "\t\tPersistedObjectHandler::getInstance()->getEntity("; + $getEntityFunctionCall = "\t\t\${$actor}->getEntity("; $getEntityFunctionCall .= "\n\t\t\t\"{$stepKey}\","; $getEntityFunctionCall .= "\n\t\t\t\"{$scope}\","; $getEntityFunctionCall .= "\n\t\t\t\"{$entity}\""; @@ -1429,7 +1435,11 @@ private function replaceMatchesIntoArg($matches, &$outputArg) ); } - $replacement = "PersistedObjectHandler::getInstance()->retrieveEntityField"; + $actor = "\$" . $this->actor; + if ($this->currentGenerationScope === TestGenerator::SUITE_SCOPE) { + $actor = 'PersistedObjectHandler::getInstance()'; + } + $replacement = "{$actor}->retrieveEntityField"; $replacement .= "('{$variable[0]}', '$variable[1]', '{$this->currentGenerationScope}')"; //Determine if quoteBreak check is necessary. Assume replacement is surrounded in quotes, then override @@ -1484,9 +1494,14 @@ private function resolveStepKeyReferences($input, $actionGroupOrigin, $matchAll foreach ($stepKeys as $stepKey) { // MQE-1011 $stepKeyVarRef = "$" . $stepKey; - $persistedVarRef = "PersistedObjectHandler::getInstance()->retrieveEntityField('{$stepKey}'" + + $actor = "\$" . $this->actor; + if ($this->currentGenerationScope === TestGenerator::SUITE_SCOPE) { + $actor = 'PersistedObjectHandler::getInstance()'; + } + $persistedVarRef = "{$actor}->retrieveEntityField('{$stepKey}'" . ", 'field', 'test')"; - $persistedVarRefInvoked = "PersistedObjectHandler::getInstance()->retrieveEntityField('" + $persistedVarRefInvoked = "{$actor}->retrieveEntityField('" . $stepKey . $testInvocationKey . "', 'field', 'test')"; // only replace when whole word matches exactly @@ -1876,6 +1891,7 @@ private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $actio $output .= implode(", ", array_filter($args, function($value) { return $value !== null; })) . ");"; return $output; } + // @codingStandardsIgnoreEnd /** @@ -1919,7 +1935,7 @@ private function resolveAllRuntimeReferences($args) { $runtimeReferenceRegex = [ "/{{_ENV\.([\w]+)}}/" => 'getenv', - ActionMergeUtil::CREDS_REGEX => 'CredentialStore::getInstance()->getSecret' + ActionMergeUtil::CREDS_REGEX => "\${$this->actor}->getSecret" ]; $argResult = $args; From c1964dc87f31ed31c079a7e3e6ca9633bc9092bd Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Mon, 2 Dec 2019 10:01:10 -0600 Subject: [PATCH 02/67] MQE-1379: Fix MFTF custom actions to fully support Codeception dry-run functionality --- dev/tests/verification/Resources/BasicFunctionalTest.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index 8e13d916c..812972eed 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -128,9 +128,9 @@ class BasicFunctionalTestCest $I->comment($magentoCli1); $magentoCli2 = $I->magentoCLI("maintenance:enable", 120, "\"stuffHere\""); // stepKey: magentoCli2 $I->comment($magentoCli2); - $magentoCli3 = $I->magentoCLISecret("config:set somePath " . CredentialStore::getInstance()->getSecret("someKey"), 60); // stepKey: magentoCli3 + $magentoCli3 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 60); // stepKey: magentoCli3 $I->comment($magentoCli3); // stepKey: magentoCli3 - $magentoCli4 = $I->magentoCLISecret("config:set somePath " . CredentialStore::getInstance()->getSecret("someKey"), 120); // stepKey: magentoCli4 + $magentoCli4 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 120); // stepKey: magentoCli4 $I->comment($magentoCli4); // stepKey: magentoCli4 $I->makeScreenshot("screenShotInput"); // stepKey: makeScreenshotKey1 $I->maximizeWindow(); // stepKey: maximizeWindowKey1 From be3bd6e7951affb025961a8745509586ed69a720 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Tue, 3 Dec 2019 11:48:52 -0600 Subject: [PATCH 03/67] MQE-1379: Fix MFTF custom actions to fully support Codeception dry-run functionality - work around MQE-1904 --- .../Module/MagentoActionProxies.php | 60 ++++----- .../Module/MagentoWebDriver.php | 116 ++++++++++++++++++ 2 files changed, 139 insertions(+), 37 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php b/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php index 1cc02b58f..18c800e48 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php @@ -20,15 +20,9 @@ */ class MagentoActionProxies extends CodeceptionModule { - /** - * PersistedObjectHandler instance - * - * @var PersistedObjectHandler - */ - private static $persistHandler = null; - /** * Create an entity + * TODO: un-comment this function after MQE-1904 * * @param string $key StepKey of the createData action. * @param string $scope @@ -38,6 +32,7 @@ class MagentoActionProxies extends CodeceptionModule * @param string $storeCode * @return void */ + /* public function createEntity( $key, $scope, @@ -46,11 +41,7 @@ public function createEntity( $overrideFields = [], $storeCode = '' ) { - if (!self::$persistHandler) { - self::$persistHandler = PersistedObjectHandler::getInstance(); - } - - self::$persistHandler->createEntity( + PersistedObjectHandler::getInstance()->createEntity( $key, $scope, $entity, @@ -59,9 +50,10 @@ public function createEntity( $storeCode ); } - + */ /** * Retrieves and updates a previously created entity + * TODO: un-comment this function after MQE-1904 * * @param string $key StepKey of the createData action. * @param string $scope @@ -69,22 +61,20 @@ public function createEntity( * @param array $dependentObjectKeys StepKeys of other createData actions that are required. * @return void */ + /* public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = []) { - if (!self::$persistHandler) { - self::$persistHandler = PersistedObjectHandler::getInstance(); - } - - self::$persistHandler->updateEntity( + PersistedObjectHandler::getInstance()->updateEntity( $key, $scope, $updateEntity, $dependentObjectKeys ); } - + */ /** * Performs GET on given entity and stores entity for use + * TODO: un-comment this function after MQE-1904 * * @param string $key StepKey of getData action. * @param string $scope @@ -94,13 +84,10 @@ public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = * @param integer $index * @return void */ + /* public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $storeCode = '', $index = null) { - if (!self::$persistHandler) { - self::$persistHandler = PersistedObjectHandler::getInstance(); - } - - self::$persistHandler->getEntity( + PersistedObjectHandler::getInstance()->getEntity( $key, $scope, $entity, @@ -109,49 +96,48 @@ public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $sto $index ); } - + */ /** * Retrieves and deletes a previously created entity + * TODO: un-comment this function after MQE-1904 * * @param string $key StepKey of the createData action. * @param string $scope * @return void */ + /* public function deleteEntity($key, $scope) { - if (!self::$persistHandler) { - self::$persistHandler = PersistedObjectHandler::getInstance(); - } - - self::$persistHandler->deleteEntity($key, $scope); + PersistedObjectHandler::getInstance()->deleteEntity($key, $scope); } - + */ /** * Retrieves a field from an entity, according to key and scope given + * TODO: un-comment this function after MQE-1904 * * @param string $stepKey * @param string $field * @param string $scope * @return string */ + /* public function retrieveEntityField($stepKey, $field, $scope) { - if (!self::$persistHandler) { - self::$persistHandler = PersistedObjectHandler::getInstance(); - } - - return self::$persistHandler->retrieveEntityField($stepKey, $field, $scope); + return PersistedObjectHandler::getInstance()->retrieveEntityField($stepKey, $field, $scope); } - + */ /** * Get encrypted value by key + * TODO: un-comment this function after MQE-1904 * * @param string $key * @return string|null * @throws TestFrameworkException */ + /* public function getSecret($key) { return CredentialStore::getInstance()->getSecret($key); } + */ } diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index cbde1ddfc..4cb980d9c 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -27,6 +27,7 @@ use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Exception\WebDriverCurlException; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; /** * MagentoWebDriver module provides common Magento web actions through Selenium WebDriver. @@ -47,6 +48,7 @@ * ``` * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.ExcessivePublicCount) */ class MagentoWebDriver extends WebDriver { @@ -904,4 +906,118 @@ private function curlExecMagentoCLI($command, $timeout, $arguments): string return $response; } + + /** + * Create an entity + * TODO: remove this function after MQE-1904 + * + * @param string $key StepKey of the createData action. + * @param string $scope + * @param string $entity Name of xml entity to create. + * @param array $dependentObjectKeys StepKeys of other createData actions that are required. + * @param array $overrideFields Array of FieldName => Value of override fields. + * @param string $storeCode + * @return void + */ + public function createEntity( + $key, + $scope, + $entity, + $dependentObjectKeys = [], + $overrideFields = [], + $storeCode = '' + ) { + PersistedObjectHandler::getInstance()->createEntity( + $key, + $scope, + $entity, + $dependentObjectKeys, + $overrideFields, + $storeCode + ); + } + + /** + * Retrieves and updates a previously created entity + * TODO: remove this function after MQE-1904 + * + * @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 = []) + { + PersistedObjectHandler::getInstance()->updateEntity( + $key, + $scope, + $updateEntity, + $dependentObjectKeys + ); + } + + /** + * Performs GET on given entity and stores entity for use + * TODO: remove this function after MQE-1904 + * + * @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) + { + PersistedObjectHandler::getInstance()->getEntity( + $key, + $scope, + $entity, + $dependentObjectKeys, + $storeCode, + $index + ); + } + + /** + * Retrieves and deletes a previously created entity + * TODO: remove this function after MQE-1904 + * + * @param string $key StepKey of the createData action. + * @param string $scope + * @return void + */ + public function deleteEntity($key, $scope) + { + PersistedObjectHandler::getInstance()->deleteEntity($key, $scope); + } + + /** + * Retrieves a field from an entity, according to key and scope given + * TODO: remove this function after MQE-1904 + * + * @param string $stepKey + * @param string $field + * @param string $scope + * @return string + */ + public function retrieveEntityField($stepKey, $field, $scope) + { + return PersistedObjectHandler::getInstance()->retrieveEntityField($stepKey, $field, $scope); + } + + /** + * Get encrypted value by key + * TODO: remove this function after MQE-1904 + * + * @param string $key + * @return string|null + * @throws TestFrameworkException + */ + public function getSecret($key) + { + return CredentialStore::getInstance()->getSecret($key); + } } From 29f770c50d06922885d92df8dc543d423789f6be Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 4 Dec 2019 14:18:58 -0600 Subject: [PATCH 04/67] MQE-1379: Fix MFTF custom actions to fully support Codeception dry-run functionality --- .../Resources/ActionGroupUsingCreateData.txt | 20 +--- .../ActionGroupWithDataOverrideTest.txt | 10 +- .../Resources/ActionGroupWithDataTest.txt | 10 +- .../ActionGroupWithNoDefaultTest.txt | 10 +- ...meterizedElementsWithStepKeyReferences.txt | 10 +- .../ActionGroupWithPersistedData.txt | 20 +--- .../ActionGroupWithStepKeyReferences.txt | 46 +------- .../ActionGroupWithTopLevelPersistedData.txt | 10 +- .../ArgumentWithSameNameAsElement.txt | 10 +- .../verification/Resources/AssertTest.txt | 20 +--- .../Resources/BasicActionGroupTest.txt | 10 +- .../Resources/BasicFunctionalTest.txt | 10 +- .../Resources/DataActionsTest.txt | 68 ++---------- .../Resources/ExtendParentDataTest.txt | 10 +- .../Resources/ExtendedParameterArrayTest.txt | 9 +- .../Resources/HookActionsTest.txt | 44 +------- .../Resources/LocatorFunctionTest.txt | 10 +- .../Resources/MergedActionGroupTest.txt | 10 +- .../Resources/MultipleActionGroupsTest.txt | 10 +- .../Resources/PageReplacementTest.txt | 10 +- .../Resources/ParameterArrayTest.txt | 10 +- .../Resources/PersistedReplacementTest.txt | 20 +--- .../PersistenceActionGroupAppendingTest.txt | 72 ++----------- .../Resources/PersistenceCustomFieldsTest.txt | 100 ++---------------- .../Resources/SectionReplacementTest.txt | 10 +- .../Resources/functionalSuiteHooks.txt | 2 +- .../Allure/Adapter/MagentoAllureAdapter.php | 61 +++++++++-- .../Codeception/Subscriber/Console.php | 54 +++++++++- .../Test/Objects/ActionObject.php | 1 + .../Util/TestGenerator.php | 89 +++++----------- 30 files changed, 196 insertions(+), 580 deletions(-) diff --git a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt index 8ec0a88a8..fb76b4f44 100644 --- a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt +++ b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt @@ -24,24 +24,8 @@ class ActionGroupUsingCreateDataCest public function _before(AcceptanceTester $I) { $I->comment("Entering Action Group [Key1] actionGroupWithCreateData"); - $I->comment("[createCategoryKey1] create 'ApiCategory' entity"); - $I->createEntity( - "createCategoryKey1", - "hook", - "ApiCategory", - [], - [] - ); - - $I->comment("[createConfigProductKey1] create 'ApiConfigurableProduct' entity"); - $I->createEntity( - "createConfigProductKey1", - "hook", - "ApiConfigurableProduct", - ["createCategoryKey1"], - [] - ); - + $I->createEntity("createCategoryKey1", "hook", "ApiCategory", [], []); // stepKey: createCategoryKey1 + $I->createEntity("createConfigProductKey1", "hook", "ApiConfigurableProduct", ["createCategoryKey1"], []); // stepKey: createConfigProductKey1 $I->comment("Exiting Action Group [Key1] actionGroupWithCreateData"); } diff --git a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt index 9ad3f7127..a455d98e0 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt @@ -24,15 +24,7 @@ class ActionGroupWithDataOverrideTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup diff --git a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt index f1a0f6219..7ac32f550 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt @@ -24,15 +24,7 @@ class ActionGroupWithDataTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup diff --git a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt index 99615c728..ca6474a7b 100644 --- a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt @@ -24,15 +24,7 @@ class ActionGroupWithNoDefaultTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup diff --git a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt index 561f4d1b2..b0758e679 100644 --- a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt @@ -29,15 +29,7 @@ class ActionGroupWithParameterizedElementsWithStepKeyReferencesCest $I->comment("Entering Action Group [actionGroup] actionGroupWithParametrizedSelectors"); $testVariableActionGroup = $I->executeJS("return 1"); // stepKey: testVariableActionGroup $testVariable2ActionGroup = $I->executeJS("return 'test'"); // stepKey: testVariable2ActionGroup - $I->comment("[createSimpleDataActionGroup] create 'simpleData' entity"); - $I->createEntity( - "createSimpleDataActionGroup", - "test", - "simpleData", - [], - [] - ); - + $I->createEntity("createSimpleDataActionGroup", "test", "simpleData", [], []); // stepKey: createSimpleDataActionGroup $I->click("#{$testVariable2ActionGroup} .John"); // stepKey: click1ActionGroup $I->click("#Doe-" . msq("simpleParamData") . "prename .{$testVariableActionGroup}"); // stepKey: click2ActionGroup $I->seeElement("//div[@name='Tiberius'][@class={$testVariableActionGroup}][@data-element='{$testVariable2ActionGroup}'][" . $I->retrieveEntityField('createSimpleData', 'name', 'test') . "]"); // stepKey: see1ActionGroup diff --git a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt index 0bec544bf..e8eb29996 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt @@ -24,15 +24,7 @@ class ActionGroupWithPersistedDataCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup @@ -71,15 +63,7 @@ class ActionGroupWithPersistedDataCest */ public function ActionGroupWithPersistedData(AcceptanceTester $I) { - $I->comment("[createPerson] create 'DefaultPerson' entity"); - $I->createEntity( - "createPerson", - "test", - "DefaultPerson", - [], - [] - ); - + $I->createEntity("createPerson", "test", "DefaultPerson", [], []); // stepKey: createPerson $I->comment("Entering Action Group [actionGroupWithPersistedData1] FunctionalActionGroupWithData"); $I->amOnPage("/" . $I->retrieveEntityField('createPerson', 'firstname', 'test') . "/" . $I->retrieveEntityField('createPerson', 'lastname', 'test') . ".html"); // stepKey: amOnPage1ActionGroupWithPersistedData1 $I->fillField("#foo", $I->retrieveEntityField('createPerson', 'firstname', 'test')); // stepKey: fillField1ActionGroupWithPersistedData1 diff --git a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt index aeda5e84e..2ee5b4bf9 100644 --- a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt @@ -27,15 +27,7 @@ class ActionGroupWithStepKeyReferencesCest public function ActionGroupWithStepKeyReferences(AcceptanceTester $I) { $I->comment("Entering Action Group [actionGroup] FunctionActionGroupWithStepKeyReferences"); - $I->comment("[createSimpleDataActionGroup] create 'simpleData' entity"); - $I->createEntity( - "createSimpleDataActionGroup", - "test", - "simpleData", - [], - [] - ); - + $I->createEntity("createSimpleDataActionGroup", "test", "simpleData", [], []); // stepKey: createSimpleDataActionGroup $grabTextDataActionGroup = $I->grabTextFrom(".class"); // stepKey: grabTextDataActionGroup $I->fillField(".{$grabTextDataActionGroup}", $I->retrieveEntityField('createSimpleDataActionGroup', 'field', 'test')); // stepKey: fill1ActionGroup $I->comment("Invocation stepKey will not be appended in non stepKey instances"); @@ -51,38 +43,10 @@ class ActionGroupWithStepKeyReferencesCest $action5ActionGroup = $date->format("H:i:s"); $action6ActionGroup = $I->formatMoney($action6ActionGroup); // stepKey: action6ActionGroup - $I->comment("[action7ActionGroup] delete entity '{$action7ActionGroupActionGroup}'"); - $I->deleteEntity( - "{$action7ActionGroupActionGroup}", - "test" - ); - - $I->comment("[action8ActionGroup] get '{$action8}' entity"); - $I->getEntity( - "action8ActionGroup", - "test", - "{$action8}", - [], - null - ); - - $I->comment("[action9ActionGroup] update '1' entity to '{$action9}'"); - $I->updateEntity( - "1", - "test", - "{$action9}", - [] - ); - - $I->comment("[action10ActionGroup] create '{$action10}' entity"); - $I->createEntity( - "action10ActionGroup", - "test", - "{$action10}", - [], - [] - ); - + $I->deleteEntity("{$action7ActionGroupActionGroup}", "test"); // stepKey: action7ActionGroup + $I->getEntity("action8ActionGroup", "test", "{$action8}", [], null); // stepKey: action8ActionGroup + $I->updateEntity("1", "test", "{$action9}",[]); // stepKey: action9ActionGroup + $I->createEntity("action10ActionGroup", "test", "{$action10}", [], []); // stepKey: action10ActionGroup $action11ActionGroup = $I->grabAttributeFrom($action11ActionGroup, "someInput"); // stepKey: action11ActionGroup $action12ActionGroup = $I->grabCookie($action12ActionGroup, ['domain' => 'www.google.com']); // stepKey: action12ActionGroup $action13ActionGroup = $I->grabFromCurrentUrl($action13ActionGroup); // stepKey: action13ActionGroup diff --git a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt index 6567bdbb0..ca8325402 100644 --- a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt @@ -24,15 +24,7 @@ class ActionGroupWithTopLevelPersistedDataCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup diff --git a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt index 54bb012e9..44a00dbd9 100644 --- a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt +++ b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt @@ -24,15 +24,7 @@ class ArgumentWithSameNameAsElementCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup diff --git a/dev/tests/verification/Resources/AssertTest.txt b/dev/tests/verification/Resources/AssertTest.txt index 50eb50e24..e7f24b605 100644 --- a/dev/tests/verification/Resources/AssertTest.txt +++ b/dev/tests/verification/Resources/AssertTest.txt @@ -23,15 +23,7 @@ class AssertTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createData1] create 'ReplacementPerson' entity"); - $I->createEntity( - "createData1", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createData1", "hook", "ReplacementPerson", [], []); // stepKey: createData1 } /** @@ -43,15 +35,7 @@ class AssertTestCest */ public function AssertTest(AcceptanceTester $I) { - $I->comment("[createData2] create 'UniquePerson' entity"); - $I->createEntity( - "createData2", - "test", - "UniquePerson", - [], - [] - ); - + $I->createEntity("createData2", "test", "UniquePerson", [], []); // stepKey: createData2 $grabTextFrom1 = $I->grabTextFrom(".copyright>span"); // stepKey: grabTextFrom1 $I->comment("custom asserts"); $I->assertArrayIsSorted(["1", "2", "3", "4", "5"], "asc"); // stepKey: assertSorted1 diff --git a/dev/tests/verification/Resources/BasicActionGroupTest.txt b/dev/tests/verification/Resources/BasicActionGroupTest.txt index 79fbd3513..02915d1a8 100644 --- a/dev/tests/verification/Resources/BasicActionGroupTest.txt +++ b/dev/tests/verification/Resources/BasicActionGroupTest.txt @@ -24,15 +24,7 @@ class BasicActionGroupTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index 812972eed..5bcfd55dd 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -74,14 +74,8 @@ class BasicFunctionalTestCest $I->clickWithRightButton("#element .4123#element", 200, 300); // stepKey: clickWithRightButtonKeyXY1 $I->closeTab(); // stepKey: closeTabKey1 $I->conditionalClick(".functionalTestSelector", ".functionalDependentTestSelector", true); // stepKey: conditionalClickKey1 - $I->comment("[deleteKey1] delete entity 'createKey1'"); - $I->deleteEntity( - "createKey1", - "test" - ); - - $I->deleteEntityByUrl("/V1/categories{$grabbedData}"); - + $I->deleteEntity("createKey1", "test"); // stepKey: deleteKey1 + $I->deleteEntityByUrl("/V1/categories{$grabbedData}"); // stepKey: deleteKey2 $I->dontSee("someInput", ".functionalTestSelector"); // stepKey: dontSeeKey1 $I->dontSeeCheckboxIsChecked(".functionalTestSelector"); // stepKey: dontSeeCheckboxIsCheckedKey1 $I->dontSeeCookie("someInput"); // stepKey: dontSeeCookieKey1 diff --git a/dev/tests/verification/Resources/DataActionsTest.txt b/dev/tests/verification/Resources/DataActionsTest.txt index bbfbafa21..c3f8400b3 100644 --- a/dev/tests/verification/Resources/DataActionsTest.txt +++ b/dev/tests/verification/Resources/DataActionsTest.txt @@ -23,29 +23,9 @@ class DataActionsTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createdInBefore] create 'entity' entity"); - $I->createEntity( - "createdInBefore", - "hook", - "entity", - [], - [] - ); - - $I->comment("[updateInBefore] update 'createdInBefore' entity to 'entity'"); - $I->updateEntity( - "createdInBefore", - "hook", - "entity", - [] - ); - - $I->comment("[deleteInBefore] delete entity 'createdInBefore'"); - $I->deleteEntity( - "createdInBefore", - "hook" - ); - + $I->createEntity("createdInBefore", "hook", "entity", [], []); // stepKey: createdInBefore + $I->updateEntity("createdInBefore", "hook", "entity",[]); // stepKey: updateInBefore + $I->deleteEntity("createdInBefore", "hook"); // stepKey: deleteInBefore } /** @@ -57,42 +37,10 @@ class DataActionsTestCest */ public function DataActionsTest(AcceptanceTester $I) { - $I->comment("[createdInTest] create 'entity' entity"); - $I->createEntity( - "createdInTest", - "test", - "entity", - [], - [] - ); - - $I->comment("[updateInTest] update 'createdInTest' entity to 'entity'"); - $I->updateEntity( - "createdInTest", - "test", - "entity", - [] - ); - - $I->comment("[deleteInTest] delete entity 'createdInTest'"); - $I->deleteEntity( - "createdInTest", - "test" - ); - - $I->comment("[updatedDataOutOfScope] update 'createdInBefore' entity to 'entity'"); - $I->updateEntity( - "createdInBefore", - "test", - "entity", - [] - ); - - $I->comment("[deleteDataOutOfScope] delete entity 'createdInBefore'"); - $I->deleteEntity( - "createdInBefore", - "test" - ); - + $I->createEntity("createdInTest", "test", "entity", [], []); // stepKey: createdInTest + $I->updateEntity("createdInTest", "test", "entity",[]); // stepKey: updateInTest + $I->deleteEntity("createdInTest", "test"); // stepKey: deleteInTest + $I->updateEntity("createdInBefore", "test", "entity",[]); // stepKey: updatedDataOutOfScope + $I->deleteEntity("createdInBefore", "test"); // stepKey: deleteDataOutOfScope } } diff --git a/dev/tests/verification/Resources/ExtendParentDataTest.txt b/dev/tests/verification/Resources/ExtendParentDataTest.txt index 5a698b55f..d26d91b08 100644 --- a/dev/tests/verification/Resources/ExtendParentDataTest.txt +++ b/dev/tests/verification/Resources/ExtendParentDataTest.txt @@ -26,15 +26,7 @@ class ExtendParentDataTestCest */ public function ExtendParentDataTest(AcceptanceTester $I) { - $I->comment("[simpleDataKey] create 'extendParentData' entity"); - $I->createEntity( - "simpleDataKey", - "test", - "extendParentData", - [], - [] - ); - + $I->createEntity("simpleDataKey", "test", "extendParentData", [], []); // stepKey: simpleDataKey $I->searchAndMultiSelectOption("#selector", ["otherName"]); // stepKey: getName $I->searchAndMultiSelectOption("#selector", ["extendName"]); // stepKey: getNameExtend $I->searchAndMultiSelectOption("#selector", ["item"]); // stepKey: emptyPost diff --git a/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt b/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt index e5016216d..d09e9a0b6 100644 --- a/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt +++ b/dev/tests/verification/Resources/ExtendedParameterArrayTest.txt @@ -25,14 +25,7 @@ class ExtendParentDataTestCest */ public function ExtendParentDataTest(AcceptanceTester $I) { - $I->amGoingTo("create entity that has the stepKey: simpleDataKey"); - $I->createEntity( - "simpleDataKey", - "test", - "extendParentData", - [], - [] - ); + $I->createEntity("simpleDataKey", "test", "extendParentData", [], []); // stepKey: simpleDataKey $I->searchAndMultiSelectOption("#selector", ["otherName"]); $I->searchAndMultiSelectOption("#selector", ["extendName"]); $I->searchAndMultiSelectOption("#selector", ["item"]); diff --git a/dev/tests/verification/Resources/HookActionsTest.txt b/dev/tests/verification/Resources/HookActionsTest.txt index 9ed9c0bc5..c61cc86e2 100644 --- a/dev/tests/verification/Resources/HookActionsTest.txt +++ b/dev/tests/verification/Resources/HookActionsTest.txt @@ -23,30 +23,9 @@ class HookActionsTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[sampleCreateBefore] create 'sampleCreatedEntity' entity"); - $I->createEntity( - "sampleCreateBefore", - "hook", - "sampleCreatedEntity", - [], - [] - ); - - $I->comment("[sampleDeleteBefore] delete entity 'sampleCreateBefore'"); - $I->deleteEntity( - "sampleCreateBefore", - "hook" - ); - - $I->comment("[sampleCreateForAfter] create 'sampleCreatedEntity' entity"); - $I->createEntity( - "sampleCreateForAfter", - "hook", - "sampleCreatedEntity", - [], - [] - ); - + $I->createEntity("sampleCreateBefore", "hook", "sampleCreatedEntity", [], []); // stepKey: sampleCreateBefore + $I->deleteEntity("sampleCreateBefore", "hook"); // stepKey: sampleDeleteBefore + $I->createEntity("sampleCreateForAfter", "hook", "sampleCreatedEntity", [], []); // stepKey: sampleCreateForAfter } /** @@ -55,21 +34,8 @@ class HookActionsTestCest */ public function _after(AcceptanceTester $I) { - $I->comment("[sampleCreateAfter] create 'sampleCreatedEntity' entity"); - $I->createEntity( - "sampleCreateAfter", - "hook", - "sampleCreatedEntity", - [], - [] - ); - - $I->comment("[sampleDeleteAfter] delete entity 'sampleCreateForAfter'"); - $I->deleteEntity( - "sampleCreateForAfter", - "hook" - ); - + $I->createEntity("sampleCreateAfter", "hook", "sampleCreatedEntity", [], []); // stepKey: sampleCreateAfter + $I->deleteEntity("sampleCreateForAfter", "hook"); // stepKey: sampleDeleteAfter } /** diff --git a/dev/tests/verification/Resources/LocatorFunctionTest.txt b/dev/tests/verification/Resources/LocatorFunctionTest.txt index 67f92543f..f00392778 100644 --- a/dev/tests/verification/Resources/LocatorFunctionTest.txt +++ b/dev/tests/verification/Resources/LocatorFunctionTest.txt @@ -26,15 +26,7 @@ class LocatorFunctionTestCest */ public function LocatorFunctionTest(AcceptanceTester $I) { - $I->comment("[data] create 'ReplacementPerson' entity"); - $I->createEntity( - "data", - "test", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("data", "test", "ReplacementPerson", [], []); // stepKey: data $I->click(Locator::contains("'label'", "'Name'")); // stepKey: SimpleLocator $I->click(Locator::contains("'label'", "'Name'")); // stepKey: SimpleLocatorNonShorthand $I->click(Locator::find("'img'", ['title' => 'diagram'])); // stepKey: ArrayLocator diff --git a/dev/tests/verification/Resources/MergedActionGroupTest.txt b/dev/tests/verification/Resources/MergedActionGroupTest.txt index b2a4d4cd3..e0067b479 100644 --- a/dev/tests/verification/Resources/MergedActionGroupTest.txt +++ b/dev/tests/verification/Resources/MergedActionGroupTest.txt @@ -24,15 +24,7 @@ class MergedActionGroupTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup diff --git a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt index bd40b3fa6..8e5ea542e 100644 --- a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt +++ b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt @@ -24,15 +24,7 @@ class MultipleActionGroupsTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createPersonParam] create 'ReplacementPerson' entity"); - $I->createEntity( - "createPersonParam", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createPersonParam", "hook", "ReplacementPerson", [], []); // stepKey: createPersonParam $I->comment("Entering Action Group [beforeGroup] FunctionalActionGroup"); $I->fillField("#foo", "myData1"); // stepKey: fillField1BeforeGroup $I->fillField("#bar", "myData2"); // stepKey: fillField2BeforeGroup diff --git a/dev/tests/verification/Resources/PageReplacementTest.txt b/dev/tests/verification/Resources/PageReplacementTest.txt index 6cfcce367..f90a4fda7 100644 --- a/dev/tests/verification/Resources/PageReplacementTest.txt +++ b/dev/tests/verification/Resources/PageReplacementTest.txt @@ -26,15 +26,7 @@ class PageReplacementTestCest */ public function PageReplacementTest(AcceptanceTester $I) { - $I->comment("[datakey] create 'simpleData' entity"); - $I->createEntity( - "datakey", - "test", - "simpleData", - [], - [] - ); - + $I->createEntity("datakey", "test", "simpleData", [], []); // stepKey: datakey $I->amOnPage("/page.html"); // stepKey: noParamPage $I->amOnPage("/StringLiteral/page.html"); // stepKey: oneParamPageString $I->amOnPage("/John/page.html"); // stepKey: oneParamPageData diff --git a/dev/tests/verification/Resources/ParameterArrayTest.txt b/dev/tests/verification/Resources/ParameterArrayTest.txt index f66ce9c47..af47657ea 100644 --- a/dev/tests/verification/Resources/ParameterArrayTest.txt +++ b/dev/tests/verification/Resources/ParameterArrayTest.txt @@ -26,15 +26,7 @@ class ParameterArrayTestCest */ public function ParameterArrayTest(AcceptanceTester $I) { - $I->comment("[simpleDataKey] create 'simpleParamData' entity"); - $I->createEntity( - "simpleDataKey", - "test", - "simpleParamData", - [], - [] - ); - + $I->createEntity("simpleDataKey", "test", "simpleParamData", [], []); // stepKey: simpleDataKey $I->searchAndMultiSelectOption("#selector", ["name"]); // stepKey: xmlSimpleReplace $I->searchAndMultiSelectOption("#selector", [msq("simpleParamData") . "prename"]); // stepKey: xmlPrefix $I->searchAndMultiSelectOption("#selector", ["postname" . msq("simpleParamData")]); // stepKey: xmlSuffix diff --git a/dev/tests/verification/Resources/PersistedReplacementTest.txt b/dev/tests/verification/Resources/PersistedReplacementTest.txt index 5d8a0f1e5..009a8eac2 100644 --- a/dev/tests/verification/Resources/PersistedReplacementTest.txt +++ b/dev/tests/verification/Resources/PersistedReplacementTest.txt @@ -23,15 +23,7 @@ class PersistedReplacementTestCest */ public function _before(AcceptanceTester $I) { - $I->comment("[createData1] create 'ReplacementPerson' entity"); - $I->createEntity( - "createData1", - "hook", - "ReplacementPerson", - [], - [] - ); - + $I->createEntity("createData1", "hook", "ReplacementPerson", [], []); // stepKey: createData1 } /** @@ -43,15 +35,7 @@ class PersistedReplacementTestCest */ public function PersistedReplacementTest(AcceptanceTester $I) { - $I->comment("[createdData] create 'simpleData' entity"); - $I->createEntity( - "createdData", - "test", - "simpleData", - [], - [] - ); - + $I->createEntity("createdData", "test", "simpleData", [], []); // stepKey: createdData $I->fillField("#selector", "StringBefore " . $I->retrieveEntityField('createdData', 'firstname', 'test') . " StringAfter"); // stepKey: inputReplace $I->fillField("#" . $I->retrieveEntityField('createdData', 'firstname', 'test'), "input"); // stepKey: selectorReplace $I->fillField("#" . getenv("MAGENTO_BASE_URL") . "#" . $I->retrieveEntityField('createdData', 'firstname', 'test'), "input"); // stepKey: selectorReplace2 diff --git a/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt b/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt index 2a3444324..118db353a 100644 --- a/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt +++ b/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt @@ -24,38 +24,10 @@ class PersistenceActionGroupAppendingTestCest public function _before(AcceptanceTester $I) { $I->comment("Entering Action Group [ACTIONGROUPBEFORE] DataPersistenceAppendingActionGroup"); - $I->comment("[createDataACTIONGROUPBEFORE] create 'entity' entity"); - $I->createEntity( - "createDataACTIONGROUPBEFORE", - "hook", - "entity", - [], - [] - ); - - $I->comment("[updateDataACTIONGROUPBEFORE] update 'createDataACTIONGROUPBEFORE' entity to 'newEntity'"); - $I->updateEntity( - "createDataACTIONGROUPBEFORE", - "hook", - "newEntity", - [] - ); - - $I->comment("[deleteDataACTIONGROUPBEFORE] delete entity 'createDataACTIONGROUPBEFORE'"); - $I->deleteEntity( - "createDataACTIONGROUPBEFORE", - "hook" - ); - - $I->comment("[getDataACTIONGROUPBEFORE] get 'someEneity' entity"); - $I->getEntity( - "getDataACTIONGROUPBEFORE", - "hook", - "someEneity", - [], - null - ); - + $I->createEntity("createDataACTIONGROUPBEFORE", "hook", "entity", [], []); // stepKey: createDataACTIONGROUPBEFORE + $I->updateEntity("createDataACTIONGROUPBEFORE", "hook", "newEntity",[]); // stepKey: updateDataACTIONGROUPBEFORE + $I->deleteEntity("createDataACTIONGROUPBEFORE", "hook"); // stepKey: deleteDataACTIONGROUPBEFORE + $I->getEntity("getDataACTIONGROUPBEFORE", "hook", "someEneity", [], null); // stepKey: getDataACTIONGROUPBEFORE $I->comment($I->retrieveEntityField('createData', 'field', 'hook')); $I->comment("Exiting Action Group [ACTIONGROUPBEFORE] DataPersistenceAppendingActionGroup"); } @@ -70,38 +42,10 @@ class PersistenceActionGroupAppendingTestCest public function PersistenceActionGroupAppendingTest(AcceptanceTester $I) { $I->comment("Entering Action Group [ACTIONGROUP] DataPersistenceAppendingActionGroup"); - $I->comment("[createDataACTIONGROUP] create 'entity' entity"); - $I->createEntity( - "createDataACTIONGROUP", - "test", - "entity", - [], - [] - ); - - $I->comment("[updateDataACTIONGROUP] update 'createDataACTIONGROUP' entity to 'newEntity'"); - $I->updateEntity( - "createDataACTIONGROUP", - "test", - "newEntity", - [] - ); - - $I->comment("[deleteDataACTIONGROUP] delete entity 'createDataACTIONGROUP'"); - $I->deleteEntity( - "createDataACTIONGROUP", - "test" - ); - - $I->comment("[getDataACTIONGROUP] get 'someEneity' entity"); - $I->getEntity( - "getDataACTIONGROUP", - "test", - "someEneity", - [], - null - ); - + $I->createEntity("createDataACTIONGROUP", "test", "entity", [], []); // stepKey: createDataACTIONGROUP + $I->updateEntity("createDataACTIONGROUP", "test", "newEntity",[]); // stepKey: updateDataACTIONGROUP + $I->deleteEntity("createDataACTIONGROUP", "test"); // stepKey: deleteDataACTIONGROUP + $I->getEntity("getDataACTIONGROUP", "test", "someEneity", [], null); // stepKey: getDataACTIONGROUP $I->comment($I->retrieveEntityField('createDataACTIONGROUP', 'field', 'test')); $I->comment("Exiting Action Group [ACTIONGROUP] DataPersistenceAppendingActionGroup"); } diff --git a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt index 517bea53a..221373be1 100644 --- a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt +++ b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt @@ -25,25 +25,9 @@ class PersistenceCustomFieldsTestCest { $createData1Fields['firstname'] = "Mac"; $createData1Fields['lastname'] = "Doe"; - $I->comment("[createData1] create 'DefaultPerson' entity"); - $I->createEntity( - "createData1", - "hook", - "DefaultPerson", - [], - $createData1Fields - ); - + $I->createEntity("createData1", "hook", "DefaultPerson", [], $createData1Fields); // stepKey: createData1 $createData2Fields['firstname'] = $I->retrieveEntityField('createData1', 'firstname', 'hook'); - $I->comment("[createData2] create 'uniqueData' entity"); - $I->createEntity( - "createData2", - "hook", - "uniqueData", - ["createData1"], - $createData2Fields - ); - + $I->createEntity("createData2", "hook", "uniqueData", ["createData1"], $createData2Fields); // stepKey: createData2 } /** @@ -57,88 +41,24 @@ class PersistenceCustomFieldsTestCest { $createdDataFields['favoriteIndex'] = "1"; $createdDataFields['middlename'] = "Kovacs"; - $I->comment("[createdData] create 'simpleData' entity"); - $I->createEntity( - "createdData", - "test", - "simpleData", - [], - $createdDataFields - ); - + $I->createEntity("createdData", "test", "simpleData", [], $createdDataFields); // stepKey: createdData $createdData3Fields['firstname'] = "Takeshi"; $createdData3Fields['lastname'] = "Kovacs"; - $I->comment("[createdData3] create 'UniquePerson' entity"); - $I->createEntity( - "createdData3", - "test", - "UniquePerson", - ["createdData"], - $createdData3Fields - ); - + $I->createEntity("createdData3", "test", "UniquePerson", ["createdData"], $createdData3Fields); // stepKey: createdData3 $I->comment("Entering Action Group [createdAG] PersistenceActionGroup"); $createDataAG1CreatedAGFields['firstname'] = "string1"; - $I->comment("[createDataAG1CreatedAG] create 'simpleData' entity"); - $I->createEntity( - "createDataAG1CreatedAG", - "test", - "simpleData", - [], - $createDataAG1CreatedAGFields - ); - + $I->createEntity("createDataAG1CreatedAG", "test", "simpleData", [], $createDataAG1CreatedAGFields); // stepKey: createDataAG1CreatedAG $createDataAG2CreatedAGFields['firstname'] = "Jane"; - $I->comment("[createDataAG2CreatedAG] create 'simpleData' entity"); - $I->createEntity( - "createDataAG2CreatedAG", - "test", - "simpleData", - [], - $createDataAG2CreatedAGFields - ); - + $I->createEntity("createDataAG2CreatedAG", "test", "simpleData", [], $createDataAG2CreatedAGFields); // stepKey: createDataAG2CreatedAG $createDataAG3CreatedAGFields['firstname'] = $I->retrieveEntityField('createdData3', 'firstname', 'test'); - $I->comment("[createDataAG3CreatedAG] create 'simpleData' entity"); - $I->createEntity( - "createDataAG3CreatedAG", - "test", - "simpleData", - [], - $createDataAG3CreatedAGFields - ); - + $I->createEntity("createDataAG3CreatedAG", "test", "simpleData", [], $createDataAG3CreatedAGFields); // stepKey: createDataAG3CreatedAG $I->comment("Exiting Action Group [createdAG] PersistenceActionGroup"); $I->comment("Entering Action Group [AGKEY] DataPersistenceSelfReferenceActionGroup"); - $I->comment("[createData1AGKEY] create 'entity1' entity"); - $I->createEntity( - "createData1AGKEY", - "test", - "entity1", - [], - [] - ); - - $I->comment("[createData2AGKEY] create 'entity2' entity"); - $I->createEntity( - "createData2AGKEY", - "test", - "entity2", - [], - [] - ); - + $I->createEntity("createData1AGKEY", "test", "entity1", [], []); // stepKey: createData1AGKEY + $I->createEntity("createData2AGKEY", "test", "entity2", [], []); // stepKey: createData2AGKEY $createData3AGKEYFields['key1'] = $I->retrieveEntityField('createData1AGKEY', 'field', 'test'); $createData3AGKEYFields['key2'] = $I->retrieveEntityField('createData2AGKEY', 'field', 'test'); - $I->comment("[createData3AGKEY] create 'entity3' entity"); - $I->createEntity( - "createData3AGKEY", - "test", - "entity3", - [], - $createData3AGKEYFields - ); - + $I->createEntity("createData3AGKEY", "test", "entity3", [], $createData3AGKEYFields); // stepKey: createData3AGKEY $I->comment("Exiting Action Group [AGKEY] DataPersistenceSelfReferenceActionGroup"); } } diff --git a/dev/tests/verification/Resources/SectionReplacementTest.txt b/dev/tests/verification/Resources/SectionReplacementTest.txt index 04efcee4b..2b2a8bcd6 100644 --- a/dev/tests/verification/Resources/SectionReplacementTest.txt +++ b/dev/tests/verification/Resources/SectionReplacementTest.txt @@ -45,15 +45,7 @@ class SectionReplacementTestCest $I->click("#Doe" . msq("uniqueData") . " .stringLiteral2"); // stepKey: selectorReplaceTwoParamDataRefMSQSuffix $I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .stringLiteral3"); // stepKey: selectorReplaceThreeParamDataRefMSQSuffix $I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .Doe" . msq("uniqueData") . " [stringLiteral3]"); // stepKey: selectorReplaceThreeParamOneDupeDataRefMSQSuffix - $I->comment("[createdData] create 'simpleData' entity"); - $I->createEntity( - "createdData", - "test", - "simpleData", - [], - [] - ); - + $I->createEntity("createdData", "test", "simpleData", [], []); // stepKey: createdData $I->click("#element ." . $I->retrieveEntityField('createdData', 'firstname', 'test')); // stepKey: selectorReplaceOneParamPersisted $I->click("#" . $I->retrieveEntityField('createdData', 'firstname', 'test') . " .stringLiteral2"); // stepKey: selectorReplaceTwoParamPersisted $I->click("#" . $I->retrieveEntityField('createdData', 'firstname', 'test') . "-stringLiteral2 .stringLiteral3"); // stepKey: selectorReplaceThreeParamPersisted diff --git a/dev/tests/verification/Resources/functionalSuiteHooks.txt b/dev/tests/verification/Resources/functionalSuiteHooks.txt index 05ada44f1..908cff8aa 100644 --- a/dev/tests/verification/Resources/functionalSuiteHooks.txt +++ b/dev/tests/verification/Resources/functionalSuiteHooks.txt @@ -122,7 +122,7 @@ class functionalSuiteHooks extends \Codeception\GroupObject // initialize the webdriver session $webDriver->_initializeSession(); $webDriver->amOnPage("some.url"); // stepKey: after - $webDriver->deleteEntityByUrl("deleteThis"); + $webDriver->deleteEntityByUrl("deleteThis"); // stepKey: delete print("Entering Action Group [AC] actionGroupWithTwoArguments"); $webDriver->see("John", msq("uniqueData") . "John"); // stepKey: seeFirstNameAC print("Exiting Action Group [AC] actionGroupWithTwoArguments"); diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index 4bce08d9f..1668f5b21 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -8,7 +8,8 @@ use Codeception\Step\Comment; use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; -use \Magento\FunctionalTestingFramework\Util\TestGenerator; +use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; +use Magento\FunctionalTestingFramework\Util\TestGenerator; use Yandex\Allure\Adapter\Model\Status; use Yandex\Allure\Adapter\Model\Step; use Yandex\Allure\Codeception\AllureCodeception; @@ -41,6 +42,20 @@ class MagentoAllureAdapter extends AllureCodeception */ private $testFiles = []; + /** + * Boolean value to indicate if steps are invisible steps + * + * @var boolean + */ + private $atInvisibleSteps = false; + + /** + * Boolean array to store status of previous invisible steps + * + * @var array + */ + private $invisibleStepStatus = []; + /** * Array of group values passed to test runner command * @@ -122,9 +137,25 @@ private function sanitizeGroupName($group) * @param StepEvent $stepEvent * @return void * @throws \Yandex\Allure\Adapter\AllureException + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function stepBefore(StepEvent $stepEvent) { + $stepAction = $stepEvent->getStep()->getAction(); + + // Set atInvisibleSteps flag and return if step is in INVISIBLE_STEP_ACTIONS + if (in_array($stepAction, ActionObject::INVISIBLE_STEP_ACTIONS)) { + $this->atInvisibleSteps = true; + return; + } + + // Set back atInvisibleSteps flag + if ($this->atInvisibleSteps && !in_array($stepAction, ActionObject::INVISIBLE_STEP_ACTIONS)) { + $this->atInvisibleSteps = false; + } + //Hard set to 200; we don't expose this config in MFTF $argumentsLength = 200; $stepKey = null; @@ -134,11 +165,9 @@ public function stepBefore(StepEvent $stepEvent) } // DO NOT alter action if actionGroup is starting, need the exact actionGroup name for good logging - if (strpos($stepEvent->getStep()->getAction(), ActionGroupObject::ACTION_GROUP_CONTEXT_START) !== false - || $stepEvent->getStep() instanceof Comment + if (strpos($stepAction, ActionGroupObject::ACTION_GROUP_CONTEXT_START) === false + && !($stepEvent->getStep() instanceof Comment) ) { - $stepAction = $stepEvent->getStep()->getAction(); - } else { $stepAction = $stepEvent->getStep()->getHumanizedActionWithoutArguments(); } $stepArgs = $stepEvent->getStep()->getArgumentsAsString($argumentsLength); @@ -169,8 +198,26 @@ public function stepBefore(StepEvent $stepEvent) */ public function stepAfter(StepEvent $stepEvent = null) { - if ($stepEvent->getStep()->hasFailed()) { - $this->getLifecycle()->fire(new StepFailedEvent()); + // Store invisible step status if step is in INVISIBLE_STEP_ACTIONS + if ($this->atInvisibleSteps && $stepEvent->getStep()->hasFailed()) { + $this->invisibleStepStatus[] = false; + return; + } elseif ($this->atInvisibleSteps) { + $this->invisibleStepStatus[] = true; + return; + } else { + // Check previous invisible steps status + $invisibleStepsPassed = true; + foreach ($this->invisibleStepStatus as $pass) { + if (!$pass) { + $invisibleStepsPassed = false; + break; + } + } + $this->invisibleStepStatus = []; + if ($stepEvent->getStep()->hasFailed() || !$invisibleStepsPassed) { + $this->getLifecycle()->fire(new StepFailedEvent()); + } } $this->getLifecycle()->fire(new StepFinishedEvent()); } diff --git a/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php b/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php index 0ba1a3b2f..b9e3f4ca1 100644 --- a/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php +++ b/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php @@ -12,6 +12,7 @@ use Codeception\Step\Comment; use Codeception\Test\Interfaces\ScenarioDriven; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; +use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; use Magento\FunctionalTestingFramework\Util\TestGenerator; use Symfony\Component\Console\Formatter\OutputFormatter; @@ -31,6 +32,20 @@ class Console extends \Codeception\Subscriber\Console */ private $actionGroupStepKey = null; + /** + * Boolean value to indicate if steps are invisible steps + * + * @var boolean + */ + private $atInvisibleSteps = false; + + /** + * Boolean array to store status of previous invisible steps + * + * @var array + */ + private $invisibleStepStatus = []; + /** * Console constructor. Parent constructor requires codeception CLI options, and does not have its own configs. * Constructor is only different than parent due to the way Codeception instantiates Extensions. @@ -50,6 +65,8 @@ public function __construct($extensionOptions = [], $options = []) * * @param StepEvent $e * @return void + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function beforeStep(StepEvent $e) { @@ -57,6 +74,19 @@ public function beforeStep(StepEvent $e) return; } + $stepAction = $e->getStep()->getAction(); + + // Set atInvisibleSteps flag and return if step is in INVISIBLE_STEP_ACTIONS + if (in_array($stepAction, ActionObject::INVISIBLE_STEP_ACTIONS)) { + $this->atInvisibleSteps = true; + return; + } + + // Set back atInvisibleSteps flag + if ($this->atInvisibleSteps && !in_array($stepAction, ActionObject::INVISIBLE_STEP_ACTIONS)) { + $this->atInvisibleSteps = false; + } + $metaStep = $e->getStep()->getMetaStep(); if ($metaStep and $this->metaStep != $metaStep) { $this->message(' ' . $metaStep->getPrefix()) @@ -77,9 +107,27 @@ public function beforeStep(StepEvent $e) */ public function afterStep(StepEvent $e) { - parent::afterStep($e); - if ($e->getStep()->hasFailed()) { - $this->actionGroupStepKey = null; + // Store invisible step status if step is in INVISIBLE_STEP_ACTIONS + if ($this->atInvisibleSteps && $e->getStep()->hasFailed()) { + $this->invisibleStepStatus[] = false; + return; + } elseif ($this->atInvisibleSteps) { + $this->invisibleStepStatus[] = true; + return; + } else { + // Check previous invisible steps status + $invisibleStepsPassed = true; + foreach ($this->invisibleStepStatus as $pass) { + if (!$pass) { + $invisibleStepsPassed = false; + break; + } + } + $this->invisibleStepStatus = []; + parent::afterStep($e); + if ($e->getStep()->hasFailed() || !$invisibleStepsPassed) { + $this->actionGroupStepKey = null; + } } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index c188008e7..53743330e 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -75,6 +75,7 @@ class ActionObject const DEFAULT_COMMAND_WAIT_TIMEOUT = 60; const ACTION_ATTRIBUTE_USERINPUT = 'userInput'; const ACTION_TYPE_COMMENT = 'comment'; + const INVISIBLE_STEP_ACTIONS = ['retrieveEntityField', 'getSecret']; /** * The unique identifier for the action diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 7c8c59dbe..dc6aa9238 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -47,10 +47,8 @@ class TestGenerator const PERSISTED_OBJECT_NOTATION_REGEX = '/\${1,2}[\w.\[\]]+\${1,2}/'; const NO_STEPKEY_ACTIONS = [ 'comment', - 'createData', - 'deleteData', - 'updateData', - 'getData', + 'retrieveEntityField', + 'getSecret', 'magentoCLI', 'generateDate', 'field' @@ -732,13 +730,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato switch ($actionObject->getType()) { case "createData": $entity = $customActionAttributes['entity']; - //Add an informative statement to help the user debug test runs - $testSteps .= sprintf( - "\t\t$%s->comment(\"[%s] create '%s' entity\");\n", - $actor, - $stepKey, - $entity - ); //TODO refactor entity field override to not be individual actionObjects $customEntityFields = @@ -766,19 +757,19 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato } $createEntityFunctionCall = "\t\t\${$actor}->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}]"; + $createEntityFunctionCall .= "\"{$stepKey}\","; + $createEntityFunctionCall .= " \"{$scope}\","; + $createEntityFunctionCall .= " \"{$entity}\","; + $createEntityFunctionCall .= " [{$requiredEntityKeysArray}],"; if (count($customEntityFields) > 1) { - $createEntityFunctionCall .= ",\n\t\t\t\${$stepKey}Fields"; + $createEntityFunctionCall .= " \${$stepKey}Fields"; } else { - $createEntityFunctionCall .= ",\n\t\t\t[]"; + $createEntityFunctionCall .= " []"; } if ($storeCode !== null) { - $createEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; + $createEntityFunctionCall .= ", \"{$storeCode}\""; } - $createEntityFunctionCall .= "\n\t\t);\n"; + $createEntityFunctionCall .= ");"; $testSteps .= $createEntityFunctionCall; break; case "deleteData": @@ -790,13 +781,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato ); $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null; $key .= $actionGroup; - //Add an informative statement to help the user debug test runs - $contextSetter = sprintf( - "\t\t$%s->comment(\"[%s] delete entity '%s'\");\n", - $actor, - $stepKey, - $key - ); //Determine Scope $scope = PersistedObjectHandler::TEST_SCOPE; @@ -807,17 +791,16 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato } $deleteEntityFunctionCall = "\t\t\${$actor}->deleteEntity("; - $deleteEntityFunctionCall .= "\n\t\t\t\"{$key}\","; - $deleteEntityFunctionCall .= "\n\t\t\t\"{$scope}\""; - $deleteEntityFunctionCall .= "\n\t\t);\n"; + $deleteEntityFunctionCall .= "\"{$key}\","; + $deleteEntityFunctionCall .= " \"{$scope}\""; + $deleteEntityFunctionCall .= ");"; - $testSteps .= $contextSetter; $testSteps .= $deleteEntityFunctionCall; } else { $url = $this->resolveAllRuntimeReferences([$url])[0]; $url = $this->resolveTestVariable([$url], null)[0]; $output = sprintf( - "\t\t$%s->deleteEntityByUrl(%s);\n", + "\t\t$%s->deleteEntityByUrl(%s);", $actor, $url ); @@ -834,15 +817,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null; $key .= $actionGroup; - //Add an informative statement to help the user debug test runs - $testSteps .= sprintf( - "\t\t$%s->comment(\"[%s] update '%s' entity to '%s'\");\n", - $actor, - $stepKey, - $key, - $updateEntity - ); - // Build array of requiredEntities $requiredEntityKeys = []; foreach ($actionObject->getCustomActionAttributes() as $actionAttribute) { @@ -865,14 +839,14 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato } $updateEntityFunctionCall = "\t\t\${$actor}->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}]"; + $updateEntityFunctionCall .= "\"{$key}\","; + $updateEntityFunctionCall .= " \"{$scope}\","; + $updateEntityFunctionCall .= " \"{$updateEntity}\","; + $updateEntityFunctionCall .= "[{$requiredEntityKeysArray}]"; if ($storeCode !== null) { - $updateEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; + $updateEntityFunctionCall .= ", \"{$storeCode}\""; } - $updateEntityFunctionCall .= "\n\t\t);\n"; + $updateEntityFunctionCall .= ");"; $testSteps .= $updateEntityFunctionCall; break; @@ -882,13 +856,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato if (isset($customActionAttributes['index'])) { $index = (int)$customActionAttributes['index']; } - //Add an informative statement to help the user debug test runs - $testSteps .= sprintf( - "\t\t$%s->comment(\"[%s] get '%s' entity\");\n", - $actor, - $stepKey, - $entity - ); // Build array of requiredEntities $requiredEntityKeys = []; @@ -913,19 +880,19 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato //Create Function $getEntityFunctionCall = "\t\t\${$actor}->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}]"; + $getEntityFunctionCall .= "\"{$stepKey}\","; + $getEntityFunctionCall .= " \"{$scope}\","; + $getEntityFunctionCall .= " \"{$entity}\","; + $getEntityFunctionCall .= " [{$requiredEntityKeysArray}],"; if ($storeCode !== null) { - $getEntityFunctionCall .= ",\n\t\t\t\"{$storeCode}\""; + $getEntityFunctionCall .= " \"{$storeCode}\""; } else { - $getEntityFunctionCall .= ",\n\t\t\tnull"; + $getEntityFunctionCall .= " null"; } if ($index !== null) { - $getEntityFunctionCall .= ",\n\t\t\t{$index}"; + $getEntityFunctionCall .= ", {$index}"; } - $getEntityFunctionCall .= "\n\t\t);\n"; + $getEntityFunctionCall .= ");"; $testSteps .= $getEntityFunctionCall; break; From 01f0847a0a67d8b7be1bcb0c97d30c8ad4f290e5 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 4 Dec 2019 15:30:53 -0600 Subject: [PATCH 05/67] MQE-1379: Fix MFTF custom actions to fully support Codeception dry-run functionality --- .../Module/MagentoActionProxies.php | 121 +----------------- .../Module/MagentoWebDriver.php | 12 +- 2 files changed, 7 insertions(+), 126 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php b/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php index 18c800e48..5a3b2360b 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoActionProxies.php @@ -20,124 +20,5 @@ */ class MagentoActionProxies extends CodeceptionModule { - /** - * Create an entity - * TODO: un-comment this function after MQE-1904 - * - * @param string $key StepKey of the createData action. - * @param string $scope - * @param string $entity Name of xml entity to create. - * @param array $dependentObjectKeys StepKeys of other createData actions that are required. - * @param array $overrideFields Array of FieldName => Value of override fields. - * @param string $storeCode - * @return void - */ - /* - public function createEntity( - $key, - $scope, - $entity, - $dependentObjectKeys = [], - $overrideFields = [], - $storeCode = '' - ) { - PersistedObjectHandler::getInstance()->createEntity( - $key, - $scope, - $entity, - $dependentObjectKeys, - $overrideFields, - $storeCode - ); - } - */ - /** - * Retrieves and updates a previously created entity - * TODO: un-comment this function after MQE-1904 - * - * @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 = []) - { - PersistedObjectHandler::getInstance()->updateEntity( - $key, - $scope, - $updateEntity, - $dependentObjectKeys - ); - } - */ - /** - * Performs GET on given entity and stores entity for use - * TODO: un-comment this function after MQE-1904 - * - * @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) - { - PersistedObjectHandler::getInstance()->getEntity( - $key, - $scope, - $entity, - $dependentObjectKeys, - $storeCode, - $index - ); - } - */ - /** - * Retrieves and deletes a previously created entity - * TODO: un-comment this function after MQE-1904 - * - * @param string $key StepKey of the createData action. - * @param string $scope - * @return void - */ - /* - public function deleteEntity($key, $scope) - { - PersistedObjectHandler::getInstance()->deleteEntity($key, $scope); - } - */ - /** - * Retrieves a field from an entity, according to key and scope given - * TODO: un-comment this function after MQE-1904 - * - * @param string $stepKey - * @param string $field - * @param string $scope - * @return string - */ - /* - public function retrieveEntityField($stepKey, $field, $scope) - { - return PersistedObjectHandler::getInstance()->retrieveEntityField($stepKey, $field, $scope); - } - */ - /** - * Get encrypted value by key - * TODO: un-comment this function after MQE-1904 - * - * @param string $key - * @return string|null - * @throws TestFrameworkException - */ - /* - public function getSecret($key) - { - return CredentialStore::getInstance()->getSecret($key); - } - */ + // TODO: placeholder for proxy functions currently in MagentoWebDriver (MQE-1904) } diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 4cb980d9c..a7407f356 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -909,7 +909,7 @@ private function curlExecMagentoCLI($command, $timeout, $arguments): string /** * Create an entity - * TODO: remove this function after MQE-1904 + * TODO: move this function to MagentoActionProxies after MQE-1904 * * @param string $key StepKey of the createData action. * @param string $scope @@ -939,7 +939,7 @@ public function createEntity( /** * Retrieves and updates a previously created entity - * TODO: remove this function after MQE-1904 + * TODO: move this function to MagentoActionProxies after MQE-1904 * * @param string $key StepKey of the createData action. * @param string $scope @@ -959,7 +959,7 @@ public function updateEntity($key, $scope, $updateEntity, $dependentObjectKeys = /** * Performs GET on given entity and stores entity for use - * TODO: remove this function after MQE-1904 + * TODO: move this function to MagentoActionProxies after MQE-1904 * * @param string $key StepKey of getData action. * @param string $scope @@ -983,7 +983,7 @@ public function getEntity($key, $scope, $entity, $dependentObjectKeys = [], $sto /** * Retrieves and deletes a previously created entity - * TODO: remove this function after MQE-1904 + * TODO: move this function to MagentoActionProxies after MQE-1904 * * @param string $key StepKey of the createData action. * @param string $scope @@ -996,7 +996,7 @@ public function deleteEntity($key, $scope) /** * Retrieves a field from an entity, according to key and scope given - * TODO: remove this function after MQE-1904 + * TODO: move this function to MagentoActionProxies after MQE-1904 * * @param string $stepKey * @param string $field @@ -1010,7 +1010,7 @@ public function retrieveEntityField($stepKey, $field, $scope) /** * Get encrypted value by key - * TODO: remove this function after MQE-1904 + * TODO: move this function to MagentoActionProxies after MQE-1904 * * @param string $key * @return string|null From 5fd746c9ff1d623774ad8517eec7b8c2dd65b8d1 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Thu, 5 Dec 2019 09:48:27 -0600 Subject: [PATCH 06/67] MQE-1379: Fix MFTF custom actions to fully support Codeception dry-run functionality --- .../Allure/Adapter/MagentoAllureAdapter.php | 39 +++++-------------- .../Codeception/Subscriber/Console.php | 36 ++++------------- 2 files changed, 17 insertions(+), 58 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index 1668f5b21..e9e1c344c 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -49,13 +49,6 @@ class MagentoAllureAdapter extends AllureCodeception */ private $atInvisibleSteps = false; - /** - * Boolean array to store status of previous invisible steps - * - * @var array - */ - private $invisibleStepStatus = []; - /** * Array of group values passed to test runner command * @@ -137,9 +130,6 @@ private function sanitizeGroupName($group) * @param StepEvent $stepEvent * @return void * @throws \Yandex\Allure\Adapter\AllureException - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) */ public function stepBefore(StepEvent $stepEvent) { @@ -198,27 +188,18 @@ public function stepBefore(StepEvent $stepEvent) */ public function stepAfter(StepEvent $stepEvent = null) { - // Store invisible step status if step is in INVISIBLE_STEP_ACTIONS - if ($this->atInvisibleSteps && $stepEvent->getStep()->hasFailed()) { - $this->invisibleStepStatus[] = false; - return; - } elseif ($this->atInvisibleSteps) { - $this->invisibleStepStatus[] = true; - return; - } else { - // Check previous invisible steps status - $invisibleStepsPassed = true; - foreach ($this->invisibleStepStatus as $pass) { - if (!$pass) { - $invisibleStepsPassed = false; - break; - } - } - $this->invisibleStepStatus = []; - if ($stepEvent->getStep()->hasFailed() || !$invisibleStepsPassed) { - $this->getLifecycle()->fire(new StepFailedEvent()); + // Simply return if step is INVISIBLE_STEP_ACTIONS + if ($this->atInvisibleSteps) { + if ($stepEvent->getStep()->hasFailed()) { + $this->atInvisibleSteps = false; } + return; } + + if ($stepEvent->getStep()->hasFailed()) { + $this->getLifecycle()->fire(new StepFailedEvent()); + } + $this->getLifecycle()->fire(new StepFinishedEvent()); } diff --git a/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php b/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php index b9e3f4ca1..8c50f0670 100644 --- a/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php +++ b/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php @@ -39,13 +39,6 @@ class Console extends \Codeception\Subscriber\Console */ private $atInvisibleSteps = false; - /** - * Boolean array to store status of previous invisible steps - * - * @var array - */ - private $invisibleStepStatus = []; - /** * Console constructor. Parent constructor requires codeception CLI options, and does not have its own configs. * Constructor is only different than parent due to the way Codeception instantiates Extensions. @@ -65,8 +58,6 @@ public function __construct($extensionOptions = [], $options = []) * * @param StepEvent $e * @return void - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function beforeStep(StepEvent $e) { @@ -107,27 +98,14 @@ public function beforeStep(StepEvent $e) */ public function afterStep(StepEvent $e) { - // Store invisible step status if step is in INVISIBLE_STEP_ACTIONS - if ($this->atInvisibleSteps && $e->getStep()->hasFailed()) { - $this->invisibleStepStatus[] = false; - return; - } elseif ($this->atInvisibleSteps) { - $this->invisibleStepStatus[] = true; - return; - } else { - // Check previous invisible steps status - $invisibleStepsPassed = true; - foreach ($this->invisibleStepStatus as $pass) { - if (!$pass) { - $invisibleStepsPassed = false; - break; - } - } - $this->invisibleStepStatus = []; + // Do usual after step if step is not INVISIBLE_STEP_ACTIONS + if (!$this->atInvisibleSteps) { parent::afterStep($e); - if ($e->getStep()->hasFailed() || !$invisibleStepsPassed) { - $this->actionGroupStepKey = null; - } + } + + if ($e->getStep()->hasFailed()) { + $this->actionGroupStepKey = null; + $this->atInvisibleSteps = false; } } From 34956406e94cb244f6aa5c6ad37badba55aeb67d Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 19 Dec 2019 09:51:06 -0600 Subject: [PATCH 07/67] MQE-1911: --allow-skipped removing test hooks - Fixed conditional - Modified existing conditional to follow same pattern --- .../Util/TestGenerator.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index dc6aa9238..09c353029 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -242,7 +242,7 @@ public function assembleTestPhp($testObject) $className = $testObject->getCodeceptionName(); try { - if (!$testObject->isSkipped() && !MftfApplicationConfig::getConfig()->allowSkipped()) { + if (!$testObject->isSkipped() || MftfApplicationConfig::getConfig()->allowSkipped()) { $hookPhp = $this->generateHooksPhp($testObject->getHooks()); } else { $hookPhp = null; @@ -1601,7 +1601,13 @@ private function generateTestPhp($test) $testName = str_replace(' ', '', $testName); $testAnnotations = $this->generateAnnotationsPhp($test->getAnnotations(), true); $dependencies = 'AcceptanceTester $I'; - if ($test->isSkipped() && !MftfApplicationConfig::getConfig()->allowSkipped()) { + if (!$test->isSkipped() || MftfApplicationConfig::getConfig()->allowSkipped()) { + try { + $steps = $this->generateStepsPhp($test->getOrderedActions()); + } catch (\Exception $e) { + throw new TestReferenceException($e->getMessage() . " in Test \"" . $test->getName() . "\""); + } + } else { $skipString = "This test is skipped due to the following issues:\\n"; $issues = $test->getAnnotations()['skip'] ?? null; if (isset($issues)) { @@ -1611,12 +1617,6 @@ private function generateTestPhp($test) } $steps = "\t\t" . '$scenario->skip("' . $skipString . '");' . "\n"; $dependencies .= ', \Codeception\Scenario $scenario'; - } else { - try { - $steps = $this->generateStepsPhp($test->getOrderedActions()); - } catch (\Exception $e) { - throw new TestReferenceException($e->getMessage() . " in Test \"" . $test->getName() . "\""); - } } $testPhp .= $testAnnotations; From 04ef38e2390ec07a4414ed86056433cb363104f7 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 19 Dec 2019 12:28:49 -0600 Subject: [PATCH 08/67] MQE-1911: --allow-skipped removing test hooks - Unit test --- .../FunctionalTestFramework/Util/TestGeneratorTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php index cadc1c6a8..f25153513 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php @@ -9,6 +9,7 @@ use AspectMock\Test as AspectMock; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; +use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject; use Magento\FunctionalTestingFramework\Test\Objects\TestObject; use Magento\FunctionalTestingFramework\Util\MagentoTestCase; use Magento\FunctionalTestingFramework\Util\TestGenerator; @@ -76,14 +77,20 @@ public function testAllowSkipped() $actionObject = new ActionObject('fakeAction', 'comment', [ 'userInput' => $actionInput ]); + $beforeActionInput = 'beforeInput'; + $beforeActionObject = new ActionObject('beforeAction', 'comment', [ + 'userInput' => $beforeActionInput + ]); $annotations = ['skip' => ['issue']]; - $testObject = new TestObject("sampleTest", ["merge123" => $actionObject], $annotations, [], "filename"); + $beforeHook = new TestHookObject("before", "sampleTest", ['beforeAction' => $beforeActionObject]); + $testObject = new TestObject("sampleTest", ["fakeAction" => $actionObject], $annotations, ["before" => $beforeHook], "filename"); $testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]); $output = $testGeneratorObject->assembleTestPhp($testObject); $this->assertNotContains('This test is skipped', $output); $this->assertContains($actionInput, $output); + $this->assertContains($beforeActionInput, $output); } } From 60a07a3113cb3b4e73f2f8ee81f2416075b4f87b Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 19 Dec 2019 12:40:06 -0600 Subject: [PATCH 09/67] MQE-1911: --allow-skipped removing test hooks - static check fix --- .../FunctionalTestFramework/Util/TestGeneratorTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php index f25153513..8f8eee749 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php @@ -84,7 +84,13 @@ public function testAllowSkipped() $annotations = ['skip' => ['issue']]; $beforeHook = new TestHookObject("before", "sampleTest", ['beforeAction' => $beforeActionObject]); - $testObject = new TestObject("sampleTest", ["fakeAction" => $actionObject], $annotations, ["before" => $beforeHook], "filename"); + $testObject = new TestObject( + "sampleTest", + ["fakeAction" => $actionObject], + $annotations, + ["before" => $beforeHook], + "filename" + ); $testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]); $output = $testGeneratorObject->assembleTestPhp($testObject); From 7926707b995929fa4bf03ba5c83aa112fd8bb086 Mon Sep 17 00:00:00 2001 From: Donald Booth Date: Thu, 2 Jan 2020 10:15:43 -0600 Subject: [PATCH 10/67] Fixes broken links --- docs/tips-tricks.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tips-tricks.md b/docs/tips-tricks.md index 4f7539c6d..a2300c3bf 100644 --- a/docs/tips-tricks.md +++ b/docs/tips-tricks.md @@ -419,5 +419,5 @@ BAD: -[This test]: https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Captcha/Test/Mftf/Test/StorefrontCaptchaRegisterNewCustomerTest.xml#L24 -[Data file]: https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Captcha/Test/Mftf/Data/CaptchaConfigData.xml +[This test]: https://github.com/magento/magento2/blob/2.3/app/code/Magento/Captcha/Test/Mftf/Test/StorefrontCaptchaRegisterNewCustomerTest.xml#L24 +[Data file]: https://github.com/magento/magento2/blob/2.3/app/code/Magento/Captcha/Test/Mftf/Data/CaptchaConfigData.xml From 16d26ae6899b39d88a5a59e77dbad5413b4f0b91 Mon Sep 17 00:00:00 2001 From: Donald Booth Date: Thu, 2 Jan 2020 10:33:05 -0600 Subject: [PATCH 11/67] Removing stray file --- docs/mftf-tests.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/mftf-tests.md b/docs/mftf-tests.md index d1bd1ce83..b9d94baa9 100644 --- a/docs/mftf-tests.md +++ b/docs/mftf-tests.md @@ -13,11 +13,11 @@ dl dt{ The Magento Functional Testing Framework runs tests on every Module within Magento. These files are stored within each Module folder in the Magento repo. This page lists all those tests so that developers can have a good sense of what is covered. -{% include mftf/functional_data.md %} +{% include mftf/mftf_data.md %} {% for item in mftf %} -### {{ item.name }} +### {{ item.name }} {% for file in item.items %} #### [{{ file.filename }}]({{file.repo}}) {: .mftf-test-link} From 4e1ea0af8166fb3e40a4a0e2480183cb49137fb9 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 3 Jan 2020 13:37:59 -0600 Subject: [PATCH 12/67] MQE-1513: createData throws a useless error message during runtime when the entity does not exist --- .../Util/TestGeneratorTest.php | 26 +++++++++++++++++++ .../Util/TestGenerator.php | 7 +++++ 2 files changed, 33 insertions(+) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php index 8f8eee749..e86a924c9 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php @@ -14,6 +14,7 @@ use Magento\FunctionalTestingFramework\Util\MagentoTestCase; use Magento\FunctionalTestingFramework\Util\TestGenerator; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; +use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; class TestGeneratorTest extends MagentoTestCase { @@ -41,11 +42,36 @@ public function testEntityException() $testGeneratorObject->createAllTestFiles(null, []); } + /** + * Test to check exceptions for createData on referencing non-existent entity + * + * @throws TestReferenceException + */ + + public function testCreateDataException() + { + $actionObject = new ActionObject('fakeAction', 'createData', [ + 'entity' => 'invalidEntity' + ]); + + $testObject = new TestObject("sampleTest", ["merge123" => $actionObject], [], [], "filename"); + + $testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]); + + AspectMock::double(TestGenerator::class, ['loadAllTestObjects' => ["sampleTest" => $testObject]]); + + $this->expectExceptionMessage("Entity \"invalidEntity\" does not exist." . + "\nException occurred parsing action at StepKey \"fakeAction\" in Test \"sampleTest\""); + + $testGeneratorObject->createAllTestFiles(null, []); + } + /** * Tests that skipped tests do not have a fully generated body * * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException */ + public function testSkippedNoGeneration() { $actionInput = 'fakeInput'; diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 09c353029..762fbd346 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -731,6 +731,13 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "createData": $entity = $customActionAttributes['entity']; + if(DataObjectHandler::getInstance()->getObject($entity) === null) { + throw new TestReferenceException( + "Entity \"" . $entity . "\" does not exist." . + "\nException occurred parsing action at StepKey \"" . $stepKey . "\"" + ); + } + //TODO refactor entity field override to not be individual actionObjects $customEntityFields = $customActionAttributes[ActionObjectExtractor::ACTION_OBJECT_PERSISTENCE_FIELDS] ?? []; From 1075fd48fb90f2f4d5df673a5fbabcd1055868b9 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 3 Jan 2020 16:34:34 -0600 Subject: [PATCH 13/67] MQE-1513: createData throws a useless error message during runtime when the entity does not exist --- .../Util/TestGeneratorTest.php | 24 ------------------- .../Handlers/PersistedObjectHandler.php | 8 +++++++ .../Util/TestGenerator.php | 7 ------ 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php index e86a924c9..17da4cd20 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php @@ -42,30 +42,6 @@ public function testEntityException() $testGeneratorObject->createAllTestFiles(null, []); } - /** - * Test to check exceptions for createData on referencing non-existent entity - * - * @throws TestReferenceException - */ - - public function testCreateDataException() - { - $actionObject = new ActionObject('fakeAction', 'createData', [ - 'entity' => 'invalidEntity' - ]); - - $testObject = new TestObject("sampleTest", ["merge123" => $actionObject], [], [], "filename"); - - $testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $testObject]); - - AspectMock::double(TestGenerator::class, ['loadAllTestObjects' => ["sampleTest" => $testObject]]); - - $this->expectExceptionMessage("Entity \"invalidEntity\" does not exist." . - "\nException occurred parsing action at StepKey \"fakeAction\" in Test \"sampleTest\""); - - $testGeneratorObject->createAllTestFiles(null, []); - } - /** * Tests that skipped tests do not have a fully generated body * diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php index 2a0f11a01..7015292c0 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -97,6 +97,14 @@ public function createEntity( } $retrievedEntity = DataObjectHandler::getInstance()->getObject($entity); + + if ($retrievedEntity === null) { + throw new TestReferenceException( + "Entity \"" . $entity . "\" does not exist." . + "\nException occurred parsing action at StepKey \"" . $key . "\"" + ); + } + $persistedObject = new DataPersistenceHandler( $retrievedEntity, $retrievedDependentObjects, diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 762fbd346..09c353029 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -731,13 +731,6 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato case "createData": $entity = $customActionAttributes['entity']; - if(DataObjectHandler::getInstance()->getObject($entity) === null) { - throw new TestReferenceException( - "Entity \"" . $entity . "\" does not exist." . - "\nException occurred parsing action at StepKey \"" . $stepKey . "\"" - ); - } - //TODO refactor entity field override to not be individual actionObjects $customEntityFields = $customActionAttributes[ActionObjectExtractor::ACTION_OBJECT_PERSISTENCE_FIELDS] ?? []; From a415f0554beb308c26f5a32ced30f40a9d11664f Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 3 Jan 2020 16:39:39 -0600 Subject: [PATCH 14/67] MQE-1513: createData throws a useless error message during runtime when the entity does not exist reverted changes --- .../Magento/FunctionalTestFramework/Util/TestGeneratorTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php index 17da4cd20..8f8eee749 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Util/TestGeneratorTest.php @@ -14,7 +14,6 @@ use Magento\FunctionalTestingFramework\Util\MagentoTestCase; use Magento\FunctionalTestingFramework\Util\TestGenerator; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; -use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; class TestGeneratorTest extends MagentoTestCase { @@ -47,7 +46,6 @@ public function testEntityException() * * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException */ - public function testSkippedNoGeneration() { $actionInput = 'fakeInput'; From fbf066d23812307f072cb17420b1a9c08c271b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Mon, 6 Jan 2020 01:31:07 +0100 Subject: [PATCH 15/67] Set of changes to TestGenerator --- .../Util/TestGenerator.php | 204 ++++++++++-------- 1 file changed, 120 insertions(+), 84 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 09c353029..89120a83e 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -40,9 +40,11 @@ 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'; + const PRESSKEY_ARRAY_ANCHOR_KEY = '987654321098765432109876543210'; const PERSISTED_OBJECT_NOTATION_REGEX = '/\${1,2}[\w.\[\]]+\${1,2}/'; const NO_STEPKEY_ACTIONS = [ @@ -53,7 +55,11 @@ class TestGenerator 'generateDate', 'field' ]; + const RULE_ERROR = 'On step with stepKey "%s", only one of the attributes: "%s" can be use for action "%s"'; + const STEP_KEY_ANNOTATION = " // stepKey: %s"; + const ARRAY_WRAP_OPEN = '['; + const ARRAY_WRAP_CLOSE = ']'; /** * Actor name for AcceptanceTest @@ -105,7 +111,7 @@ class TestGenerator private $currentGenerationScope = TestGenerator::TEST_SCOPE; /** - * TestGenerator constructor. + * Private constructor for Factory * * @param string $exportDir * @param array $tests @@ -114,13 +120,11 @@ class TestGenerator */ private function __construct($exportDir, $tests, $debug = false) { - // private constructor for factory $this->exportDirName = $exportDir ?? self::DEFAULT_DIR; - $exportDir = $exportDir ?? self::DEFAULT_DIR; $this->exportDirectory = FilePathFormatter::format(TESTS_MODULE_PATH) . self::GENERATED_DIR . DIRECTORY_SEPARATOR - . $exportDir; + . $this->exportDirName; $this->tests = $tests; $this->consoleOutput = new \Symfony\Component\Console\Output\ConsoleOutput(); $this->debug = $debug; @@ -185,13 +189,13 @@ private function loadAllTestObjects($testsToIgnore) * @return void * @throws \Exception */ - private function createCestFile($testPhp, $filename) + private function createCestFile(string $testPhp, string $filename) { $exportFilePath = $this->exportDirectory . DIRECTORY_SEPARATOR . $filename . ".php"; $file = fopen($exportFilePath, 'w'); if (!$file) { - throw new \Exception("Could not open the file."); + throw new \Exception(sprintf('Could not open test file: "%s"', $exportFilePath)); } fwrite($file, $testPhp); @@ -628,9 +632,9 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato // validate the param array is in the correct format $this->validateParameterArray($customActionAttributes['parameterArray']); - $parameterArray = "["; - $parameterArray .= $this->addUniquenessToParamArray($customActionAttributes['parameterArray']); - $parameterArray .= "]"; + $parameterArray = $this->wrapParameterArray( + $this->addUniquenessToParamArray($customActionAttributes['parameterArray']) + ); } if (isset($customActionAttributes['requiredAction'])) { @@ -748,13 +752,8 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato if (!empty($requiredEntityKeys)) { $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; } - //Determine Scope - $scope = PersistedObjectHandler::TEST_SCOPE; - if ($generationScope == TestGenerator::HOOK_SCOPE) { - $scope = PersistedObjectHandler::HOOK_SCOPE; - } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { - $scope = PersistedObjectHandler::SUITE_SCOPE; - } + + $scope = $this->getObjectScope($generationScope); $createEntityFunctionCall = "\t\t\${$actor}->createEntity("; $createEntityFunctionCall .= "\"{$stepKey}\","; @@ -782,13 +781,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $actionGroup = $actionObject->getCustomActionAttributes()['actionGroup'] ?? null; $key .= $actionGroup; - //Determine Scope - $scope = PersistedObjectHandler::TEST_SCOPE; - if ($generationScope == TestGenerator::HOOK_SCOPE) { - $scope = PersistedObjectHandler::HOOK_SCOPE; - } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { - $scope = PersistedObjectHandler::SUITE_SCOPE; - } + $scope = $this->getObjectScope($generationScope); $deleteEntityFunctionCall = "\t\t\${$actor}->deleteEntity("; $deleteEntityFunctionCall .= "\"{$key}\","; @@ -831,12 +824,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; } - $scope = PersistedObjectHandler::TEST_SCOPE; - if ($generationScope == TestGenerator::HOOK_SCOPE) { - $scope = PersistedObjectHandler::HOOK_SCOPE; - } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { - $scope = PersistedObjectHandler::SUITE_SCOPE; - } + $scope = $this->getObjectScope($generationScope); $updateEntityFunctionCall = "\t\t\${$actor}->updateEntity("; $updateEntityFunctionCall .= "\"{$key}\","; @@ -870,13 +858,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $requiredEntityKeysArray = '"' . implode('", "', $requiredEntityKeys) . '"'; } - //Determine Scope - $scope = PersistedObjectHandler::TEST_SCOPE; - if ($generationScope == TestGenerator::HOOK_SCOPE) { - $scope = PersistedObjectHandler::HOOK_SCOPE; - } elseif ($generationScope == TestGenerator::SUITE_SCOPE) { - $scope = PersistedObjectHandler::SUITE_SCOPE; - } + $scope = $this->getObjectScope($generationScope); //Create Function $getEntityFunctionCall = "\t\t\${$actor}->getEntity("; @@ -1303,7 +1285,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato break; case "comment": $input = $input === null ? strtr($value, ['$' => '\$', '{' => '\{', '}' => '\}']) : $input; - // Combining userInput from native XML comment and action to fall-through 'default' case + // Combining userInput from native XML comment and action to fall-through 'default' case default: $testSteps .= $this->wrapFunctionCall( $actor, @@ -1380,9 +1362,9 @@ private function trimVariableIfNeeded($input) preg_match('/"{\$[a-z][a-zA-Z\d]+}"/', $input, $match); if (isset($match[0])) { return trim($input, '{}"'); - } else { - return $input; } + + return $input; } /** @@ -1403,7 +1385,7 @@ private function replaceMatchesIntoArg($matches, &$outputArg) $variable = $this->stripAndSplitReference($match, $delimiter); if (count($variable) != 2) { throw new \Exception( - "Invalid Persisted Entity Reference: {$match}. + "Invalid Persisted Entity Reference: {$match}. Test persisted entity references must follow {$delimiter}entityStepKey.field{$delimiter} format." ); } @@ -1480,7 +1462,7 @@ private function resolveStepKeyReferences($input, $actionGroupOrigin, $matchAll // only replace when whole word matches exactly // e.g. testVar => $testVar but not $testVar2 if (strpos($output, $stepKeyVarRef) !== false) { - $output = preg_replace('/\B\\' .$stepKeyVarRef. '\b/', $stepKeyVarRef . $testInvocationKey, $output); + $output = preg_replace('/\B\\' . $stepKeyVarRef . '\b/', $stepKeyVarRef . $testInvocationKey, $output); } if (strpos($output, $persistedVarRef) !== false) { @@ -1515,8 +1497,8 @@ private function wrapFunctionArgsWithQuotes($functionRegex, $input) foreach ($allArguments as $argument) { $argument = trim($argument); - if ($argument[0] == "[") { - $replacement = "[" . $this->addUniquenessToParamArray($argument) . "]"; + if ($argument[0] == self::ARRAY_WRAP_OPEN) { + $replacement = $this->wrapParameterArray($this->addUniquenessToParamArray($argument)); } elseif (is_numeric($argument)) { $replacement = $argument; } else { @@ -1685,8 +1667,9 @@ private function processPressKey($input) preg_match_all('/[\[][^\]]*?[\]]/', $input, $paramInput); if (!empty($paramInput)) { foreach ($paramInput[0] as $param) { - $arrayResult[self::PRESSKEY_ARRAY_ANCHOR_KEY . $count] = - '[' . trim($this->addUniquenessToParamArray($param)) . ']'; + $arrayResult[self::PRESSKEY_ARRAY_ANCHOR_KEY . $count] = $this->wrapParameterArray( + trim($this->addUniquenessToParamArray($param)) + ); $input = str_replace($param, self::PRESSKEY_ARRAY_ANCHOR_KEY . $count, $input); $count++; } @@ -1780,13 +1763,8 @@ private function stripWrappedQuotes($input) if (empty($input)) { return ''; } - if (substr($input, 0, 1) === '"') { - $input = substr($input, 1); - } - if (substr($input, -1, 1) === '"') { - $input = substr($input, 0, -1); - } - return $input; + + return trim($input, '"'); } /** @@ -1821,7 +1799,7 @@ private function wrapFunctionCall($actor, $action, ...$args) continue; } if ($args[$i] === "") { - $args[$i] = '"' . $args[$i] . '"'; + $args[$i] = '""'; } } if (!is_array($args)) { @@ -1829,7 +1807,7 @@ private function wrapFunctionCall($actor, $action, ...$args) } $args = $this->resolveAllRuntimeReferences($args); $args = $this->resolveTestVariable($args, $action->getActionOrigin()); - $output .= implode(", ", array_filter($args, function($value) { return $value !== null; })) . ");"; + $output .= implode(", ", array_filter($args, $this->filterNullCallback())) . ");"; return $output; } @@ -1853,7 +1831,7 @@ private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $actio continue; } if ($args[$i] === "") { - $args[$i] = '"' . $args[$i] . '"'; + $args[$i] = '""'; } } if (!is_array($args)) { @@ -1861,12 +1839,22 @@ private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $actio } $args = $this->resolveAllRuntimeReferences($args); $args = $this->resolveTestVariable($args, $action->getActionOrigin()); - $output .= implode(", ", array_filter($args, function($value) { return $value !== null; })) . ");"; + $output .= implode(", ", array_filter($args, $this->filterNullCallback())) . ");"; return $output; } // @codingStandardsIgnoreEnd + /** + * @return callable + */ + private function filterNullCallback() + { + return function ($value) { + return $value !== null; + }; + } + /** * Resolves {{_ENV.variable}} into getenv("variable") for test-runtime ENV referencing. * @param array $args @@ -1928,43 +1916,75 @@ private function resolveAllRuntimeReferences($args) */ private function validateParameterArray($paramArray) { - if (substr($paramArray, 0, 1) != "[" || substr($paramArray, strlen($paramArray) - 1, 1) != "]") { - throw new TestReferenceException("parameterArray must begin with `[` and end with `]"); + if (!$this->isWrappedArray($paramArray)) { + throw new TestReferenceException(sprintf( + "parameterArray must begin with `%s` and end with `%s`", + self::ARRAY_WRAP_OPEN, + self::ARRAY_WRAP_CLOSE + )); } } + /** + * @param string $paramArray + * @return boolean + */ + private function isWrappedArray(string $paramArray) + { + return 0 === strpos($paramArray, self::ARRAY_WRAP_OPEN) + && substr($paramArray, -1) === self::ARRAY_WRAP_CLOSE; + } + /** * Resolve value based on type. * - * @param string $value - * @param string $type - * @return string + * @param string|null $value + * @param string|null $type + * @return string|null * @throws TestReferenceException - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - private function resolveValueByType($value, $type) + private function resolveValueByType($value = null, $type = null) { - //TODO: Refactor to deal with PHPMD.CyclomaticComplexity, and remove @SuppressWarnings if (null === $value) { return null; } + if (null === $type) { $type = 'const'; } - if ($type == "string") { - return $this->addUniquenessFunctionCall($value); - } elseif ($type == "bool") { - return $this->toBoolean($value) ? "true" : "false"; - } elseif ($type == "int" || $type == "float") { - return $this->toNumber($value); - } elseif ($type == "array") { - $this->validateParameterArray($value); - return "[" . $this->addUniquenessToParamArray($value) . "]"; - } elseif ($type == "variable") { - return $this->addDollarSign($value); - } else { - return $value; + + switch ($type) { + case 'string': + return $this->addUniquenessFunctionCall($value); + case 'bool': + return $this->toBoolean($value) ? "true" : "false"; + case 'int': + case 'float': + return $this->toNumber($value); + case 'array': + $this->validateParameterArray($value); + return $this->wrapParameterArray($this->addUniquenessToParamArray($value)); + case 'variable': + return $this->addDollarSign($value); } + + return $value; + } + + /** + * @param string $generationScope + * @return string + */ + private function getObjectScope(string $generationScope): string + { + switch ($generationScope) { + case TestGenerator::SUITE_SCOPE: + return PersistedObjectHandler::SUITE_SCOPE; + case TestGenerator::HOOK_SCOPE: + return PersistedObjectHandler::HOOK_SCOPE; + } + + return PersistedObjectHandler::TEST_SCOPE; } /** @@ -1987,11 +2007,11 @@ private function toBoolean($inStr) private function toNumber($inStr) { $outStr = $this->stripQuotes($inStr); - if (strpos($outStr, localeconv()['decimal_point']) === false) { - return intval($outStr); - } else { + if ($this->hasDecimalPoint($outStr)) { return floatval($outStr); } + + return intval($outStr); } /** @@ -2078,9 +2098,25 @@ private function printRuleErrorToConsole($key, $tagName, $attributes) if (empty($tagName) || empty($attributes)) { return; } - $message = 'On step with stepKey "' . $key . '", only one of the attributes: "'; - $message .= implode('", "', $attributes); - $message .= '" can be use for action "' . $tagName . "\".\n"; - print $message; + + printf(self::RULE_ERROR, $key, implode('", "', $attributes), $tagName); + } + + /** + * @param string $value + * @return string + */ + private function wrapParameterArray(string $value): string + { + return sprintf('%s%s%s', self::ARRAY_WRAP_OPEN, $value, self::ARRAY_WRAP_CLOSE); + } + + /** + * @param string $outStr + * @return boolean + */ + private function hasDecimalPoint(string $outStr) + { + return strpos($outStr, localeconv()['decimal_point']) === false; } } From 43ce9fc83cd2094fc476907b14c366a2195cd5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Mon, 6 Jan 2020 15:59:49 +0100 Subject: [PATCH 16/67] Introduce magentoCron command to execute Cron Jobs taking into consideration cron required interval (60 seconds) --- etc/di.xml | 2 +- .../Module/MagentoWebDriver.php | 110 ++++++++++++++++++ .../Test/etc/Actions/customActions.xsd | 37 +++++- .../Util/TestGenerator.php | 24 +++- 4 files changed, 170 insertions(+), 3 deletions(-) diff --git a/etc/di.xml b/etc/di.xml index 3e6313bf3..e5e31cf87 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -8,7 +8,7 @@ + ]> diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index a95586b26..3baa93cea 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -53,6 +53,9 @@ class MagentoWebDriver extends WebDriver { use AttachmentSupport; + const MAGENTO_CRON_INTERVAL = 60; + const MAGENTO_CRON_COMMAND = 'cron:run'; + /** * List of known magento loading masks by selector * @@ -121,6 +124,13 @@ class MagentoWebDriver extends WebDriver */ private $jsErrors = []; + /** + * Contains last execution times for Cron + * + * @var int[] + */ + private $cronExecution = []; + /** * Sanitizes config, then initializes using parent. * @@ -552,6 +562,74 @@ public function magentoCLI($command, $timeout = null, $arguments = null) return $response; } + /** + * Executes Magento Cron keeping the interval (> 60 seconds between each run) + * + * @param string|null $cronGroups + * @param int|null $timeout + * @param string|null $arguments + */ + public function magentoCron($cronGroups = null, $timeout = null, $arguments = null) + { + $cronGroups = explode(' ', $cronGroups); + return $this->executeCronjobs($cronGroups, $timeout, $arguments); + } + + /** + * Updates last execution time for Cron + * + * @param array $cronGroups + * @return void + */ + private function notifyCronFinished(array $cronGroups = []) + { + if (empty($cronGroups)) { + $this->cronExecution['*'] = time(); + } + + foreach ($cronGroups as $group) { + $this->cronExecution[$group] = time(); + } + } + + /** + * Returns last Cron execution time for specific cron or all crons + * + * @param array $cronGroups + * @return int + */ + private function getLastCronExecution(array $cronGroups = []) + { + if (empty($cronGroups)) { + return (int)max($this->cronExecution); + } + + $cronGroups = array_merge($cronGroups, ['*']); + + return array_reduce($cronGroups, function($lastExecution, $group) { + if (isset($this->cronExecution[$group]) && $this->cronExecution[$group] > $lastExecution) { + $lastExecution = $this->cronExecution[$group]; + } + + return (int)$lastExecution; + }, 0); + } + + /** + * Returns time to wait for next run + * + * @param array $cronGroups + * @param int $cronInterval + * @return int + */ + private function getCronWait(array $cronGroups = [], int $cronInterval = self::MAGENTO_CRON_INTERVAL) + { + $nextRun = $this->getLastCronExecution($cronGroups) + $cronInterval; + $toNextRun = $nextRun - time(); + + return max(0, $toNextRun); + } + /** * Runs DELETE request to delete a Magento entity against the url given. * @@ -971,4 +1049,36 @@ public function getSecret($key) { return CredentialStore::getInstance()->getSecret($key); } + + /** + * Waits proper amount of time to perform Cron execution + * + * @param $cronGroups + * @param $timeout + * @param $arguments + * @return string + * @throws TestFrameworkException + */ + private function executeCronjobs($cronGroups, $timeout, $arguments): string + { + $cronGroups = array_filter($cronGroups); + + $waitFor = $this->getCronWait($cronGroups); + + if ($waitFor) { + $this->wait($waitFor); + } + + $command = array_reduce($cronGroups, function ($command, $cronGroup) { + $command .= ' --group=' . $cronGroup; + return $command; + }, self::MAGENTO_CRON_COMMAND); + $timeStart = microtime(true); + $cronResult = $this->magentoCLI($command, $timeout, $arguments); + $timeEnd = microtime(true); + + $this->notifyCronFinished($cronGroups); + + return sprintf('%s (wait: %ss, execution: %ss)', $cronResult, $waitFor, round($timeEnd - $timeStart, 2)); + } } diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd index 2424d0d31..8670d9885 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/Actions/customActions.xsd @@ -12,6 +12,7 @@ + @@ -62,6 +63,40 @@ + + + + Executes Magento Cron Jobs (selected groups) + + + + + + + + Cron groups to be executed (separated by space) + + + + + + + Arguments for Magento CLI command, will not be escaped. + + + + + + + Idle timeout in seconds, defaulted to 60s when not specified. + + + + + + + + @@ -285,4 +320,4 @@ - \ No newline at end of file + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 09c353029..e98dcbe61 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -50,10 +50,12 @@ class TestGenerator 'retrieveEntityField', 'getSecret', 'magentoCLI', + 'magentoCron', 'generateDate', 'field' ]; const STEP_KEY_ANNOTATION = " // stepKey: %s"; + const CRON_INTERVAL = 60; /** * Actor name for AcceptanceTest @@ -534,6 +536,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $dependentSelector = null; $visible = null; $command = null; + $cronGroups = ''; $arguments = null; $sortOrder = null; $storeCode = null; @@ -551,6 +554,9 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato if (isset($customActionAttributes['command'])) { $command = $this->addUniquenessFunctionCall($customActionAttributes['command']); } + if (isset($customActionAttributes['groups'])) { + $cronGroups = $this->addUniquenessFunctionCall($customActionAttributes['groups']); + } if (isset($customActionAttributes['arguments'])) { $arguments = $this->addUniquenessFunctionCall($customActionAttributes['arguments']); } @@ -1270,6 +1276,22 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $stepKey ); break; + case 'magentoCron': + $testSteps .= $this->wrapFunctionCallWithReturnValue( + $stepKey, + $actor, + $actionObject, + $cronGroups, + self::CRON_INTERVAL + $time, + $arguments + ); + $testSteps .= sprintf(self::STEP_KEY_ANNOTATION, $stepKey) . PHP_EOL; + $testSteps .= sprintf( + "\t\t$%s->comment(\$%s);", + $actor, + $stepKey + ); + break; case "field": $fieldKey = $actionObject->getCustomActionAttributes()['key']; $input = $this->resolveStepKeyReferences($input, $actionObject->getActionOrigin()); @@ -1403,7 +1425,7 @@ private function replaceMatchesIntoArg($matches, &$outputArg) $variable = $this->stripAndSplitReference($match, $delimiter); if (count($variable) != 2) { throw new \Exception( - "Invalid Persisted Entity Reference: {$match}. + "Invalid Persisted Entity Reference: {$match}. Test persisted entity references must follow {$delimiter}entityStepKey.field{$delimiter} format." ); } From df058d78ed0b22eeb1d47352144c5a3828966d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Mon, 6 Jan 2020 16:12:02 +0100 Subject: [PATCH 17/67] Code Style like 80s! --- .../Module/MagentoWebDriver.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 3baa93cea..f44d7e1a0 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -565,9 +565,10 @@ public function magentoCLI($command, $timeout = null, $arguments = null) /** * Executes Magento Cron keeping the interval (> 60 seconds between each run) * - * @param string|null $cronGroups - * @param int|null $timeout - * @param string|null $arguments + * @param string|null $cronGroups + * @param integer|null $timeout + * @param string|null $arguments + * @return string */ public function magentoCron($cronGroups = null, $timeout = null, $arguments = null) { @@ -596,7 +597,7 @@ private function notifyCronFinished(array $cronGroups = []) * Returns last Cron execution time for specific cron or all crons * * @param array $cronGroups - * @return int + * @return integer */ private function getLastCronExecution(array $cronGroups = []) { @@ -606,7 +607,7 @@ private function getLastCronExecution(array $cronGroups = []) $cronGroups = array_merge($cronGroups, ['*']); - return array_reduce($cronGroups, function($lastExecution, $group) { + return array_reduce($cronGroups, function ($lastExecution, $group) { if (isset($this->cronExecution[$group]) && $this->cronExecution[$group] > $lastExecution) { $lastExecution = $this->cronExecution[$group]; } @@ -618,9 +619,9 @@ private function getLastCronExecution(array $cronGroups = []) /** * Returns time to wait for next run * - * @param array $cronGroups - * @param int $cronInterval - * @return int + * @param array $cronGroups + * @param integer $cronInterval + * @return integer */ private function getCronWait(array $cronGroups = [], int $cronInterval = self::MAGENTO_CRON_INTERVAL) { @@ -1053,9 +1054,9 @@ public function getSecret($key) /** * Waits proper amount of time to perform Cron execution * - * @param $cronGroups - * @param $timeout - * @param $arguments + * @param string $cronGroups + * @param integer $timeout + * @param string $arguments * @return string * @throws TestFrameworkException */ From af0a499d4b52c06d8053d2a57c7e9fe81227159a Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Mon, 6 Jan 2020 09:48:01 -0600 Subject: [PATCH 18/67] MQE-1513: createData throws a useless error message during runtime when the entity does not exist reverted changes Added unit test --- .../Handlers/PersistedObjectHandlerTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php index 6c3823466..34d59e8c8 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php @@ -32,6 +32,31 @@ public function setUp() TestLoggingUtil::getInstance()->setMockLoggingUtil(); } + public function testCreateInvalidEntity() + { + // Test Data and Variables + + $entityName = "InvalidEntity"; + $entityStepKey = "StepKey"; + $scope = PersistedObjectHandler::TEST_SCOPE; + + $exceptionMessage = "Entity \"" . $entityName . "\" does not exist." . + "\nException occurred parsing action at StepKey \"" . $entityStepKey . "\""; + + $this->expectException(TestReferenceException::class); + + $this->expectExceptionMessage($exceptionMessage); + + $handler = PersistedObjectHandler::getInstance(); + + // Call method + $handler->createEntity( + $entityStepKey, + $scope, + $entityName + ); + } + public function testCreateSimpleEntity() { // Test Data and Variables From 28804f4891ed698c91fd77040d411ede6de9bbfa Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Mon, 6 Jan 2020 15:00:21 -0600 Subject: [PATCH 19/67] MQE-1513: createData throws a useless error message during runtime when the entity does not exist reverted changes fixed unit test --- .../DataGenerator/Handlers/PersistedObjectHandlerTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php index 34d59e8c8..04e1f0810 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php @@ -32,10 +32,9 @@ public function setUp() TestLoggingUtil::getInstance()->setMockLoggingUtil(); } - public function testCreateInvalidEntity() + public function testCreateEntityWithNonExistingName() { // Test Data and Variables - $entityName = "InvalidEntity"; $entityStepKey = "StepKey"; $scope = PersistedObjectHandler::TEST_SCOPE; From 188d6bae7e827fefd83eb377adf52fd65d95b3f9 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Mon, 6 Jan 2020 15:45:31 -0600 Subject: [PATCH 20/67] MQE-1513: createData throws a useless error message during runtime when the entity does not exist reverted changes reworded message --- .../DataGenerator/Handlers/PersistedObjectHandlerTest.php | 2 +- .../DataGenerator/Handlers/PersistedObjectHandler.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php index 04e1f0810..592b87f4e 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/PersistedObjectHandlerTest.php @@ -40,7 +40,7 @@ public function testCreateEntityWithNonExistingName() $scope = PersistedObjectHandler::TEST_SCOPE; $exceptionMessage = "Entity \"" . $entityName . "\" does not exist." . - "\nException occurred parsing action at StepKey \"" . $entityStepKey . "\""; + "\nException occurred executing action at StepKey \"" . $entityStepKey . "\""; $this->expectException(TestReferenceException::class); diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php index 7015292c0..00353856b 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -101,7 +101,7 @@ public function createEntity( if ($retrievedEntity === null) { throw new TestReferenceException( "Entity \"" . $entity . "\" does not exist." . - "\nException occurred parsing action at StepKey \"" . $key . "\"" + "\nException occurred executing action at StepKey \"" . $key . "\"" ); } From 20a0ceffa1c3d1488161ea06834f1f6adeba2382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Tue, 7 Jan 2020 23:02:17 +0100 Subject: [PATCH 21/67] Code Review changes --- .../Util/TestGenerator.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 89120a83e..c87d0ad55 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -1778,8 +1778,6 @@ private function addDollarSign($input) return sprintf("$%s", ltrim($this->stripQuotes($input), '$')); } - // @codingStandardsIgnoreStart - /** * Wrap parameters into a function call. * @@ -1843,9 +1841,9 @@ private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $actio return $output; } - // @codingStandardsIgnoreEnd - /** + * Closure returned is used as a callable for array_filter to remove null values from array + * * @return callable */ private function filterNullCallback() @@ -1857,6 +1855,7 @@ private function filterNullCallback() /** * Resolves {{_ENV.variable}} into getenv("variable") for test-runtime ENV referencing. + * * @param array $args * @param string $regex * @param string $func @@ -1926,6 +1925,8 @@ private function validateParameterArray($paramArray) } /** + * Verifies whether we have correctly wrapped array syntax + * * @param string $paramArray * @return boolean */ @@ -1972,6 +1973,8 @@ private function resolveValueByType($value = null, $type = null) } /** + * Determines correct scope based on parameter + * * @param string $generationScope * @return string */ @@ -2103,6 +2106,8 @@ private function printRuleErrorToConsole($key, $tagName, $attributes) } /** + * Wraps parameters array with opening and closing symbol. + * * @param string $value * @return string */ @@ -2112,6 +2117,8 @@ private function wrapParameterArray(string $value): string } /** + * Determines whether string provided contains decimal point characteristic for current locale + * * @param string $outStr * @return boolean */ From f83107a98f49e636c003cb8ba23f60f8c9e94e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Tue, 7 Jan 2020 23:50:06 +0100 Subject: [PATCH 22/67] Satisfy ridiculous Coding Standard --- .../FunctionalTestingFramework/Util/TestGenerator.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index c87d0ad55..2d7b99eee 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -1781,10 +1781,9 @@ private function addDollarSign($input) /** * Wrap parameters into a function call. * - * @param string $actor + * @param string $actor * @param actionObject $action - * @param string $scope - * @param array ...$args + * @param array ...$args * @return string * @throws \Exception */ @@ -1816,7 +1815,7 @@ private function wrapFunctionCall($actor, $action, ...$args) * @param string $actor * @param string $action * @param string $scope - * @param array ...$args + * @param array ...$args * @return string * @throws \Exception */ From 771716dc4bc59921156d40254021a649e01e0b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Wed, 8 Jan 2020 00:07:13 +0100 Subject: [PATCH 23/67] ... Coding Standard --- src/Magento/FunctionalTestingFramework/Util/TestGenerator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 2d7b99eee..66c11975c 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -1814,7 +1814,6 @@ 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 From 995016a42bee7a0043ae2331be968f1f7a91369b Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Wed, 8 Jan 2020 14:56:40 -0600 Subject: [PATCH 24/67] MQE-1713: Generate/run test in single suite context - added support for 'suite:test' syntax in generate and run:test command - minor fixes to exceptions in suite mechanisms --- .../Console/BaseGenerateCommandTest.php | 18 ++++++++++++++++++ .../Console/BaseGenerateCommand.php | 4 ++++ .../Suite/Handlers/SuiteObjectHandler.php | 3 ++- .../Suite/SuiteGenerator.php | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Console/BaseGenerateCommandTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Console/BaseGenerateCommandTest.php index 1b1686ce2..234f677e8 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Console/BaseGenerateCommandTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Console/BaseGenerateCommandTest.php @@ -156,6 +156,24 @@ public function testThreeTestOneSuiteOneGroupMix() $this->assertEquals($expected, $actual); } + public function testSuiteToTestSyntax() + { + $testOne = new TestObject('Test1', [], [], []); + $suiteOne = new SuiteObject( + 'Suite1', + ['Test1' => $testOne], + [], + [] + ); + + $testArray = ['Test1' => $testOne]; + $suiteArray = ['Suite1' => $suiteOne]; + $this->mockHandlers($testArray, $suiteArray); + $actual = json_decode($this->callTestConfig(['Suite1:Test1']), true); + $expected = ['tests' => null, 'suites' => ['Suite1' => ['Test1']]]; + $this->assertEquals($expected, $actual); + } + /** * Mock handlers to skip parsing * @param array $testArray diff --git a/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php b/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php index 0953e9d68..72cfc8578 100644 --- a/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php @@ -87,6 +87,10 @@ protected function getTestAndSuiteConfiguration(array $tests) $suiteToTestPair = []; foreach($tests as $test) { + if (strpos($test, ':') !== null) { + $suiteToTestPair[] = $test; + continue; + } if (array_key_exists($test, $testsReferencedInSuites)) { $suites = $testsReferencedInSuites[$test]; foreach ($suites as $suite) { diff --git a/src/Magento/FunctionalTestingFramework/Suite/Handlers/SuiteObjectHandler.php b/src/Magento/FunctionalTestingFramework/Suite/Handlers/SuiteObjectHandler.php index 30a67c31d..bbaaf4379 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/Handlers/SuiteObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Suite/Handlers/SuiteObjectHandler.php @@ -5,6 +5,7 @@ */ namespace Magento\FunctionalTestingFramework\Suite\Handlers; +use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; use Magento\FunctionalTestingFramework\Exceptions\XmlException; use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface; use Magento\FunctionalTestingFramework\ObjectManagerFactory; @@ -73,7 +74,7 @@ public static function getInstance(): ObjectHandlerInterface public function getObject($objectName): SuiteObject { if (!array_key_exists($objectName, $this->suiteObjects)) { - trigger_error("Suite ${objectName} is not defined.", E_USER_ERROR); + throw new TestReferenceException("Suite ${objectName} is not defined in xml."); } return $this->suiteObjects[$objectName]; } diff --git a/src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php b/src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php index 4df7daa75..077e6d1cc 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php @@ -178,7 +178,7 @@ private function validateTestsReferencedInSuite($suiteName, $testsReferenced, $o { $suiteRef = $originalSuiteName ?? $suiteName; $possibleTestRef = SuiteObjectHandler::getInstance()->getObject($suiteRef)->getTests(); - $errorMsg = "Cannot reference tests whcih are not declared as part of suite."; + $errorMsg = "Cannot reference tests which are not declared as part of suite."; $invalidTestRef = array_diff($testsReferenced, array_keys($possibleTestRef)); From 199391561191460956489c26d97afc39b83514a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Wed, 8 Jan 2020 23:52:06 +0100 Subject: [PATCH 25/67] Add tests to cover new feature --- .../verification/TestModule/Test/BasicFunctionalTest.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml index c23a3ce60..1ef25b43d 100644 --- a/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml +++ b/dev/tests/verification/TestModule/Test/BasicFunctionalTest.xml @@ -79,6 +79,9 @@ + + + @@ -143,4 +146,4 @@ - \ No newline at end of file + From f61897228498c1a2734bf75dd17891645c6fef4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Thu, 9 Jan 2020 00:02:38 +0100 Subject: [PATCH 26/67] Add tests to cover new feature --- dev/tests/verification/Resources/BasicFunctionalTest.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index 5bcfd55dd..e78f1b49c 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -126,6 +126,12 @@ class BasicFunctionalTestCest $I->comment($magentoCli3); // stepKey: magentoCli3 $magentoCli4 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 120); // stepKey: magentoCli4 $I->comment($magentoCli4); // stepKey: magentoCli4 + $cronAllGroups = $I->magentoCron("", 70); // stepKey: cronAllGroups + $I->comment($cronAllGroups); + $cronSingleGroup = $I->magentoCron("index", 70); // stepKey: cronSingleGroup + $I->comment($cronSingleGroup); + $cronMultipleGroups = $I->magentoCron("a b c", 70); // stepKey: cronMultipleGroups + $I->comment($cronMultipleGroups); $I->makeScreenshot("screenShotInput"); // stepKey: makeScreenshotKey1 $I->maximizeWindow(); // stepKey: maximizeWindowKey1 $I->moveBack(); // stepKey: moveBackKey1 From f3bb5c2cfadd35ed6c8f50dc8fac402b69118ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Thu, 9 Jan 2020 00:18:02 +0100 Subject: [PATCH 27/67] Add documentation to `` command --- docs/test/actions.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/test/actions.md b/docs/test/actions.md index c5dc83fdb..59fd12aa2 100644 --- a/docs/test/actions.md +++ b/docs/test/actions.md @@ -1274,6 +1274,29 @@ Attribute|Type|Use|Description ``` +### magentoCron + +Used to execute Magento Cron jobs. Groups may be provided optionally. Internal mechanism of `` ensures that Cron Job of single group is ran with 60 seconds interval. + +Attribute|Type|Use|Description +---|---|---|--- +`groups`|string |optional| Run only specified groups of Cron Jobs +`arguments`|string |optional| Unescaped arguments to be passed in with the CLI command. +`timeout`|string|optional| Number of seconds CLI command can run without outputting anything. +`stepKey`|string|required| A unique identifier of the action. +`before`|string|optional| `stepKey` of action that must be executed next. +`after`|string|optional| `stepKey` of preceding action. + + +#### Example +```xml + + + + + +``` + ### makeScreenshot See [makeScreenshot docs on codeception.com](http://codeception.com/docs/modules/WebDriver#makeScreenshot). From aea7e8d76bc24c69cb506370e8bd8c78ca06e0ac Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 9 Jan 2020 08:58:24 -0600 Subject: [PATCH 28/67] MQE-1713: Generate/run test in single suite contex - Fixed wrong comparison --- .../FunctionalTestingFramework/Console/BaseGenerateCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php b/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php index 72cfc8578..a0d94b16e 100644 --- a/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/BaseGenerateCommand.php @@ -87,7 +87,7 @@ protected function getTestAndSuiteConfiguration(array $tests) $suiteToTestPair = []; foreach($tests as $test) { - if (strpos($test, ':') !== null) { + if (strpos($test, ':') !== false) { $suiteToTestPair[] = $test; continue; } From af7c2fb9a4af3de4a9a401768bb6794f149ca711 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Thu, 9 Jan 2020 09:03:40 -0600 Subject: [PATCH 29/67] MQE-1713: Generate/run test in single suite context - Documentation update --- docs/commands/mftf.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/commands/mftf.md b/docs/commands/mftf.md index 2440428f9..642bbb1bd 100644 --- a/docs/commands/mftf.md +++ b/docs/commands/mftf.md @@ -42,6 +42,12 @@ vendor/bin/mftf generate:tests vendor/bin/mftf generate:tests AdminLoginTest StorefrontPersistedCustomerLoginTest ``` +### Generate test by test and suite name + +```bash +vendor/bin/mftf generate:tests LoginSuite:AdminLoginTest +``` + ### Generate and run the tests for a specified group ```bash @@ -58,6 +64,14 @@ vendor/bin/mftf run:test AdminLoginTest StorefrontPersistedCustomerLoginTest -r This command cleans up the previously generated tests; generates and runs the `LoginAsAdminTest` and `LoginAsCustomerTest` tests. +### Generate and run particular test in a specific suite's context + +```bash +vendor/bin/mftf run:test LoginSuite:AdminLoginTest -r +``` + +This command cleans up previously generated tests; generates and run `AdminLoginTest` within the context of the `LoginSuite`. + ### Generate and run a testManifest.txt file ```bash From ffec377dd2d8b3d091dcc20c33c1354eed89836d Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Fri, 10 Jan 2020 14:44:00 -0600 Subject: [PATCH 30/67] MQE-1918: MFTF AWS Secrets Manager - Local Use --- composer.json | 3 + composer.lock | 148 ++++++++++++++++- .../AwsSecretManagerStorageTest.php | 65 ++++++++ docs/configuration.md | 22 +++ docs/credentials.md | 67 +++++++- etc/config/.env.example | 6 +- .../Handlers/CredentialStore.php | 27 ++- .../SecretStorage/AwsSecretManagerStorage.php | 155 ++++++++++++++++++ .../Handlers/SecretStorage/VaultStorage.php | 2 +- 9 files changed, 483 insertions(+), 12 deletions(-) create mode 100644 dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php create mode 100644 src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php diff --git a/composer.json b/composer.json index 158287fbf..ca1c02572 100755 --- a/composer.json +++ b/composer.json @@ -11,7 +11,10 @@ "require": { "php": "7.0.2||7.0.4||~7.0.6||~7.1.0||~7.2.0||~7.3.0", "ext-curl": "*", + "ext-json": "*", + "ext-openssl": "*", "allure-framework/allure-codeception": "~1.3.0", + "aws/aws-sdk-php": "^3.132", "codeception/codeception": "~2.4.5", "composer/composer": "^1.4", "consolidation/robo": "^1.0.0", diff --git a/composer.lock b/composer.lock index 8f2fcb8e9..6bfc30ab9 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": "59e95cc1ae6311e93111bd7ced180d29", + "content-hash": "2325a3a38edb33b24f6e33bd3009fd8a", "packages": [ { "name": "allure-framework/allure-codeception", @@ -109,6 +109,90 @@ ], "time": "2016-12-07T12:15:46+00:00" }, + { + "name": "aws/aws-sdk-php", + "version": "3.132.2", + "source": { + "type": "git", + "url": "https://github.com/aws/aws-sdk-php.git", + "reference": "f890689c6db27625522ea2e7e9b8420b6fccb063" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/f890689c6db27625522ea2e7e9b8420b6fccb063", + "reference": "f890689c6db27625522ea2e7e9b8420b6fccb063", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-pcre": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^5.3.3|^6.2.1|^7.0", + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4.1", + "mtdowling/jmespath.php": "^2.5", + "php": ">=5.5" + }, + "require-dev": { + "andrewsville/php-token-reflection": "^1.4", + "aws/aws-php-sns-message-validator": "~1.0", + "behat/behat": "~3.0", + "doctrine/cache": "~1.4", + "ext-dom": "*", + "ext-openssl": "*", + "ext-pcntl": "*", + "ext-sockets": "*", + "nette/neon": "^2.3", + "phpunit/phpunit": "^4.8.35|^5.4.3", + "psr/cache": "^1.0", + "psr/simple-cache": "^1.0", + "sebastian/comparator": "^1.2.3" + }, + "suggest": { + "aws/aws-php-sns-message-validator": "To validate incoming SNS notifications", + "doctrine/cache": "To use the DoctrineCacheAdapter", + "ext-curl": "To send requests using cURL", + "ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages", + "ext-sockets": "To use client-side monitoring" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Aws\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Amazon Web Services", + "homepage": "http://aws.amazon.com" + } + ], + "description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project", + "homepage": "http://aws.amazon.com/sdkforphp", + "keywords": [ + "amazon", + "aws", + "cloud", + "dynamodb", + "ec2", + "glacier", + "s3", + "sdk" + ], + "time": "2020-01-09T19:09:31+00:00" + }, { "name": "behat/gherkin", "version": "v4.4.5", @@ -2542,8 +2626,66 @@ "bcmath", "math" ], + "abandoned": "brick/math", "time": "2017-02-16T16:54:46+00:00" }, + { + "name": "mtdowling/jmespath.php", + "version": "2.5.0", + "source": { + "type": "git", + "url": "https://github.com/jmespath/jmespath.php.git", + "reference": "52168cb9472de06979613d365c7f1ab8798be895" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/52168cb9472de06979613d365c7f1ab8798be895", + "reference": "52168cb9472de06979613d365c7f1ab8798be895", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "symfony/polyfill-mbstring": "^1.4" + }, + "require-dev": { + "composer/xdebug-handler": "^1.2", + "phpunit/phpunit": "^4.8.36|^7.5.15" + }, + "bin": [ + "bin/jp.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-4": { + "JmesPath\\": "src/" + }, + "files": [ + "src/JmesPath.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Declaratively specify how to extract elements from a JSON document", + "keywords": [ + "json", + "jsonpath" + ], + "time": "2019-12-30T18:03:34+00:00" + }, { "name": "mustache/mustache", "version": "v2.12.0", @@ -6542,7 +6684,9 @@ "prefer-lowest": false, "platform": { "php": "7.0.2||7.0.4||~7.0.6||~7.1.0||~7.2.0||~7.3.0", - "ext-curl": "*" + "ext-curl": "*", + "ext-json": "*", + "ext-openssl": "*" }, "platform-dev": [] } diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php new file mode 100644 index 000000000..015c7a009 --- /dev/null +++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php @@ -0,0 +1,65 @@ + 'mftf/magento/' . $testShortKey, + 'SecretString' => json_encode([$testShortKey => $testValue]) + ]; + /** @var Result */ + $result = new Result($data); + + $mockClient = $this->getMockBuilder(SecretsManagerClient::class) + ->disableOriginalConstructor() + ->setMethods(['__call']) + ->getMock(); + + $mockClient->expects($this->once()) + ->method('__call') + ->willReturnCallback(function($name, $args) use ($result) { + return $result; + }); + + /** @var SecretsManagerClient */ + $credentialStorage = new AwsSecretManagerStorage($testRegion, $testProfile); + $reflection = new ReflectionClass($credentialStorage); + $reflection_property = $reflection->getProperty('client'); + $reflection_property->setAccessible(true); + $reflection_property->setValue($credentialStorage, $mockClient); + + // Test getEncryptedValue() + $encryptedCred = $credentialStorage->getEncryptedValue($testLongKey); + + // Assert the value we've gotten is in fact not identical to our test value + $this->assertNotEquals($testValue, $encryptedCred); + + // Test getDecryptedValue() + $actualValue = $credentialStorage->getDecryptedValue($encryptedCred); + + // Assert that we are able to successfully decrypt our secret value + $this->assertEquals($testValue, $actualValue); + } +} diff --git a/docs/configuration.md b/docs/configuration.md index 5140c01e7..f89090c06 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -277,6 +277,28 @@ Example: CREDENTIAL_VAULT_SECRET_BASE_PATH=secret ``` +### CREDENTIAL_AWS_SECRET_MANAGER_REGION + +The region that Aws Secret Manager is located. + +Example: + +```conf +# Region of Aws Secret Manager +CREDENTIAL_AWS_SECRET_MANAGER_REGION=us-east-1 +``` + +### CREDENTIAL_AWS_SECRET_MANAGER_PROFILE + +The profile used to connect to Aws Secret Manager. + +Example: + +```conf +# Profile used to connect to Aws Secret Manager. +CREDENTIAL_AWS_SECRET_MANAGER_PROFILE=default +``` + ### ENABLE_BROWSER_LOG Enables addition of browser logs to Allure steps diff --git a/docs/credentials.md b/docs/credentials.md index a2850cfe8..6ca9900cb 100644 --- a/docs/credentials.md +++ b/docs/credentials.md @@ -3,10 +3,11 @@ When you test functionality that involves external services such as UPS, FedEx, PayPal, or SignifyD, use the MFTF credentials feature to hide sensitive [data][] like integration tokens and API keys. -Currently the MFTF supports two types of credential storage: +Currently the MFTF supports three types of credential storage: - **.credentials file** -- **HashiCorp vault** +- **HashiCorp Vault** +- **Aws Secret Manager** ## Configure File Storage @@ -135,11 +136,64 @@ CREDENTIAL_VAULT_ADDRESS=http://127.0.0.1:8200 CREDENTIAL_VAULT_SECRET_BASE_PATH=secret ``` -## Configure both File Storage and Vault Storage +## Configure Aws Secret Manager -It is possible and sometimes useful to setup and use both `.credentials` file and vault for secret storage at the same time. -In this case, the MFTF tests are able to read secret data at runtime from both storage options, but the local `.credentials` file will take precedence. +Aws Secrets Manager offers secret management that supports: +- Secret rotation with built-in integration for Amazon RDS, Amazon Redshift, and Amazon DocumentDB +- Fine-grained policies and permissions +- Audit secret rotation centrally for resources in the AWS Cloud, third-party services, and on-premises +### Prerequisites +- AWS account +- AWS Secret Manger is created and configured +- IAM User or Role is created + +### Store secrets in Aws Secret Manager + +#### Secrets format +`Secret Name`, `Secret Key`, `Secret Value` are three key pieces of information to construct an Aws Secret. +`Secret Key` and `Secret Value` can be any content you want to secure, `Secret Name` must follow the format: + +```conf +mftf// +``` + +```conf +# Secret name for carriers_usps_userid +mftf/magento/carriers_usps_userid + +# Secret key for carriers_usps_userid +carriers_usps_userid + +# Secret name for carriers_usps_password +mftf/magento/carriers_usps_password + +# Secret key for carriers_usps_password +carriers_usps_password +``` + +### Setup MFTF to use Aws Secret Manager + +To use Aws Secret Manager, the Aws region to connect to is required. You can set it through environment variable [`CREDENTIAL_AWS_SECRET_MANAGER_REGION`][] in `.env`. + +MFTF uses the recommended [Default Credential Provider Chain][credential chain] to establish connection to Aws Secret Manager service. +You can setup credentials according to [Default Credential Provider Chain][credential chain] and there is no MFTF specific setup required. +Optionally, however, you can explicitly set Aws profile through environment variable [`CREDENTIAL_AWS_SECRET_MANAGER_PROFILE`][] in `.env`. + +```conf +# Sample Aws Secret Manager configuration +CREDENTIAL_AWS_SECRET_MANAGER_REGION=us-east-1 +CREDENTIAL_AWS_SECRET_MANAGER_PROFILE=default +``` + +## Configure multiple credential storage + +It is possible and sometimes useful to setup and use multiple credential storage at the same time. +In this case, the MFTF tests are able to read secret data at runtime from all storage options, in this case MFTF use the following precedence: + +``` +.credentials File > HashiCorp Vault > Aws Secret Manager +``` ## Use credentials in a test @@ -183,3 +237,6 @@ The MFTF tests delivered with Magento application do not use credentials and do [Vault KV2]: https://www.vaultproject.io/docs/secrets/kv/kv-v2.html [`CREDENTIAL_VAULT_ADDRESS`]: configuration.md#credential_vault_address [`CREDENTIAL_VAULT_SECRET_BASE_PATH`]: configuration.md#credential_vault_secret_base_path +[credential chain]: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html +[`CREDENTIAL_AWS_SECRET_MANAGER_PROFILE`]: configuration.md#credential_aws_secret_manager_profile +[`CREDENTIAL_AWS_SECRET_MANAGER_REGION`]: configuration.md#credential_aws_secret_manager_region \ No newline at end of file diff --git a/etc/config/.env.example b/etc/config/.env.example index 7320d8b8b..a772b1e9e 100644 --- a/etc/config/.env.example +++ b/etc/config/.env.example @@ -30,10 +30,14 @@ BROWSER=chrome #MAGENTO_RESTAPI_SERVER_PORT=8080 #MAGENTO_RESTAPI_SERVER_PROTOCOL=https -#*** Uncomment and set vault address and secret base path if you want to use vault to manage _CREDS secrets ***# +#*** To use HashiCorp Vault to manage _CREDS secrets, uncomment and set vault address and secret base path ***# #CREDENTIAL_VAULT_ADDRESS=http://127.0.0.1:8200 #CREDENTIAL_VAULT_SECRET_BASE_PATH=secret +#*** To use AWS Secret Manager to manage _CREDS secrets, uncomment and set region, profile is optional, when omitted, AWS default credential provider chain will be used ***# +#CREDENTIAL_AWS_SECRET_MANAGER_PROFILE=default +#CREDENTIAL_AWS_SECRET_MANAGER_REGION=us-east-1 + #*** Uncomment these properties to set up a dev environment with symlinked projects ***# #TESTS_BP= #FW_BP= diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php index 94ff40069..bff3e9b00 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php @@ -9,12 +9,18 @@ use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\FileStorage; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\VaultStorage; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\AwsSecretManagerStorage; use Magento\FunctionalTestingFramework\Util\Path\UrlFormatter; class CredentialStore { const ARRAY_KEY_FOR_VAULT = 'vault'; const ARRAY_KEY_FOR_FILE = 'file'; + const ARRAY_KEY_FOR_AWS_SECRET_MANAGER = 'aws'; + + const CREDENTIAL_STORAGE_INFO = 'MFTF uses Credential Storage in the following precedence: ' + . '.credentials file, HashiCorp Vault and AWS Secret Manager. ' + . 'You need to configure at least one to use _CREDS in tests.'; /** * Credential storage array @@ -71,9 +77,25 @@ private function __construct() } } + // Initialize AWS secret manager storage + $awsRegion = getenv('CREDENTIAL_AWS_SECRET_MANAGER_REGION'); + $awsProfile = getenv('CREDENTIAL_AWS_SECRET_MANAGER_PROFILE'); + if ($awsRegion !== false) { + if ($awsProfile === false) { + $awsProfile = null; + } + try { + $this->credStorage[self::ARRAY_KEY_FOR_AWS_SECRET_MANAGER] = new AwsSecretManagerStorage( + $awsRegion, + $awsProfile + ); + } catch (TestFrameworkException $e) { + } + } + if (empty($this->credStorage)) { throw new TestFrameworkException( - "No credential storage is properly configured. Please configure vault or .credentials file." + 'Invalid Credential Storage. ' . self::CREDENTIAL_STORAGE_INFO ); } } @@ -97,8 +119,7 @@ public function getSecret($key) } throw new TestFrameworkException( - "\"{$key}\" not defined in vault or .credentials file, " - . "please provide a value in order to use this secret in a test." + "{$key} not found. " . self::CREDENTIAL_STORAGE_INFO . ' And make sure key/value exists.' ); } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php new file mode 100644 index 000000000..c617f1cac --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php @@ -0,0 +1,155 @@ +createAwsSecretManagerClient($region, $profile); + } + + /** + * Returns the value of a secret based on corresponding key + * + * @param string $key + * @return string|null + * @throws Exception + */ + public function getEncryptedValue($key) + { + // Check if secret is in cached array + if (null !== ($value = parent::getEncryptedValue($key))) { + return $value; + } + + if (MftfApplicationConfig::getConfig()->verboseEnabled()) { + LoggingUtil::getInstance()->getLogger(VaultStorage::class)->debug( + "Retrieving secret for key name {$key} from AWS Secret Manager" + ); + } + + $reValue = null; + try { + // Split vendor/key to construct secret id + list($vendor, $key) = explode('/', trim($key, '/'), 2); + $secretId = self::MFTF_PATH + . '/' + . $vendor + . '/' + . $key; + // Read value by id from AWS Secret Manager, and parse the result + $value = $this->parseAwsSecretResult( + $this->client->getSecretValue(['SecretId' => $secretId]), + $key + ); + // Encrypt value for return + $reValue = openssl_encrypt($value, parent::ENCRYPTION_ALGO, parent::$encodedKey, 0, parent::$iv); + parent::$cachedSecretData[$key] = $reValue; + } catch (AwsException $e) { + $error = $e->getAwsErrorCode(); + if (MftfApplicationConfig::getConfig()->verboseEnabled()) { + LoggingUtil::getInstance()->getLogger(VaultStorage::class)->debug( + "AWS error code: {$error}. Unable to read secret for key {$key} from AWS Secret Manager" + ); + } + } catch (\Exception $e) { + if (MftfApplicationConfig::getConfig()->verboseEnabled()) { + LoggingUtil::getInstance()->getLogger(VaultStorage::class)->debug( + "Unable to read secret for key {$key} from AWS Secret Manager" + ); + } + } + return $reValue; + } + + /** + * Parse AWS result object and return secret for key + * + * @param Result $awsResult + * @param string $key + * @return string + * @throws TestFrameworkException + */ + private function parseAwsSecretResult($awsResult, $key) + { + // Return secret from the associated KMS CMK + if (isset($awsResult['SecretString'])) { + $rawSecret = $awsResult['SecretString']; + } else { + throw new TestFrameworkException("Error parsing AWS secret result"); + } + $secret = json_decode($rawSecret, true); + if (isset($secret[$key])) { + return $secret[$key]; + } + throw new TestFrameworkException("Error parsing AWS secret result"); + } + + /** + * Create Aws Secret Manager client + * + * @param string $region + * @param string $profile + * @throws TestFrameworkException + * @throws InvalidArgumentException + */ + private function createAwsSecretManagerClient($region, $profile) + { + if (null !== $this->client) { + return; + } + + // Create AWS Secret Manager client + $this->client = new SecretsManagerClient([ + 'profile' => $profile, + 'region' => $region, + 'version' => self::LATEST_VERSION + ]); + + if ($this->client === null) { + throw new TestFrameworkException("Unable to create AWS Secret Manager client"); + } + } +} diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php index 6a9e9f0cf..798ac660c 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php @@ -67,7 +67,7 @@ class VaultStorage extends BaseStorage private $secretBasePath; /** - * CredentialVault constructor + * VaultStorage constructor * * @param string $baseUrl * @param string $secretBasePath From 579c96d82c9786392cf85b78162947d42f686802 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Fri, 10 Jan 2020 14:49:15 -0600 Subject: [PATCH 31/67] MQE-1918: MFTF AWS Secrets Manager - Local Use --- .../Handlers/SecretStorage/AwsSecretManagerStorageTest.php | 2 +- .../Handlers/SecretStorage/AwsSecretManagerStorage.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php index 015c7a009..f11d14920 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php @@ -39,7 +39,7 @@ public function testEncryptAndDecrypt() $mockClient->expects($this->once()) ->method('__call') - ->willReturnCallback(function($name, $args) use ($result) { + ->willReturnCallback(function ($name, $args) use ($result) { return $result; }); diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php index c617f1cac..0c10c53c4 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php @@ -132,6 +132,7 @@ private function parseAwsSecretResult($awsResult, $key) * * @param string $region * @param string $profile + * @return void * @throws TestFrameworkException * @throws InvalidArgumentException */ From 3f7df8b25609c811c2823895d38d63ee051a2950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Sun, 12 Jan 2020 01:22:33 +0100 Subject: [PATCH 32/67] Update ActionGroups documentation --- docs/test/action-groups.md | 111 ++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/docs/test/action-groups.md b/docs/test/action-groups.md index 0743481f6..5fdfbb522 100644 --- a/docs/test/action-groups.md +++ b/docs/test/action-groups.md @@ -10,8 +10,10 @@ The following diagram shows the structure of an MFTF action group: The following conventions apply to MFTF action groups: -- All action groups are declared in XML files and stored in the `/ActionGroup/` directory. -- Every file name ends with `ActionGroup`, such as `LoginToAdminActionGroup`. +- All action groups are declared in XML files and stored in the `/Test/Mftf/ActionGroup/` directory. +- Every file name ends with `ActionGroup` suffix. For exampe `LoginAsAdminActionGroup.xml`. +- Action group name should be the same as file name without extension. +- Single file should contain only one `` node The XML format for the `actionGroups` declaration is: @@ -34,32 +36,31 @@ The XML format for the `actionGroups` declaration is: These examples build a declaration for a group of actions that grant authorization to the Admin area, and use the declaration in a test. -The _Backend/ActionGroup/LoginToAdminActionGroup.xml_ `` relates to the functionality of the _Backend_ module. -In [test][], the name and identifier of the `` is used as a reference in the `ref` parameter, such as `ref="LoginToAdminActionGroup"`. +The _Magento/Backend/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml_ `` relates to the functionality of the _Magento_Backend_ module. + +In [test][], the name and identifier of the `` is used as a reference in the `ref` parameter, such as `ref="LoginAsAdminActionGroup"`. ### Create an action group declaration To create the `` declaration: -1. Begin with a _Backend/ActionGroup/LoginToAdminActionGroup.xml_ template for the ``: +1. Begin with a template for the ``: ```xml - - ... + + ``` - - 1. Add actions to the `actionGroup` arguments: ```xml - + @@ -81,14 +82,20 @@ To create the `` declaration: - - - - - - - - + + + Login to Backend Admin using provided User Data. PLEASE NOTE: This Action Group does NOT validate that you are Logged In. + + + + + + + + + + + ``` @@ -97,23 +104,23 @@ To create the `` declaration: In this test example, we want to add the following set of actions: ```xml - - - + + + ``` -Instead of adding this set of actions, use the _LoginToAdminActionGroup_ `` declaration in tests: +Instead of adding this set of actions, use the _LoginAsAdminActionGroup_ `` declaration in tests: -1. Reference the `LoginToAdminActionGroup` action group: +1. Reference the `LoginAsAdminActionGroup` action group: ```xml - + ``` 1. Update the argument name/value pair to `adminUser` and `CustomAdminUser`: ```xml - + ``` @@ -196,30 +203,34 @@ Starting with an action group such as: ``` It can be reworked into more manageable pieces, as below. These smaller steps are easier to read, update, and reuse. - -```xml - - - - - - - - - - - - - - - - - - - - - -``` +* GoToCategoryGridAndAddNewCategory + ```xml + + + + + + ``` +* FillInBasicCategoryFields + ```xml + + + + + + + + + ``` +* SaveAndVerifyCategoryCreation + ```xml + + + + + + + ``` @@ -261,4 +272,4 @@ Attribute|Type|Use|Description [actions]: ./actions.md [test]: ../test.md [`argument`]: #argument-tag -[created]: ../data.md#persist-data \ No newline at end of file +[created]: ../data.md#persist-data From 2d67ec9961abf24e720e34a4a9e6ff5d612761fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= Date: Sun, 12 Jan 2020 01:33:48 +0100 Subject: [PATCH 33/67] Update Best Practices --- docs/best-practices.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/best-practices.md b/docs/best-practices.md index a3e5f2629..95677e78a 100644 --- a/docs/best-practices.md +++ b/docs/best-practices.md @@ -5,12 +5,12 @@ Check out our best practices below to ensure you are getting the absolute most o ## Action group 1. [Action group] names should be sufficiently descriptive to inform a test writer of what the action group does and when it should be used. - Add additional explanation in comments if needed. + Add additional explanation in annotations if needed. 2. Provide default values for the arguments that apply to your most common case scenarios. ## `actionGroups` vs `extends` -Use an action group to wraps a set of actions to reuse them multiple times. +Use an action group to wrap a set of actions to reuse them multiple times. Use an [extension] when a test or action group needs to be repeated with the exception of a few steps. @@ -64,6 +64,12 @@ Format: {_Admin_ or _Storefront_}{Functionality}_Test.xml_, where Functionality Example: _StorefrontCreateCustomerTest.xml_. +#### Action Group file name + +Format: {_Admin_ or _Storefront_}{Action Group Summary}ActionGroup.xml`, where Action Group Summary describes with a few words what we can expect from it. + +Example: _AdminCreateStoreActionGroup.xml_ + #### Section file name Format: {_Admin_ or _Storefront_}{UI Description}_Section.xml_, where UI Description briefly describes the testing UI. @@ -97,6 +103,7 @@ Use a lower case first letter for: - Data keys. Example: ``. - Element names. Examples: ``. +- Step keys. For example: `` ## Page object From 22e1f48404a6fc2a68d152aec749db246d1a3428 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Tue, 14 Jan 2020 09:46:50 -0600 Subject: [PATCH 34/67] MQE-1713: Generate/run test in single suite context - New Unit test for SuiteGenerator - Better message for exception in SuiteGenerator --- .../Suite/SuiteGeneratorTest.php | 45 +++++++++++++++++++ .../Suite/SuiteGenerator.php | 6 ++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php index 29158b0f5..eded50b41 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php @@ -6,6 +6,7 @@ namespace Tests\unit\Magento\FunctionalTestFramework\Suite; use AspectMock\Test as AspectMock; +use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; use Magento\FunctionalTestingFramework\ObjectManager\ObjectManager; use Magento\FunctionalTestingFramework\ObjectManagerFactory; use Magento\FunctionalTestingFramework\Suite\SuiteGenerator; @@ -17,6 +18,7 @@ use Magento\FunctionalTestingFramework\Test\Parsers\TestDataParser; use Magento\FunctionalTestingFramework\Util\Manifest\DefaultTestManifest; use Magento\FunctionalTestingFramework\Util\MagentoTestCase; +use Magento\FunctionalTestingFramework\Util\Manifest\TestManifestFactory; use tests\unit\Util\SuiteDataArrayBuilder; use tests\unit\Util\TestDataArrayBuilder; use tests\unit\Util\TestLoggingUtil; @@ -143,6 +145,49 @@ public function testGenerateEmptySuite() $mockSuiteGenerator->generateSuite("basicTestSuite"); } + public function testInvalidTestRef() + { + // Mock Suite1 => Test1 and Suite2 => Test2 + $suiteDataArrayBuilder = new SuiteDataArrayBuilder(); + $mockData = $suiteDataArrayBuilder + ->withName('Suite1') + ->includeGroups(['group1']) + ->build(); + $suiteDataArrayBuilder = new SuiteDataArrayBuilder(); + $mockData2 = $suiteDataArrayBuilder + ->withName('Suite2') + ->includeGroups(['group2']) + ->build(); + $mockSuiteData = array_merge_recursive($mockData, $mockData2); + + $testDataArrayBuilder = new TestDataArrayBuilder(); + $mockSimpleTest = $testDataArrayBuilder + ->withName('Test1') + ->withAnnotations(['group' => [['value' => 'group1']]]) + ->withTestActions() + ->build(); + $testDataArrayBuilder = new TestDataArrayBuilder(); + $mockSimpleTest2 = $testDataArrayBuilder + ->withName('Test2') + ->withAnnotations(['group' => [['value' => 'group2']]]) + ->withTestActions() + ->build(); + $mockTestData = ['tests' => array_merge($mockSimpleTest, $mockSimpleTest2)]; + $this->setMockTestAndSuiteParserOutput($mockTestData, $mockSuiteData); + + // Make invalid manifest + $suiteConfig = ['Suite2' => ['Test1']]; + $manifest = TestManifestFactory::makeManifest('default', $suiteConfig); + + // Set up Expected Exception + $this->expectException(TestReferenceException::class); + $this->expectExceptionMessageRegExp('(Suite: "Suite2" Tests: "Test1")'); + + // parse and generate suite object with mocked data and manifest + $mockSuiteGenerator = SuiteGenerator::getInstance(); + $mockSuiteGenerator->generateAllSuites($manifest); + } + /** * Function used to set mock for parser return and force init method to run between tests. * diff --git a/src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php b/src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php index 077e6d1cc..e3da10497 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Suite/SuiteGenerator.php @@ -178,12 +178,14 @@ private function validateTestsReferencedInSuite($suiteName, $testsReferenced, $o { $suiteRef = $originalSuiteName ?? $suiteName; $possibleTestRef = SuiteObjectHandler::getInstance()->getObject($suiteRef)->getTests(); - $errorMsg = "Cannot reference tests which are not declared as part of suite."; + $errorMsg = "Cannot reference tests which are not declared as part of suite"; $invalidTestRef = array_diff($testsReferenced, array_keys($possibleTestRef)); if (!empty($invalidTestRef)) { - throw new TestReferenceException($errorMsg, ['suite' => $suiteRef, 'test' => $invalidTestRef]); + $testList = implode("\", \"", $invalidTestRef); + $fullError = $errorMsg . " (Suite: \"{$suiteRef}\" Tests: \"{$testList}\")"; + throw new TestReferenceException($fullError, ['suite' => $suiteRef, 'test' => $invalidTestRef]); } } From 46eabbf80dc84fe37981ba8487ac53a6bfae76ec Mon Sep 17 00:00:00 2001 From: Donald Booth Date: Tue, 14 Jan 2020 10:21:46 -0600 Subject: [PATCH 35/67] Added raw tags --- docs/best-practices.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/docs/best-practices.md b/docs/best-practices.md index 95677e78a..0b95b1c41 100644 --- a/docs/best-practices.md +++ b/docs/best-practices.md @@ -58,6 +58,8 @@ The following pattern is used when merging with `extends`: Name files according to the following patterns to make searching in future more easy: + + #### Test file name Format: {_Admin_ or _Storefront_}{Functionality}_Test.xml_, where Functionality briefly describes the testing functionality. @@ -80,6 +82,8 @@ Example: _AdminNavbarSection.xml_. Format: {Type}_Data.xml_, where Type represents the entity type. + + Example: _ProductData.xml_. ### Object names @@ -91,18 +95,18 @@ Use the _Foo.camelCase_ naming convention, which is similar to _Classes_ and _cl Use an upper case first letter for: - File names. Example: _StorefrontCreateCustomerTest.xml_ -- Test name attributes. Example: ``. -- Data entity names. Example: ``. -- Page name. Example: ``. -- Section name. Example: `
`. -- Action group name. Example: ``. +- Test name attributes. Example: `` +- Data entity names. Example: `` +- Page name. Example: `` +- Section name. Example: `
` +- Action group name. Example: `` #### Lower case Use a lower case first letter for: -- Data keys. Example: ``. -- Element names. Examples: ``. +- Data keys. Example: `` +- Element names. Examples: `` - Step keys. For example: `` ## Page object From ce8b333b0d4cd115b69f42b9f2a2f5e08b3eef89 Mon Sep 17 00:00:00 2001 From: Kevin Kozan Date: Tue, 14 Jan 2020 11:11:26 -0600 Subject: [PATCH 36/67] MQE-1713: Generate/run test in single suite context - Added unit test for different exception message --- .../Suite/SuiteGeneratorTest.php | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php index eded50b41..e3f820ede 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Suite/SuiteGeneratorTest.php @@ -145,7 +145,7 @@ public function testGenerateEmptySuite() $mockSuiteGenerator->generateSuite("basicTestSuite"); } - public function testInvalidTestRef() + public function testInvalidSuiteTestPair() { // Mock Suite1 => Test1 and Suite2 => Test2 $suiteDataArrayBuilder = new SuiteDataArrayBuilder(); @@ -188,6 +188,30 @@ public function testInvalidTestRef() $mockSuiteGenerator->generateAllSuites($manifest); } + public function testNonExistentSuiteTestPair() + { + $testDataArrayBuilder = new TestDataArrayBuilder(); + $mockSimpleTest = $testDataArrayBuilder + ->withName('Test1') + ->withAnnotations(['group' => [['value' => 'group1']]]) + ->withTestActions() + ->build(); + $mockTestData = ['tests' => array_merge($mockSimpleTest)]; + $this->setMockTestAndSuiteParserOutput($mockTestData, []); + + // Make invalid manifest + $suiteConfig = ['Suite3' => ['Test1']]; + $manifest = TestManifestFactory::makeManifest('default', $suiteConfig); + + // Set up Expected Exception + $this->expectException(TestReferenceException::class); + $this->expectExceptionMessageRegExp('#Suite3 is not defined#'); + + // parse and generate suite object with mocked data and manifest + $mockSuiteGenerator = SuiteGenerator::getInstance(); + $mockSuiteGenerator->generateAllSuites($manifest); + } + /** * Function used to set mock for parser return and force init method to run between tests. * From d0d98051488658d8325b7e2e0fe3a969c9cd45ee Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Tue, 14 Jan 2020 15:36:30 -0600 Subject: [PATCH 37/67] MQE-1918: MFTF AWS Secrets Manager - Local Use --- ...t.php => AwsSecretsManagerStorageTest.php} | 8 ++--- docs/configuration.md | 16 ++++----- docs/credentials.md | 34 +++++++++---------- etc/config/.env.example | 6 ++-- .../Handlers/CredentialStore.php | 18 +++++----- ...orage.php => AwsSecretsManagerStorage.php} | 34 +++++++++---------- 6 files changed, 58 insertions(+), 58 deletions(-) rename dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/{AwsSecretManagerStorageTest.php => AwsSecretsManagerStorageTest.php} (88%) rename src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/{AwsSecretManagerStorage.php => AwsSecretsManagerStorage.php} (75%) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorageTest.php similarity index 88% rename from dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php rename to dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorageTest.php index f11d14920..e1f4e4879 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorageTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorageTest.php @@ -7,15 +7,15 @@ namespace tests\unit\Magento\FunctionalTestFramework\DataGenerator\Handlers\SecretStorage; use Aws\SecretsManager\SecretsManagerClient; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\AwsSecretManagerStorage; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\AwsSecretsManagerStorage; use Aws\Result; use Magento\FunctionalTestingFramework\Util\MagentoTestCase; use ReflectionClass; -class AwsSecretManagerStorageTest extends MagentoTestCase +class AwsSecretsManagerStorageTest extends MagentoTestCase { /** - * Test encryption/decryption functionality in AwsSecretManagerStorage class. + * Test encryption/decryption functionality in AwsSecretsManagerStorage class. */ public function testEncryptAndDecrypt() { @@ -44,7 +44,7 @@ public function testEncryptAndDecrypt() }); /** @var SecretsManagerClient */ - $credentialStorage = new AwsSecretManagerStorage($testRegion, $testProfile); + $credentialStorage = new AwsSecretsManagerStorage($testRegion, $testProfile); $reflection = new ReflectionClass($credentialStorage); $reflection_property = $reflection->getProperty('client'); $reflection_property->setAccessible(true); diff --git a/docs/configuration.md b/docs/configuration.md index f89090c06..9466f2bcc 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -277,26 +277,26 @@ Example: CREDENTIAL_VAULT_SECRET_BASE_PATH=secret ``` -### CREDENTIAL_AWS_SECRET_MANAGER_REGION +### CREDENTIAL_AWS_SECRETS_MANAGER_REGION -The region that Aws Secret Manager is located. +The region that AWS Secrets Manager is located. Example: ```conf -# Region of Aws Secret Manager -CREDENTIAL_AWS_SECRET_MANAGER_REGION=us-east-1 +# Region of AWS Secrets Manager +CREDENTIAL_AWS_SECRETS_MANAGER_REGION=us-east-1 ``` -### CREDENTIAL_AWS_SECRET_MANAGER_PROFILE +### CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE -The profile used to connect to Aws Secret Manager. +The profile used to connect to AWS Secrets Manager. Example: ```conf -# Profile used to connect to Aws Secret Manager. -CREDENTIAL_AWS_SECRET_MANAGER_PROFILE=default +# Profile used to connect to AWS Secrets Manager. +CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default ``` ### ENABLE_BROWSER_LOG diff --git a/docs/credentials.md b/docs/credentials.md index 6ca9900cb..4b20e68dc 100644 --- a/docs/credentials.md +++ b/docs/credentials.md @@ -7,7 +7,7 @@ Currently the MFTF supports three types of credential storage: - **.credentials file** - **HashiCorp Vault** -- **Aws Secret Manager** +- **AWS Secrets Manager** ## Configure File Storage @@ -136,22 +136,22 @@ CREDENTIAL_VAULT_ADDRESS=http://127.0.0.1:8200 CREDENTIAL_VAULT_SECRET_BASE_PATH=secret ``` -## Configure Aws Secret Manager +## Configure AWS Secrets Manager -Aws Secrets Manager offers secret management that supports: +AWS Secrets Manager offers secret management that supports: - Secret rotation with built-in integration for Amazon RDS, Amazon Redshift, and Amazon DocumentDB - Fine-grained policies and permissions - Audit secret rotation centrally for resources in the AWS Cloud, third-party services, and on-premises ### Prerequisites - AWS account -- AWS Secret Manger is created and configured -- IAM User or Role is created +- AWS Secrets Manger is created and configured +- IAM User or Role is created with appropriate AWS Secrets Manger access permission -### Store secrets in Aws Secret Manager +### Store secrets in AWS Secrets Manager #### Secrets format -`Secret Name`, `Secret Key`, `Secret Value` are three key pieces of information to construct an Aws Secret. +`Secret Name`, `Secret Key`, `Secret Value` are three key pieces of information to construct an AWS Secret. `Secret Key` and `Secret Value` can be any content you want to secure, `Secret Name` must follow the format: ```conf @@ -172,18 +172,18 @@ mftf/magento/carriers_usps_password carriers_usps_password ``` -### Setup MFTF to use Aws Secret Manager +### Setup MFTF to use AWS Secrets Manager -To use Aws Secret Manager, the Aws region to connect to is required. You can set it through environment variable [`CREDENTIAL_AWS_SECRET_MANAGER_REGION`][] in `.env`. +To use AWS Secrets Manager, the AWS region to connect to is required. You can set it through environment variable [`CREDENTIAL_AWS_SECRETS_MANAGER_REGION`][] in `.env`. -MFTF uses the recommended [Default Credential Provider Chain][credential chain] to establish connection to Aws Secret Manager service. +MFTF uses the recommended [Default Credential Provider Chain][credential chain] to establish connection to AWS Secrets Manager service. You can setup credentials according to [Default Credential Provider Chain][credential chain] and there is no MFTF specific setup required. -Optionally, however, you can explicitly set Aws profile through environment variable [`CREDENTIAL_AWS_SECRET_MANAGER_PROFILE`][] in `.env`. +Optionally, however, you can explicitly set AWS profile through environment variable [`CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE`][] in `.env`. ```conf -# Sample Aws Secret Manager configuration -CREDENTIAL_AWS_SECRET_MANAGER_REGION=us-east-1 -CREDENTIAL_AWS_SECRET_MANAGER_PROFILE=default +# Sample AWS Secrets Manager configuration +CREDENTIAL_AWS_SECRETS_MANAGER_REGION=us-east-1 +CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default ``` ## Configure multiple credential storage @@ -192,7 +192,7 @@ It is possible and sometimes useful to setup and use multiple credential storage In this case, the MFTF tests are able to read secret data at runtime from all storage options, in this case MFTF use the following precedence: ``` -.credentials File > HashiCorp Vault > Aws Secret Manager +.credentials File > HashiCorp Vault > AWS Secrets Manager ``` @@ -238,5 +238,5 @@ The MFTF tests delivered with Magento application do not use credentials and do [`CREDENTIAL_VAULT_ADDRESS`]: configuration.md#credential_vault_address [`CREDENTIAL_VAULT_SECRET_BASE_PATH`]: configuration.md#credential_vault_secret_base_path [credential chain]: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html -[`CREDENTIAL_AWS_SECRET_MANAGER_PROFILE`]: configuration.md#credential_aws_secret_manager_profile -[`CREDENTIAL_AWS_SECRET_MANAGER_REGION`]: configuration.md#credential_aws_secret_manager_region \ No newline at end of file +[`CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE`]: configuration.md#credential_aws_secrets_manager_profile +[`CREDENTIAL_AWS_SECRETS_MANAGER_REGION`]: configuration.md#credential_aws_secrets_manager_region \ No newline at end of file diff --git a/etc/config/.env.example b/etc/config/.env.example index a772b1e9e..f5b6ef40e 100644 --- a/etc/config/.env.example +++ b/etc/config/.env.example @@ -34,9 +34,9 @@ BROWSER=chrome #CREDENTIAL_VAULT_ADDRESS=http://127.0.0.1:8200 #CREDENTIAL_VAULT_SECRET_BASE_PATH=secret -#*** To use AWS Secret Manager to manage _CREDS secrets, uncomment and set region, profile is optional, when omitted, AWS default credential provider chain will be used ***# -#CREDENTIAL_AWS_SECRET_MANAGER_PROFILE=default -#CREDENTIAL_AWS_SECRET_MANAGER_REGION=us-east-1 +#*** To use AWS Secrets Manager to manage _CREDS secrets, uncomment and set region, profile is optional, when omitted, AWS default credential provider chain will be used ***# +#CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default +#CREDENTIAL_AWS_SECRETS_MANAGER_REGION=us-east-1 #*** Uncomment these properties to set up a dev environment with symlinked projects ***# #TESTS_BP= diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php index bff3e9b00..76560bcf1 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php @@ -9,17 +9,17 @@ use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\FileStorage; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\VaultStorage; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\AwsSecretManagerStorage; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\AwsSecretsManagerStorage; use Magento\FunctionalTestingFramework\Util\Path\UrlFormatter; class CredentialStore { const ARRAY_KEY_FOR_VAULT = 'vault'; const ARRAY_KEY_FOR_FILE = 'file'; - const ARRAY_KEY_FOR_AWS_SECRET_MANAGER = 'aws'; + const ARRAY_KEY_FOR_AWS_SECRETS_MANAGER = 'aws'; const CREDENTIAL_STORAGE_INFO = 'MFTF uses Credential Storage in the following precedence: ' - . '.credentials file, HashiCorp Vault and AWS Secret Manager. ' + . '.credentials file, HashiCorp Vault and AWS Secrets Manager. ' . 'You need to configure at least one to use _CREDS in tests.'; /** @@ -77,15 +77,15 @@ private function __construct() } } - // Initialize AWS secret manager storage - $awsRegion = getenv('CREDENTIAL_AWS_SECRET_MANAGER_REGION'); - $awsProfile = getenv('CREDENTIAL_AWS_SECRET_MANAGER_PROFILE'); + // Initialize AWS Secrets Manager storage + $awsRegion = getenv('CREDENTIAL_AWS_SECRETS_MANAGER_REGION'); + $awsProfile = getenv('CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE'); if ($awsRegion !== false) { if ($awsProfile === false) { $awsProfile = null; } try { - $this->credStorage[self::ARRAY_KEY_FOR_AWS_SECRET_MANAGER] = new AwsSecretManagerStorage( + $this->credStorage[self::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER] = new AwsSecretsManagerStorage( $awsRegion, $awsProfile ); @@ -109,8 +109,8 @@ private function __construct() */ public function getSecret($key) { - // Get secret data from storage according to the order they are stored - // File storage is preferred over vault storage to allow local secret value overriding remote secret value + // Get secret data from storage according to the order they are stored which follows this precedence: + // FileStorage > VaultStorage > AwsSecretsManagerStorage foreach ($this->credStorage as $storage) { $value = $storage->getEncryptedValue($key); if (null !== $value) { diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php similarity index 75% rename from src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php rename to src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php index 0c10c53c4..e7a858254 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretManagerStorage.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php @@ -15,7 +15,7 @@ use InvalidArgumentException; use Exception; -class AwsSecretManagerStorage extends BaseStorage +class AwsSecretsManagerStorage extends BaseStorage { /** * Mftf project path @@ -23,7 +23,7 @@ class AwsSecretManagerStorage extends BaseStorage const MFTF_PATH = 'mftf'; /** - * AWS Secret Manager version + * AWS Secrets Manager version * * Last tested version '2017-10-17' */ @@ -37,7 +37,7 @@ class AwsSecretManagerStorage extends BaseStorage private $client = null; /** - * AwsSecretManagerStorage constructor + * AwsSecretsManagerStorage constructor * * @param string $region * @param string $profile @@ -47,7 +47,7 @@ class AwsSecretManagerStorage extends BaseStorage public function __construct($region, $profile = null) { parent::__construct(); - $this->createAwsSecretManagerClient($region, $profile); + $this->createAwsSecretsManagerClient($region, $profile); } /** @@ -65,8 +65,8 @@ public function getEncryptedValue($key) } if (MftfApplicationConfig::getConfig()->verboseEnabled()) { - LoggingUtil::getInstance()->getLogger(VaultStorage::class)->debug( - "Retrieving secret for key name {$key} from AWS Secret Manager" + LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug( + "Retrieving value for key name {$key} from AWS Secrets Manager" ); } @@ -79,7 +79,7 @@ public function getEncryptedValue($key) . $vendor . '/' . $key; - // Read value by id from AWS Secret Manager, and parse the result + // Read value by id from AWS Secrets Manager, and parse the result $value = $this->parseAwsSecretResult( $this->client->getSecretValue(['SecretId' => $secretId]), $key @@ -90,14 +90,14 @@ public function getEncryptedValue($key) } catch (AwsException $e) { $error = $e->getAwsErrorCode(); if (MftfApplicationConfig::getConfig()->verboseEnabled()) { - LoggingUtil::getInstance()->getLogger(VaultStorage::class)->debug( - "AWS error code: {$error}. Unable to read secret for key {$key} from AWS Secret Manager" + LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug( + "AWS error code: {$error}. Unable to read value for key {$key} from AWS Secrets Manager" ); } } catch (\Exception $e) { if (MftfApplicationConfig::getConfig()->verboseEnabled()) { - LoggingUtil::getInstance()->getLogger(VaultStorage::class)->debug( - "Unable to read secret for key {$key} from AWS Secret Manager" + LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug( + "Unable to read value for key {$key} from AWS Secrets Manager" ); } } @@ -118,17 +118,17 @@ private function parseAwsSecretResult($awsResult, $key) if (isset($awsResult['SecretString'])) { $rawSecret = $awsResult['SecretString']; } else { - throw new TestFrameworkException("Error parsing AWS secret result"); + throw new TestFrameworkException("Error parsing result from AWS Secrets Manager"); } $secret = json_decode($rawSecret, true); if (isset($secret[$key])) { return $secret[$key]; } - throw new TestFrameworkException("Error parsing AWS secret result"); + throw new TestFrameworkException("Error parsing result from AWS Secrets Manager"); } /** - * Create Aws Secret Manager client + * Create Aws Secrets Manager client * * @param string $region * @param string $profile @@ -136,13 +136,13 @@ private function parseAwsSecretResult($awsResult, $key) * @throws TestFrameworkException * @throws InvalidArgumentException */ - private function createAwsSecretManagerClient($region, $profile) + private function createAwsSecretsManagerClient($region, $profile) { if (null !== $this->client) { return; } - // Create AWS Secret Manager client + // Create AWS Secrets Manager client $this->client = new SecretsManagerClient([ 'profile' => $profile, 'region' => $region, @@ -150,7 +150,7 @@ private function createAwsSecretManagerClient($region, $profile) ]); if ($this->client === null) { - throw new TestFrameworkException("Unable to create AWS Secret Manager client"); + throw new TestFrameworkException("Unable to create AWS Secrets Manager client"); } } } From bb62cfe317f88c7e18df7039d72c2bbbb78b1bf9 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 15 Jan 2020 10:07:44 -0600 Subject: [PATCH 38/67] MQE-1918: MFTF AWS Secrets Manager - Local Use --- .../DataGenerator/Handlers/CredentialStore.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php index 76560bcf1..84d58ade8 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php @@ -18,9 +18,8 @@ class CredentialStore const ARRAY_KEY_FOR_FILE = 'file'; const ARRAY_KEY_FOR_AWS_SECRETS_MANAGER = 'aws'; - const CREDENTIAL_STORAGE_INFO = 'MFTF uses Credential Storage in the following precedence: ' - . '.credentials file, HashiCorp Vault and AWS Secrets Manager. ' - . 'You need to configure at least one to use _CREDS in tests.'; + const CREDENTIAL_STORAGE_INFO = 'You need to configure at least one of these options: ' + . '.credentials file, HashiCorp Vault or AWS Secrets Manager correctly'; /** * Credential storage array @@ -95,7 +94,7 @@ private function __construct() if (empty($this->credStorage)) { throw new TestFrameworkException( - 'Invalid Credential Storage. ' . self::CREDENTIAL_STORAGE_INFO + 'Invalid Credential Storage. ' . self::CREDENTIAL_STORAGE_INFO . '.' ); } } @@ -119,7 +118,8 @@ public function getSecret($key) } throw new TestFrameworkException( - "{$key} not found. " . self::CREDENTIAL_STORAGE_INFO . ' And make sure key/value exists.' + "{$key} not found. " . self::CREDENTIAL_STORAGE_INFO + . ' and ensure key, value exists to use _CREDS in tests.' ); } From 350e8967cb971623f40c1b73d46230c1e5c47498 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 15 Jan 2020 11:59:56 -0600 Subject: [PATCH 39/67] MQE-1761: Allure reporting error for multiple suite run --- .../Console/RunTestGroupCommand.php | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php index 98d121d40..2c7aee1c1 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php @@ -94,21 +94,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int $command->run(new ArrayInput($args), $output); } - $codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional --verbose --steps'; + $commandString = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional --verbose --steps'; + $exitCode = -1; + $returnCodes = []; foreach ($groups as $group) { - $codeceptionCommand .= " -g {$group}"; - } + $codeceptionCommandString = $commandString . " -g {$group}"; + + $process = new Process($codeceptionCommandString); + $process->setWorkingDirectory(TESTS_BP); + $process->setIdleTimeout(600); + $process->setTimeout(0); - $process = new Process($codeceptionCommand); - $process->setWorkingDirectory(TESTS_BP); - $process->setIdleTimeout(600); - $process->setTimeout(0); + $returnCodes[] = $process->run( + function ($type, $buffer) use ($output) { + $output->write($buffer); + } + ); + } - return $process->run( - function ($type, $buffer) use ($output) { - $output->write($buffer); + foreach ($returnCodes as $returnCode) { + if ($returnCode != 0) { + return $returnCode; } - ); + $exitCode = 0; + } + return $exitCode; + } } From eb68e89b195ba6eec1a511f06623332938fd7780 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 15 Jan 2020 12:16:37 -0600 Subject: [PATCH 40/67] MQE-1761: Allure reporting error for multiple suite run --- .../FunctionalTestingFramework/Console/RunTestGroupCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php index 2c7aee1c1..6ea37785d 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php @@ -120,6 +120,5 @@ function ($type, $buffer) use ($output) { $exitCode = 0; } return $exitCode; - } } From 9a1fdd1530b8005dd2cf8f3d62edab612330adb9 Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Thu, 16 Jan 2020 16:02:52 -0600 Subject: [PATCH 41/67] MQE-1919: MFTF AWS Secrets Manager - CI Use --- etc/config/.env.example | 2 ++ .../Handlers/CredentialStore.php | 7 ++++- .../AwsSecretsManagerStorage.php | 31 +++++++++++++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/etc/config/.env.example b/etc/config/.env.example index f5b6ef40e..7f988c9f0 100644 --- a/etc/config/.env.example +++ b/etc/config/.env.example @@ -37,6 +37,8 @@ BROWSER=chrome #*** To use AWS Secrets Manager to manage _CREDS secrets, uncomment and set region, profile is optional, when omitted, AWS default credential provider chain will be used ***# #CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default #CREDENTIAL_AWS_SECRETS_MANAGER_REGION=us-east-1 +#*** If using non-default AWS account ***# +#CREDENTIAL_AWS_ACCOUNT_ID= #*** Uncomment these properties to set up a dev environment with symlinked projects ***# #TESTS_BP= diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php index 84d58ade8..7769decc6 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php @@ -79,14 +79,19 @@ private function __construct() // Initialize AWS Secrets Manager storage $awsRegion = getenv('CREDENTIAL_AWS_SECRETS_MANAGER_REGION'); $awsProfile = getenv('CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE'); + $awsId = getenv('CREDENTIAL_AWS_ACCOUNT_ID'); if ($awsRegion !== false) { if ($awsProfile === false) { $awsProfile = null; } + if ($awsId === false) { + $awsId = null; + } try { $this->credStorage[self::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER] = new AwsSecretsManagerStorage( $awsRegion, - $awsProfile + $awsProfile, + $awsId ); } catch (TestFrameworkException $e) { } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php index e7a858254..1e58e3bee 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php @@ -22,6 +22,11 @@ class AwsSecretsManagerStorage extends BaseStorage */ const MFTF_PATH = 'mftf'; + /** + * AWS Secrets Manager partial ARN + */ + const AWS_SM_PARTIAL_ARN = 'arn:aws:secretsmanager:'; + /** * AWS Secrets Manager version * @@ -36,18 +41,35 @@ class AwsSecretsManagerStorage extends BaseStorage */ private $client = null; + /** + * AWS account id + * + * @var string + */ + private $awsAccountId; + + /** + * AWS account region + * + * @var string + */ + private $region; + /** * AwsSecretsManagerStorage constructor * * @param string $region * @param string $profile + * @param string $accountId * @throws TestFrameworkException * @throws InvalidArgumentException */ - public function __construct($region, $profile = null) + public function __construct($region, $profile = null, $accountId = null) { parent::__construct(); $this->createAwsSecretsManagerClient($region, $profile); + $this->region = $region; + $this->awsAccountId = $accountId; } /** @@ -74,7 +96,12 @@ public function getEncryptedValue($key) try { // Split vendor/key to construct secret id list($vendor, $key) = explode('/', trim($key, '/'), 2); - $secretId = self::MFTF_PATH + // If AWS account id is specified, create and use full ARN, otherwise use partial ARN as secret id + $secretId = ''; + if (!empty($this->awsAccountId)) { + $secretId = self::AWS_SM_PARTIAL_ARN . $this->region . ':' . $this->awsAccountId . ':secret:'; + } + $secretId .= self::MFTF_PATH . '/' . $vendor . '/' From 458bddd9046070173dd23e1746b829c40862b694 Mon Sep 17 00:00:00 2001 From: Ajith Date: Mon, 20 Jan 2020 14:52:02 +0530 Subject: [PATCH 42/67] Remove extra spaces --- docs/extending.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/extending.md b/docs/extending.md index 91dc97c5d..5ebd5ab27 100644 --- a/docs/extending.md +++ b/docs/extending.md @@ -26,7 +26,7 @@ __Use case__: Create two similar tests with different `url` (`"{{AdminCategoryPa > Test with "extends": ```xml - + ... @@ -47,7 +47,7 @@ __Use case__: Create two similar tests with different `url` (`"{{AdminCategoryPa > Test without "extends": ```xml - + ... @@ -77,7 +77,7 @@ __Use case__: Create two similar tests where the second test contains two additi > Tests with "extends": ```xml - + @@ -95,7 +95,7 @@ __Use case__: Create two similar tests where the second test contains two additi > Tests without "extends": ```xml - + @@ -125,7 +125,7 @@ __Use case__: Create two similar tests where the second one contains two additio > Tests with "extends": ```xml - + @@ -147,7 +147,7 @@ __Use case__: Create two similar tests where the second one contains two additio > Tests without "extends": ```xml - + From eb7b6a3f59645bcb427ba749fc7e34f8e5899360 Mon Sep 17 00:00:00 2001 From: Ajith Date: Tue, 21 Jan 2020 07:16:37 +0530 Subject: [PATCH 43/67] Remove extra spaces --- docs/extending.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/extending.md b/docs/extending.md index 5ebd5ab27..064ed3208 100644 --- a/docs/extending.md +++ b/docs/extending.md @@ -295,7 +295,7 @@ __Use case__: Create an entity named `DivPanelGreen`, which is similar to the `D > Entities with "extends": ```xml - + Red 80px @@ -310,7 +310,7 @@ __Use case__: Create an entity named `DivPanelGreen`, which is similar to the `D > Entities without "extends": ```xml - + Red 80px @@ -331,7 +331,7 @@ __Use case__: Create an entity named `DivPanelGreen`, which is similar to the `D > Entities with "extends": ```xml - + Red 80px @@ -347,7 +347,7 @@ __Use case__: Create an entity named `DivPanelGreen`, which is similar to the `D > Entities without "extends": ```xml - + Red 80px From 93e221c4a99db73a129d05b3fd203942022617dc Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Tue, 21 Jan 2020 11:14:56 -0600 Subject: [PATCH 44/67] MQE-1919: MFTF AWS Secrets Manager - CI Use --- docs/credentials.md | 64 ++++++++--- etc/config/.env.example | 2 - .../Handlers/CredentialStore.php | 107 +++++++++++------- .../AwsSecretsManagerStorage.php | 42 ++++--- 4 files changed, 145 insertions(+), 70 deletions(-) diff --git a/docs/credentials.md b/docs/credentials.md index 4b20e68dc..1ea91a5c3 100644 --- a/docs/credentials.md +++ b/docs/credentials.md @@ -144,32 +144,54 @@ AWS Secrets Manager offers secret management that supports: - Audit secret rotation centrally for resources in the AWS Cloud, third-party services, and on-premises ### Prerequisites -- AWS account -- AWS Secrets Manger is created and configured + +#### Use AWS Secrets Manager from your own AWS account + +- AWS account with Secrets Manager service available - IAM User or Role is created with appropriate AWS Secrets Manger access permission +#### Use AWS Secrets Manager from other AWS account + +- AWS account ID where the AWS Secrets Manager service is hosted +- IAM User or Role with appropriate access permission + ### Store secrets in AWS Secrets Manager + #### Secrets format -`Secret Name`, `Secret Key`, `Secret Value` are three key pieces of information to construct an AWS Secret. -`Secret Key` and `Secret Value` can be any content you want to secure, `Secret Name` must follow the format: + +`Secret Name` and `Secret Value` are two key pieces of information for creating a secret. + +`Secret Value` can be either plaintext or key/value pairs in JSON format. + +`Secrets Name` must use the following format: ```conf -mftf// +mftf// ``` -```conf -# Secret name for carriers_usps_userid -mftf/magento/carriers_usps_userid +`Secrets Value` in plaintext format can be any content you want to secure. `Secrets Value` in key/value pairs format, however, the `key` must be same as the `Secret Name` with `mftf//` part removed. +e.g. in above example, `key` should be `` + +##### Create Secrets using AWS CLI -# Secret key for carriers_usps_userid -carriers_usps_userid +```bash +aws secretsmanager create-secret --name "mftf/magento/shipping/carriers_usps_userid" --description "Carriers USPS user id" --secret-string "1234567" +``` + +##### Create Secrets using AWS Console + +To save the same secret in key/value JSON format, you should use + +```conf +# Secret Name +mftf/magento/shipping/carriers_usps_userid -# Secret name for carriers_usps_password -mftf/magento/carriers_usps_password +# Secret Key +shipping/carriers_usps_userid -# Secret key for carriers_usps_password -carriers_usps_password +# Secret Value +1234567 ``` ### Setup MFTF to use AWS Secrets Manager @@ -186,6 +208,16 @@ CREDENTIAL_AWS_SECRETS_MANAGER_REGION=us-east-1 CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default ``` +### Optionally set CREDENTIAL_AWS_ACCOUNT_ID environment variable + +Full AWS KMS ([Key Management Service][]) key ARN ([Amazon Resource Name][]) is required when accessing secrets stored in other AWS account. +If this is the case, you will also need to set `CREDENTIAL_AWS_ACCOUNT_ID` environment variable so that MFTF can construct the full ARN. +This is also commonly used in CI system. + +```bash +export CREDENTIAL_AWS_ACCOUNT_ID= +``` + ## Configure multiple credential storage It is possible and sometimes useful to setup and use multiple credential storage at the same time. @@ -239,4 +271,6 @@ The MFTF tests delivered with Magento application do not use credentials and do [`CREDENTIAL_VAULT_SECRET_BASE_PATH`]: configuration.md#credential_vault_secret_base_path [credential chain]: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html [`CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE`]: configuration.md#credential_aws_secrets_manager_profile -[`CREDENTIAL_AWS_SECRETS_MANAGER_REGION`]: configuration.md#credential_aws_secrets_manager_region \ No newline at end of file +[`CREDENTIAL_AWS_SECRETS_MANAGER_REGION`]: configuration.md#credential_aws_secrets_manager_region +[Key Management Service]: https://aws.amazon.com/kms/ +[Amazon Resource Name]: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html \ No newline at end of file diff --git a/etc/config/.env.example b/etc/config/.env.example index 7f988c9f0..f5b6ef40e 100644 --- a/etc/config/.env.example +++ b/etc/config/.env.example @@ -37,8 +37,6 @@ BROWSER=chrome #*** To use AWS Secrets Manager to manage _CREDS secrets, uncomment and set region, profile is optional, when omitted, AWS default credential provider chain will be used ***# #CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default #CREDENTIAL_AWS_SECRETS_MANAGER_REGION=us-east-1 -#*** If using non-default AWS account ***# -#CREDENTIAL_AWS_ACCOUNT_ID= #*** Uncomment these properties to set up a dev environment with symlinked projects ***# #TESTS_BP= diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php index 7769decc6..b66d19799 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php @@ -57,45 +57,10 @@ public static function getInstance() */ private function __construct() { - // Initialize file storage - try { - $this->credStorage[self::ARRAY_KEY_FOR_FILE] = new FileStorage(); - } catch (TestFrameworkException $e) { - } - - // Initialize vault storage - $cvAddress = getenv('CREDENTIAL_VAULT_ADDRESS'); - $cvSecretPath = getenv('CREDENTIAL_VAULT_SECRET_BASE_PATH'); - if ($cvAddress !== false && $cvSecretPath !== false) { - try { - $this->credStorage[self::ARRAY_KEY_FOR_VAULT] = new VaultStorage( - UrlFormatter::format($cvAddress, false), - '/' . trim($cvSecretPath, '/') - ); - } catch (TestFrameworkException $e) { - } - } - - // Initialize AWS Secrets Manager storage - $awsRegion = getenv('CREDENTIAL_AWS_SECRETS_MANAGER_REGION'); - $awsProfile = getenv('CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE'); - $awsId = getenv('CREDENTIAL_AWS_ACCOUNT_ID'); - if ($awsRegion !== false) { - if ($awsProfile === false) { - $awsProfile = null; - } - if ($awsId === false) { - $awsId = null; - } - try { - $this->credStorage[self::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER] = new AwsSecretsManagerStorage( - $awsRegion, - $awsProfile, - $awsId - ); - } catch (TestFrameworkException $e) { - } - } + // Initialize credential storage by defined order of precedence as the following + $this->initializeFileStorage(); + $this->initializeVaultStorage(); + $this->initializeAwsSecretsManagerStorage(); if (empty($this->credStorage)) { throw new TestFrameworkException( @@ -155,4 +120,68 @@ public function decryptAllSecretsInString($string) return $storage->getAllDecryptedValuesInString($string); } } + + /** + * Initialize file storage + * + * @return void + */ + private function initializeFileStorage() + { + // Initialize file storage + try { + $this->credStorage[self::ARRAY_KEY_FOR_FILE] = new FileStorage(); + } catch (TestFrameworkException $e) { + } + } + + /** + * Initialize Vault storage + * + * @return void + */ + private function initializeVaultStorage() + { + // Initialize vault storage + $cvAddress = getenv('CREDENTIAL_VAULT_ADDRESS'); + $cvSecretPath = getenv('CREDENTIAL_VAULT_SECRET_BASE_PATH'); + if ($cvAddress !== false && $cvSecretPath !== false) { + try { + $this->credStorage[self::ARRAY_KEY_FOR_VAULT] = new VaultStorage( + UrlFormatter::format($cvAddress, false), + '/' . trim($cvSecretPath, '/') + ); + } catch (TestFrameworkException $e) { + } + } + } + + /** + * Initialize AWS Secrets Manager storage + * + * @return void + */ + private function initializeAwsSecretsManagerStorage() + { + // Initialize AWS Secrets Manager storage + $awsRegion = getenv('CREDENTIAL_AWS_SECRETS_MANAGER_REGION'); + $awsProfile = getenv('CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE'); + $awsId = getenv('CREDENTIAL_AWS_ACCOUNT_ID'); + if (!empty($awsRegion)) { + if (empty($awsProfile)) { + $awsProfile = null; + } + if (empty($awsId)) { + $awsId = null; + } + try { + $this->credStorage[self::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER] = new AwsSecretsManagerStorage( + $awsRegion, + $awsProfile, + $awsId + ); + } catch (TestFrameworkException $e) { + } + } + } } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php index 1e58e3bee..bb6044c7f 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php @@ -115,17 +115,18 @@ public function getEncryptedValue($key) $reValue = openssl_encrypt($value, parent::ENCRYPTION_ALGO, parent::$encodedKey, 0, parent::$iv); parent::$cachedSecretData[$key] = $reValue; } catch (AwsException $e) { - $error = $e->getAwsErrorCode(); + $errMessage = "\nAWS Exception:\n" . $e->getAwsErrorMessage() + . "\nUnable to read value for key {$key} from AWS Secrets Manager\n"; + print_r($errMessage); if (MftfApplicationConfig::getConfig()->verboseEnabled()) { - LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug( - "AWS error code: {$error}. Unable to read value for key {$key} from AWS Secrets Manager" - ); + LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug($errMessage); } } catch (\Exception $e) { + $errMessage = "\nException:\n" . $e->getMessage() + . "\nUnable to read value for key {$key} from AWS Secrets Manager\n"; + print_r($errMessage); if (MftfApplicationConfig::getConfig()->verboseEnabled()) { - LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug( - "Unable to read value for key {$key} from AWS Secrets Manager" - ); + LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug($errMessage); } } return $reValue; @@ -145,13 +146,22 @@ private function parseAwsSecretResult($awsResult, $key) if (isset($awsResult['SecretString'])) { $rawSecret = $awsResult['SecretString']; } else { - throw new TestFrameworkException("Error parsing result from AWS Secrets Manager"); + throw new TestFrameworkException( + "'SecretString' field is not set in AWS Result. Error parsing result from AWS Secrets Manager" + ); } + + // Secrets are saved as JSON structures of key/value pairs if using AWS Secrets Manager console, and + // Secrets are saved as plain text if using AWS CLI. We need to handle both cases. $secret = json_decode($rawSecret, true); if (isset($secret[$key])) { return $secret[$key]; + } elseif (is_string($rawSecret)) { + return $rawSecret; } - throw new TestFrameworkException("Error parsing result from AWS Secrets Manager"); + throw new TestFrameworkException( + "$key not found or value is not string . Error parsing result from AWS Secrets Manager" + ); } /** @@ -169,13 +179,17 @@ private function createAwsSecretsManagerClient($region, $profile) return; } - // Create AWS Secrets Manager client - $this->client = new SecretsManagerClient([ - 'profile' => $profile, + $options = [ 'region' => $region, - 'version' => self::LATEST_VERSION - ]); + 'version' => self::LATEST_VERSION, + ]; + if (!empty($profile)) { + $options['profile'] = $profile; + } + + // Create AWS Secrets Manager client + $this->client = new SecretsManagerClient($options); if ($this->client === null) { throw new TestFrameworkException("Unable to create AWS Secrets Manager client"); } From 0331f7eec902b9c04780129c905b30e0416abf2f Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Wed, 22 Jan 2020 09:01:30 -0600 Subject: [PATCH 45/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments --- .../StaticCheck/StaticChecksList.php | 1 + .../StaticCheck/UnusedArgumentsCheck.php | 212 ++++++++++++++++++ .../Handlers/ActionGroupObjectHandler.php | 5 +- 3 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php index f3cf20739..83f06225e 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php @@ -29,6 +29,7 @@ public function __construct(array $checks = []) { $this->checks = [ 'testDependencies' => new TestDependencyCheck(), + 'unusedArgumentsCheck' => new UnusedArgumentsCheck(), ] + $checks; } diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php new file mode 100644 index 000000000..0dc74171c --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php @@ -0,0 +1,212 @@ +initActionGroups(); + + $unusedArgumentList = $this->buildUnusedArgumentList($actionGroups); + + $this->errors += $this->setErrorOutput($unusedArgumentList); + + $this->output = $this->printErrorsToFile(); + + } + + /** + * Return array containing all errors found after running the execute() function. + * @return array + */ + public function getErrors() + { + return $this->errors; + } + + /** + * Return string of a short human readable result of the check. For example: "No unused arguments found." + * @return string + */ + public function getOutput() + { + return $this->output; + } + + /** + * Builds array of action groups => unused arguments + * @param $actionGroups + * @return array + */ + private function buildUnusedArgumentList($actionGroups) { + + $actionGroupToArguments = []; + + foreach ($actionGroups as $actionGroup) { + $unusedArguments = $this->findUnusedArguments($actionGroup); + if(!empty($unusedArguments)) { + $actionGroupToArguments[$actionGroup->getFilename()][$actionGroup->getName()] = $unusedArguments; + } + } + return $actionGroupToArguments; + } + + /** + * Returns unused arguments in an action group. + * @param $actionGroup + * @return array + */ + private function findUnusedArguments($actionGroup) { + + $unusedArguments = []; + //extract all action attribute values + $actionAttributeValues = $this->getAllActionAttributeValues($actionGroup); + $argumentList = $actionGroup->getArguments(); + foreach ($argumentList as $argument) { + $argumentName = $argument->getName(); + //pattern to match all argument references + $pattern = '(.*\.*[\W]+(?getName(); + } + return $unusedArguments; + } + + /** + * Returns array of all action attribute values in an action group. + * @param $actionGroup + * @return array + */ + private function getAllActionAttributeValues($actionGroup) { + + $allAttributeValues = []; + $actions = $actionGroup->getActions(); + foreach ($actions as $action) { + $actionAttributeValues = $this->extractAttributeValues($action); + $allAttributeValues = array_merge($allAttributeValues, $actionAttributeValues); + } + return array_unique($allAttributeValues); + } + + + /** + * Builds and returns flattened attribute value list for an action. + * @param $action + * @return array + */ + private function extractAttributeValues($action) { + + $flattenedAttributeValues = []; + $actionAttributes = $action->getCustomActionAttributes(); + //check if action has nodes eg. expectedResult, actualResult and flatten array + foreach ($actionAttributes as $attributeName => $attributeValue) { + if (is_array($attributeValue)) { + $flattenedAttributeValues = array_merge($flattenedAttributeValues, array_values($attributeValue)); + } + else { + $flattenedAttributeValues[] = $attributeValue; + } + } + return $flattenedAttributeValues; + } + + /** + * Builds and returns error output for unused arguments + * + * @param array $unusedArgumentList + * @return mixed + */ + private function setErrorOutput($unusedArgumentList) + { + $testErrors = []; + + if (!empty($unusedArgumentList)) { + // Build error output + foreach ($unusedArgumentList as $path => $actionGroupToArguments) { + + $errorOutput = "\nFile \"{$path}\""; + $errorOutput .= "\ncontains action group(s) with unused arguments.\n\t\t"; + + foreach ($actionGroupToArguments as $actionGroup => $arguments) { + $errorOutput .= "\n\t {$actionGroup} has unused argument(s): " . implode(", ", $arguments); + } + $testErrors[$path][] = $errorOutput; + } + } + return $testErrors; + } + + /** + * Prints out given errors to file, and returns summary result string + * @return string + */ + private function printErrorsToFile() + { + $errors = $this->getErrors(); + + if (empty($errors)) { + return "No unused arguments found."; + } + + $outputPath = getcwd() . DIRECTORY_SEPARATOR . "mftf-arguments-checks.txt"; + $fileResource = fopen($outputPath, 'w'); + $header = "MFTF ActionGroup Arguments Check:\n"; + fwrite($fileResource, $header); + + foreach ($errors as $test => $error) { + fwrite($fileResource, $error[0] . PHP_EOL); + } + + fclose($fileResource); + $errorCount = count($errors); + $output = "Unused arguments found across {$errorCount} actionGroup(s). Error details output to {$outputPath}"; + + return $output; + } + +} diff --git a/src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php b/src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php index 131ae0a26..91f1f2b0d 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php @@ -99,10 +99,10 @@ public function getAllObjects(): array /** * Method which populates field array with objects from parsed action_group.xml * - * @return void + * @return array * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ - private function initActionGroups() + public function initActionGroups() { $actionGroupParser = ObjectManagerFactory::getObjectManager()->create(ActionGroupDataParser::class); $parsedActionGroups = $actionGroupParser->readActionGroupData(); @@ -118,6 +118,7 @@ private function initActionGroups() $this->actionGroups[$actionGroupName] = $actionGroupObjectExtractor->extractActionGroup($actionGroupData); } + return $this->actionGroups; } /** From 4a4fc38df8dc59f10a3ee2228a04f8ebad238685 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Wed, 22 Jan 2020 10:59:29 -0600 Subject: [PATCH 46/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments modified regex, merged develop, fixed static checks --- .../StaticCheck/UnusedArgumentsCheck.php | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php index 0dc74171c..ffec45487 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php @@ -8,6 +8,8 @@ use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; use Magento\FunctionalTestingFramework\Test\Handlers\ActionGroupObjectHandler; +use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; +use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; use Symfony\Component\Console\Input\InputInterface; use Exception; @@ -35,7 +37,7 @@ class UnusedArgumentsCheck implements StaticCheckInterface * Checks unused arguments in action groups and prints out error to file. * * @param InputInterface $input - * @return string + * @return void * @throws Exception; */ public function execute(InputInterface $input) @@ -55,7 +57,6 @@ public function execute(InputInterface $input) $this->errors += $this->setErrorOutput($unusedArgumentList); $this->output = $this->printErrorsToFile(); - } /** @@ -78,16 +79,16 @@ public function getOutput() /** * Builds array of action groups => unused arguments - * @param $actionGroups - * @return array + * @param array $actionGroups + * @return array $actionGroupToArguments */ - private function buildUnusedArgumentList($actionGroups) { - + private function buildUnusedArgumentList($actionGroups) + { $actionGroupToArguments = []; foreach ($actionGroups as $actionGroup) { $unusedArguments = $this->findUnusedArguments($actionGroup); - if(!empty($unusedArguments)) { + if (!empty($unusedArguments)) { $actionGroupToArguments[$actionGroup->getFilename()][$actionGroup->getName()] = $unusedArguments; } } @@ -96,11 +97,11 @@ private function buildUnusedArgumentList($actionGroups) { /** * Returns unused arguments in an action group. - * @param $actionGroup - * @return array + * @param ActionGroupObject $actionGroup + * @return array $unusedArguments */ - private function findUnusedArguments($actionGroup) { - + private function findUnusedArguments($actionGroup) + { $unusedArguments = []; //extract all action attribute values $actionAttributeValues = $this->getAllActionAttributeValues($actionGroup); @@ -108,7 +109,7 @@ private function findUnusedArguments($actionGroup) { foreach ($argumentList as $argument) { $argumentName = $argument->getName(); //pattern to match all argument references - $pattern = '(.*\.*[\W]+(?getActions(); foreach ($actions as $action) { @@ -133,22 +134,20 @@ private function getAllActionAttributeValues($actionGroup) { return array_unique($allAttributeValues); } - /** * Builds and returns flattened attribute value list for an action. - * @param $action - * @return array + * @param ActionObject $action + * @return array $flattenedAttributeValues */ - private function extractAttributeValues($action) { - + private function extractAttributeValues($action) + { $flattenedAttributeValues = []; $actionAttributes = $action->getCustomActionAttributes(); //check if action has nodes eg. expectedResult, actualResult and flatten array foreach ($actionAttributes as $attributeName => $attributeValue) { if (is_array($attributeValue)) { $flattenedAttributeValues = array_merge($flattenedAttributeValues, array_values($attributeValue)); - } - else { + } else { $flattenedAttributeValues[] = $attributeValue; } } @@ -158,7 +157,7 @@ private function extractAttributeValues($action) { /** * Builds and returns error output for unused arguments * - * @param array $unusedArgumentList + * @param array $unusedArgumentList * @return mixed */ private function setErrorOutput($unusedArgumentList) @@ -168,7 +167,6 @@ private function setErrorOutput($unusedArgumentList) if (!empty($unusedArgumentList)) { // Build error output foreach ($unusedArgumentList as $path => $actionGroupToArguments) { - $errorOutput = "\nFile \"{$path}\""; $errorOutput .= "\ncontains action group(s) with unused arguments.\n\t\t"; @@ -208,5 +206,4 @@ private function printErrorsToFile() return $output; } - } From 58f0da61520522b01f3eadb2161fb4035bdc6435 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Wed, 22 Jan 2020 11:08:57 -0600 Subject: [PATCH 47/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments Documentation + fixed static checks --- docs/commands/mftf.md | 1 + .../StaticCheck/UnusedArgumentsCheck.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/commands/mftf.md b/docs/commands/mftf.md index 642bbb1bd..bb0cca3fb 100644 --- a/docs/commands/mftf.md +++ b/docs/commands/mftf.md @@ -468,6 +468,7 @@ Runs all MFTF static-checks on the test codebase that MFTF is currently attached #### Existing static checks * Test Dependency: Checks that test dependencies do not violate Magento module's composer dependencies. +* Unused Arguments: Checks that action groups do not have unused arguments. #### Usage diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php index ffec45487..b0a20959a 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php @@ -120,8 +120,8 @@ private function findUnusedArguments($actionGroup) /** * Returns array of all action attribute values in an action group. - * @param $actionGroup - * @return array + * @param ActionGroupObject $actionGroup + * @return array $allAttributeValues */ private function getAllActionAttributeValues($actionGroup) { From 9bd0651bb39ca7db68fb2a175fdda0c8bb5cac7b Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Wed, 22 Jan 2020 10:55:19 -0600 Subject: [PATCH 48/67] MQE-1959: Static-checks command can be configured --- docs/commands/mftf.md | 29 ++++++- .../Console/StaticChecksCommand.php | 82 +++++++++++++++++-- 2 files changed, 98 insertions(+), 13 deletions(-) diff --git a/docs/commands/mftf.md b/docs/commands/mftf.md index 642bbb1bd..cf1260b6a 100644 --- a/docs/commands/mftf.md +++ b/docs/commands/mftf.md @@ -463,18 +463,39 @@ The example parameters are taken from the `etc/config/.env.example` file. ### `static-checks` -Runs all MFTF static-checks on the test codebase that MFTF is currently attached to. +Runs all or specific MFTF static-checks on the test codebase that MFTF is currently attached to. +If no script name argument is specified, all existing static check scripts will run. -#### Existing static checks +#### Usage -* Test Dependency: Checks that test dependencies do not violate Magento module's composer dependencies. +```bash +vendor/bin/mftf static-checks []... +``` -#### Usage +#### Examples + +To check what existing static check scripts are available + +```bash +vendor/bin/mftf static-checks --help +``` + +To run all existing static check scripts ```bash vendor/bin/mftf static-checks ``` +To run specific static check scripts + +```bash +vendor/bin/mftf static-checks testDependencies +``` + +#### Existing static checks + +* Test Dependency: Checks that test dependencies do not violate Magento module's composer dependencies. + ### `upgrade:tests` Applies all the MFTF major version upgrade scripts to test components in the given path (`test.xml`, `data.xml`, etc). diff --git a/src/Magento/FunctionalTestingFramework/Console/StaticChecksCommand.php b/src/Magento/FunctionalTestingFramework/Console/StaticChecksCommand.php index 9757f494e..30c9cd600 100644 --- a/src/Magento/FunctionalTestingFramework/Console/StaticChecksCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/StaticChecksCommand.php @@ -8,10 +8,12 @@ namespace Magento\FunctionalTestingFramework\Console; +use Magento\FunctionalTestingFramework\StaticCheck\StaticCheckInterface; use Magento\FunctionalTestingFramework\StaticCheck\StaticChecksList; -use Magento\FunctionalTestingFramework\StaticCheck\StaticCheckListInterface; use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Exception\InvalidArgumentException; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Exception; @@ -19,11 +21,18 @@ class StaticChecksCommand extends Command { /** - * Pool of static check scripts to run + * Pool of all existing static check objects * - * @var StaticCheckListInterface + * @var StaticCheckInterface[] */ - private $staticChecksList; + private $allStaticCheckObjects; + + /** + * Static checks to run + * + * @var StaticCheckInterface[] + */ + private $staticCheckObjects; /** * Configures the current command. @@ -32,13 +41,22 @@ class StaticChecksCommand extends Command */ protected function configure() { + $list = new StaticChecksList(); + $this->allStaticCheckObjects = $list->getStaticChecks(); + $staticCheckNames = implode(', ', array_keys($this->allStaticCheckObjects)); + $description = "This command will run all static checks on xml test materials. " + . "Available static check scripts are:\n{$staticCheckNames}"; $this->setName('static-checks') - ->setDescription('This command will run all static checks on xml test materials.'); - $this->staticChecksList = new StaticChecksList(); + ->setDescription($description) + ->addArgument( + 'names', + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, + 'name(s) of specific static check script(s) to run' + ); } /** - * + * Run required static check scripts * * @param InputInterface $input * @param OutputInterface $output @@ -47,11 +65,23 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $staticCheckObjects = $this->staticChecksList->getStaticChecks(); + try { + $this->validateInputArguments($input, $output); + } catch (InvalidArgumentException $e) { + LoggingUtil::getInstance()->getLogger(StaticChecksCommand::class)->error($e->getMessage()); + $output->writeln($e->getMessage() . " Please fix input arguments and rerun."); + return 1; + } $errors = []; + foreach ($this->staticCheckObjects as $name => $staticCheck) { + LoggingUtil::getInstance()->getLogger(get_class($staticCheck))->info( + "\nRunning static check script for: " . $name + ); + $output->writeln( + "\nRunning static check script for: " . $name + ); - foreach ($staticCheckObjects as $staticCheck) { $staticCheck->execute($input); $staticOutput = $staticCheck->getOutput(); @@ -66,4 +96,38 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } } + + /** + * Validate input arguments + * + * @param InputInterface $input + * @return void + * @throws InvalidArgumentException + */ + private function validateInputArguments(InputInterface $input) + { + $this->staticCheckObjects = []; + $requiredChecksNames = $input->getArgument('names'); + $invalidCheckNames = []; + // Found user required static check script(s) to run, + // If no static check name is supplied, run all static check scripts + if (empty($requiredChecksNames)) { + $this->staticCheckObjects = $this->allStaticCheckObjects; + } else { + for ($index = 0; $index < count($requiredChecksNames); $index++) { + if (in_array($requiredChecksNames[$index], array_keys($this->allStaticCheckObjects))) { + $this->staticCheckObjects[$requiredChecksNames[$index]] = + $this->allStaticCheckObjects[$requiredChecksNames[$index]]; + } else { + $invalidCheckNames[] = $requiredChecksNames[$index]; + } + } + } + + if (!empty($invalidCheckNames)) { + throw new InvalidArgumentException( + "Invalid static check script(s): " . implode(', ', $invalidCheckNames) . "." + ); + } + } } From cc3601ae1f9262228a56415a09816fbb18fab024 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 24 Jan 2020 08:58:35 -0600 Subject: [PATCH 49/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments Refactoring + added logic to exclude arguments found in parent action group --- ...heck.php => ActionGroupArgumentsCheck.php} | 78 ++++++++++--------- .../StaticCheck/StaticCheckHelper.php | 36 +++++++++ .../StaticCheck/StaticChecksList.php | 2 +- .../StaticCheck/TestDependencyCheck.php | 35 ++------- 4 files changed, 84 insertions(+), 67 deletions(-) rename src/Magento/FunctionalTestingFramework/StaticCheck/{UnusedArgumentsCheck.php => ActionGroupArgumentsCheck.php} (75%) create mode 100644 src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php similarity index 75% rename from src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php rename to src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php index b0a20959a..709d35341 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/UnusedArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php @@ -14,12 +14,13 @@ use Exception; /** - * Class UnusedArgumentsCheck + * Class ActionGroupArgumentsCheck * @package Magento\FunctionalTestingFramework\StaticCheck - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class UnusedArgumentsCheck implements StaticCheckInterface +class ActionGroupArgumentsCheck implements StaticCheckInterface { + const ERROR_LOG_FILENAME = 'mftf-arguments-checks'; + const ERROR_LOG_MESSAGE = 'MFTF Unused Arguments Check'; /** * Array containing all errors found after running the execute() function. @@ -38,10 +39,11 @@ class UnusedArgumentsCheck implements StaticCheckInterface * * @param InputInterface $input * @return void - * @throws Exception; + * @throws Exception */ public function execute(InputInterface $input) { + MftfApplicationConfig::create( true, MftfApplicationConfig::UNIT_TEST_PHASE, @@ -56,7 +58,8 @@ public function execute(InputInterface $input) $this->errors += $this->setErrorOutput($unusedArgumentList); - $this->output = $this->printErrorsToFile(); + $this->output = StaticCheckHelper::printErrorsToFile($this->errors, + self::ERROR_LOG_FILENAME, self::ERROR_LOG_MESSAGE); } /** @@ -109,15 +112,45 @@ private function findUnusedArguments($actionGroup) foreach ($argumentList as $argument) { $argumentName = $argument->getName(); //pattern to match all argument references - $pattern = '(.*[\W]+(?getName(); + //exclude arguments that are also defined in parent action group for extending action groups + if ($this->isParentActionGroupArgument($argument, $actionGroup)) { + continue; + } + $unusedArguments[] = $argumentName; } return $unusedArguments; } + /** + * Checks if the argument is also defined in the parent for extending action groups. + * @param string $argument + * @param ActionGroupObject $actionGroup + * @return bool + */ + private function isParentActionGroupArgument($argument, $actionGroup) { + + if ($actionGroup->getParentName() !== null) { + $parentActionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroup->getParentName()); + $parentArguments = $parentActionGroup->getArguments(); + if ($parentArguments !== null) { + return in_array($argument, $parentArguments); + } + return false; + } + } + /** * Returns array of all action attribute values in an action group. * @param ActionGroupObject $actionGroup @@ -163,7 +196,6 @@ private function extractAttributeValues($action) private function setErrorOutput($unusedArgumentList) { $testErrors = []; - if (!empty($unusedArgumentList)) { // Build error output foreach ($unusedArgumentList as $path => $actionGroupToArguments) { @@ -178,32 +210,4 @@ private function setErrorOutput($unusedArgumentList) } return $testErrors; } - - /** - * Prints out given errors to file, and returns summary result string - * @return string - */ - private function printErrorsToFile() - { - $errors = $this->getErrors(); - - if (empty($errors)) { - return "No unused arguments found."; - } - - $outputPath = getcwd() . DIRECTORY_SEPARATOR . "mftf-arguments-checks.txt"; - $fileResource = fopen($outputPath, 'w'); - $header = "MFTF ActionGroup Arguments Check:\n"; - fwrite($fileResource, $header); - - foreach ($errors as $test => $error) { - fwrite($fileResource, $error[0] . PHP_EOL); - } - - fclose($fileResource); - $errorCount = count($errors); - $output = "Unused arguments found across {$errorCount} actionGroup(s). Error details output to {$outputPath}"; - - return $output; - } } diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php new file mode 100644 index 000000000..dc8803ceb --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php @@ -0,0 +1,36 @@ + $error) { + fwrite($fileResource, $error[0] . PHP_EOL); + } + + fclose($fileResource); + $errorCount = count($errors); + $output = $message . ": Errors found across {$errorCount} file(s). Error details output to {$outputPath}"; + + return $output; + } +} diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php index 83f06225e..ffa63389d 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticChecksList.php @@ -29,7 +29,7 @@ public function __construct(array $checks = []) { $this->checks = [ 'testDependencies' => new TestDependencyCheck(), - 'unusedArgumentsCheck' => new UnusedArgumentsCheck(), + 'actionGroupArguments' => new ActionGroupArgumentsCheck(), ] + $checks; } diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php index 19725dc18..dff24b0ed 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php @@ -6,6 +6,7 @@ namespace Magento\FunctionalTestingFramework\StaticCheck; +use Magento\FunctionalTestingFramework\StaticCheck\StaticCheckHelper; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler; use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; @@ -32,6 +33,9 @@ class TestDependencyCheck implements StaticCheckInterface const ACTIONGROUP_REGEX_PATTERN = '/ref=["\']([^\'"]*)/'; const ACTIONGROUP_ARGUMENT_REGEX_PATTERN = '/]*name="([^"\']*)/'; + const ERROR_LOG_FILENAME = 'mftf-dependency-checks'; + const ERROR_LOG_MESSAGE = 'MFTF File Dependency Check'; + /** * Array of FullModuleName => [dependencies] * @var array @@ -123,7 +127,8 @@ public function execute(InputInterface $input) $this->errors += $this->findErrorsInFileSet($dataXmlFiles); // hold on to the output and print any errors to a file - $this->output = $this->printErrorsToFile(); + $this->output = StaticCheckHelper::printErrorsToFile($this->errors, + self::ERROR_LOG_FILENAME, self::ERROR_LOG_MESSAGE); } /** @@ -461,32 +466,4 @@ private function findEntity($name) } return null; } - - /** - * Prints out given errors to file, and returns summary result string - * @return string - */ - private function printErrorsToFile() - { - $errors = $this->getErrors(); - - if (empty($errors)) { - return "No Dependency errors found."; - } - - $outputPath = getcwd() . DIRECTORY_SEPARATOR . "mftf-dependency-checks.txt"; - $fileResource = fopen($outputPath, 'w'); - $header = "MFTF File Dependency Check:\n"; - fwrite($fileResource, $header); - - foreach ($errors as $test => $error) { - fwrite($fileResource, $error[0] . PHP_EOL); - } - - fclose($fileResource); - $errorCount = count($errors); - $output = "Dependency errors found across {$errorCount} file(s). Error details output to {$outputPath}"; - - return $output; - } } From 4a306c265d4b29e11c23414f1edb674a51e843a3 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 24 Jan 2020 09:43:04 -0600 Subject: [PATCH 50/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments fixing unit tests --- .../StaticCheck/ActionGroupArgumentsCheck.php | 15 +++++++++------ .../StaticCheck/TestDependencyCheck.php | 7 +++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php index 709d35341..705b2103d 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php @@ -58,8 +58,11 @@ public function execute(InputInterface $input) $this->errors += $this->setErrorOutput($unusedArgumentList); - $this->output = StaticCheckHelper::printErrorsToFile($this->errors, - self::ERROR_LOG_FILENAME, self::ERROR_LOG_MESSAGE); + $this->output = StaticCheckHelper::printErrorsToFile( + $this->errors, + self::ERROR_LOG_FILENAME, + self::ERROR_LOG_MESSAGE + ); } /** @@ -135,12 +138,12 @@ private function findUnusedArguments($actionGroup) /** * Checks if the argument is also defined in the parent for extending action groups. - * @param string $argument + * @param string $argument * @param ActionGroupObject $actionGroup - * @return bool + * @return boolean */ - private function isParentActionGroupArgument($argument, $actionGroup) { - + private function isParentActionGroupArgument($argument, $actionGroup) + { if ($actionGroup->getParentName() !== null) { $parentActionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroup->getParentName()); $parentArguments = $parentActionGroup->getArguments(); diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php index dff24b0ed..2b309c015 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php @@ -127,8 +127,11 @@ public function execute(InputInterface $input) $this->errors += $this->findErrorsInFileSet($dataXmlFiles); // hold on to the output and print any errors to a file - $this->output = StaticCheckHelper::printErrorsToFile($this->errors, - self::ERROR_LOG_FILENAME, self::ERROR_LOG_MESSAGE); + $this->output = StaticCheckHelper::printErrorsToFile( + $this->errors, + self::ERROR_LOG_FILENAME, + self::ERROR_LOG_MESSAGE + ); } /** From f4b2d955f2ab8687b4d92721a5a6fc59196fbc7b Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Fri, 24 Jan 2020 10:04:55 -0600 Subject: [PATCH 51/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments fixing unit tests --- .../StaticCheck/StaticCheckHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php index dc8803ceb..5e3e8520d 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php @@ -9,7 +9,7 @@ class StaticCheckHelper { /** * Prints out given errors to file, and returns summary result string - * @param array $errors + * @param array $errors * @param string $filename * @param string $message * @return string From 3166af84d0c42039ace17ecd9c09299ebaefee53 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk Date: Fri, 24 Jan 2020 19:24:01 -0600 Subject: [PATCH 52/67] MFTF deprecation notice attributes --- .../MFTF/DevDocs/Section/ContentSection.xml | 1 + .../tests/MFTF/DevDocs/Test/DevDocsTest.xml | 2 +- .../Allure/Adapter/MagentoAllureAdapter.php | 1 + .../Codeception/Subscriber/Console.php | 30 ++++++++++ .../Handlers/DataObjectHandler.php | 13 ++++- .../OperationDefinitionObjectHandler.php | 12 +++- .../Objects/EntityDataObject.php | 30 ++++++++-- .../Objects/OperationDefinitionObject.php | 22 +++++++- .../Persist/DataPersistenceHandler.php | 5 +- .../DataGenerator/Util/DataExtensionUtil.php | 3 +- .../DataGenerator/etc/dataOperation.xsd | 7 +++ .../DataGenerator/etc/dataProfileSchema.xsd | 8 +++ .../Page/Handlers/PageObjectHandler.php | 11 +++- .../Page/Handlers/SectionObjectHandler.php | 29 +++++++++- .../Page/Objects/ElementObject.php | 20 ++++++- .../Page/Objects/PageObject.php | 45 ++++++++++++--- .../Page/Objects/SectionObject.php | 25 ++++++++- .../Page/etc/PageObject.xsd | 8 +++ .../Page/etc/SectionObject.xsd | 14 +++++ .../Suite/etc/suiteSchema.xsd | 7 +++ .../Test/Objects/ActionGroupObject.php | 55 ++++++++++++++++--- .../Test/Objects/ActionObject.php | 47 ++++++++++++++-- .../Test/Util/ActionGroupObjectExtractor.php | 16 +++++- .../Test/Util/ActionMergeUtil.php | 3 +- .../Test/Util/TestObjectExtractor.php | 39 +++++++++---- .../Test/etc/actionGroupSchema.xsd | 7 +++ .../Test/etc/mergedTestSchema.xsd | 7 +++ .../Util/TestGenerator.php | 46 +++++++++++++++- 28 files changed, 452 insertions(+), 61 deletions(-) diff --git a/dev/tests/functional/tests/MFTF/DevDocs/Section/ContentSection.xml b/dev/tests/functional/tests/MFTF/DevDocs/Section/ContentSection.xml index cf82b69e9..15af0fa39 100644 --- a/dev/tests/functional/tests/MFTF/DevDocs/Section/ContentSection.xml +++ b/dev/tests/functional/tests/MFTF/DevDocs/Section/ContentSection.xml @@ -10,5 +10,6 @@ xsi:noNamespaceSchemaLocation="../../../../../../../src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
+
diff --git a/dev/tests/functional/tests/MFTF/DevDocs/Test/DevDocsTest.xml b/dev/tests/functional/tests/MFTF/DevDocs/Test/DevDocsTest.xml index 3bdeeb9e8..c6b2575b9 100644 --- a/dev/tests/functional/tests/MFTF/DevDocs/Test/DevDocsTest.xml +++ b/dev/tests/functional/tests/MFTF/DevDocs/Test/DevDocsTest.xml @@ -21,6 +21,6 @@ - +
diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index e9e1c344c..97335726a 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -5,6 +5,7 @@ */ namespace Magento\FunctionalTestingFramework\Allure\Adapter; +use Codeception\Event\TestEvent; use Codeception\Step\Comment; use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; diff --git a/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php b/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php index 8c50f0670..01b385133 100644 --- a/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php +++ b/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php @@ -7,17 +7,24 @@ namespace Magento\FunctionalTestingFramework\Codeception\Subscriber; use Codeception\Event\StepEvent; +use Codeception\Event\TestEvent; use Codeception\Lib\Console\Message; use Codeception\Step; use Codeception\Step\Comment; use Codeception\Test\Interfaces\ScenarioDriven; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; +use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; use Magento\FunctionalTestingFramework\Util\TestGenerator; use Symfony\Component\Console\Formatter\OutputFormatter; class Console extends \Codeception\Subscriber\Console { + /** + * Regular expresion to find deprecated notices. + */ + const DEPRECATED_NOTICE = '/
  • (?.*?)<\/li>/m'; + /** * Test files cache. * @@ -53,6 +60,29 @@ public function __construct($extensionOptions = [], $options = []) parent::__construct($options); } + public function startTest(TestEvent $e) + { + $test = $e->getTest()->getTestClass(); + try { + $testReflection = new \ReflectionClass($test); + $isDeprecated = preg_match_all(self::DEPRECATED_NOTICE, $testReflection->getDocComment(), $match); + if ($isDeprecated) { + $this->message('DEPRECATION NOTICE(S): ') + ->style('debug') + ->writeln(); + foreach ($match['deprecatedMessage'] as $deprecatedMessage) { + $this->message(' - ' . $deprecatedMessage) + ->style('debug') + ->writeln(); + } + } + } catch (\ReflectionException $e) { + LoggingUtil::getInstance()->getLogger(self::class)->error($e->getMessage(), $e->getTrace()); + } + + return parent::startTest($e); + } + /** * Printing stepKey in before step action. * diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php index 95a2b8b93..0a7ae8ff2 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php @@ -13,6 +13,8 @@ use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface; use Magento\FunctionalTestingFramework\ObjectManagerFactory; use Magento\FunctionalTestingFramework\DataGenerator\Util\DataExtensionUtil; +use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; +use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; class DataObjectHandler implements ObjectHandlerInterface { @@ -163,6 +165,14 @@ private function processParserOutput($parserOutput) $parentEntity = $rawEntity[self::_EXTENDS]; } + if (array_key_exists('deprecated', $rawEntity)) { + $deprecated = $rawEntity['deprecated']; + LoggingUtil::getInstance()->getLogger(self::class)->deprecation( + $deprecated, + ["dataName" => $filename, "deprecatedEntity" => $deprecated] + ); + } + $entityDataObject = new EntityDataObject( $name, $type, @@ -171,7 +181,8 @@ private function processParserOutput($parserOutput) $uniquenessData, $vars, $parentEntity, - $filename + $filename, + $deprecated ); $entityDataObjects[$entityDataObject->getName()] = $entityDataObject; diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php index b768d9bd8..7fbfe0be7 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php @@ -11,6 +11,7 @@ use Magento\FunctionalTestingFramework\DataGenerator\Util\OperationElementExtractor; use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface; use Magento\FunctionalTestingFramework\ObjectManagerFactory; +use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; class OperationDefinitionObjectHandler implements ObjectHandlerInterface { @@ -145,6 +146,7 @@ private function initialize() $auth = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_AUTH] ?? null; $successRegex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_SUCCESS_REGEX] ?? null; $returnRegex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_RETURN_REGEX] ?? null; + $deprecated = $opDefArray['deprecated'] ?? null; $returnIndex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_RETURN_INDEX] ?? 0; $contentType = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_CONTENT_TYPE][0]['value'] ?? null; @@ -205,6 +207,13 @@ private function initialize() } } + if ($deprecated !== null) { + LoggingUtil::getInstance()->getLogger(self::class)->deprecation( + $deprecated, + ["operationName" => $dataDefName, "deprecatedOperation" => $deprecated] + ); + } + $this->operationDefinitionObjects[$operation . $dataType] = new OperationDefinitionObject( $dataDefName, $operation, @@ -219,7 +228,8 @@ private function initialize() $removeBackend, $successRegex, $returnRegex, - $returnIndex + $returnIndex, + $deprecated ); } } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php index 47a966f84..a41ee03d8 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php @@ -80,17 +80,25 @@ class EntityDataObject */ private $filename; + /** + * Deprecated message. + * + * @var string + */ + private $deprecated; + /** * Constructor * - * @param string $name - * @param string $type + * @param string $name + * @param string $type * @param string[] $data * @param string[] $linkedEntities * @param string[] $uniquenessData * @param string[] $vars - * @param string $parentEntity - * @param string $filename + * @param string $parentEntity + * @param string $filename + * @param string|null $deprecated */ public function __construct( $name, @@ -100,7 +108,8 @@ public function __construct( $uniquenessData, $vars = [], $parentEntity = null, - $filename = null + $filename = null, + $deprecated = null ) { $this->name = $name; $this->type = $type; @@ -113,6 +122,17 @@ public function __construct( $this->vars = $vars; $this->parentEntity = $parentEntity; $this->filename = $filename; + $this->deprecated = $deprecated; + } + + /** + * Getter for the deprecated attr of the section. + * + * @return string + */ + public function getDeprecated() + { + return $this->deprecated; } /** diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php index 721a9dcc9..a294ea1fd 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php @@ -117,6 +117,13 @@ class OperationDefinitionObject */ private $removeBackend; + /** + * Deprecated message. + * + * @var string + */ + private $deprecated; + /** * OperationDefinitionObject constructor. * @param string $name @@ -133,6 +140,7 @@ class OperationDefinitionObject * @param string $successRegex * @param string $returnRegex * @param string $returnIndex + * @param string|null $deprecated * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -149,7 +157,8 @@ public function __construct( $removeBackend, $successRegex = null, $returnRegex = null, - $returnIndex = null + $returnIndex = null, + $deprecated = null ) { $this->name = $name; $this->operation = $operation; @@ -164,6 +173,7 @@ public function __construct( $this->returnRegex = $returnRegex; $this->returnIndex = $returnIndex; $this->removeBackend = $removeBackend; + $this->deprecated = $deprecated; $this->apiUrl = null; if (!empty($contentType)) { @@ -176,6 +186,16 @@ public function __construct( $this->headers[] = self::HTTP_CONTENT_TYPE_HEADER . ': ' . $this->contentType; } + /** + * Getter for the deprecated attr of the section + * + * @return string + */ + public function getDeprecated() + { + return $this->deprecated; + } + /** * Getter for data's data type * diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/DataPersistenceHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/DataPersistenceHandler.php index dcb9d158a..73ee2be19 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/DataPersistenceHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Persist/DataPersistenceHandler.php @@ -59,7 +59,10 @@ public function __construct($entityObject, $dependentObjects = [], $customFields array_merge($entityObject->getAllData(), $customFields), $entityObject->getLinkedEntities(), $this->stripCustomFieldsFromUniquenessData($entityObject->getUniquenessData(), $customFields), - $entityObject->getVarReferences() + $entityObject->getVarReferences(), + $entityObject->getParentName(), + $entityObject->getFilename(), + $entityObject->getDeprecated() ); } else { $this->entityObject = clone $entityObject; diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php index 2766b39a0..3a12bdce1 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Util/DataExtensionUtil.php @@ -93,7 +93,8 @@ public function extendEntity($entityObject) $newUniqueReferences, $newVarReferences, $entityObject->getParentName(), - $entityObject->getFilename() + $entityObject->getFilename(), + $entityObject->getDeprecated() ); return $extendedEntity; } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataOperation.xsd b/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataOperation.xsd index 8b59ccae0..58fad8d8b 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataOperation.xsd +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataOperation.xsd @@ -22,6 +22,13 @@ + + + + Message and flag which shows that entity is deprecated. + + + diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd b/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd index aec157309..9d0d8bb35 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd @@ -69,6 +69,14 @@ + + + + Message and flag which shows that entity is deprecated. + + + + diff --git a/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php b/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php index d9eec1af1..a9c3b7cfb 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php @@ -9,6 +9,7 @@ use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface; use Magento\FunctionalTestingFramework\ObjectManagerFactory; use Magento\FunctionalTestingFramework\Page\Objects\PageObject; +use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; use Magento\FunctionalTestingFramework\XmlParser\PageParser; use Magento\FunctionalTestingFramework\Exceptions\XmlException; @@ -68,9 +69,17 @@ private function __construct() $sectionNames = array_keys($pageData[self::SECTION] ?? []); $parameterized = $pageData[self::PARAMETERIZED] ?? false; $filename = $pageData[self::FILENAME] ?? null; + $deprecated = $pageData['deprecated'] ?? null; + + if ($deprecated !== null) { + LoggingUtil::getInstance()->getLogger(self::class)->deprecation( + $deprecated, + ["pageName" => $filename, "deprecatedPage" => $deprecated] + ); + } $this->pageObjects[$pageName] = - new PageObject($pageName, $url, $module, $sectionNames, $parameterized, $area, $filename); + new PageObject($pageName, $url, $module, $sectionNames, $parameterized, $area, $filename, $deprecated); } } diff --git a/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php b/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php index e77e4c502..a827eac22 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php @@ -10,6 +10,8 @@ use Magento\FunctionalTestingFramework\ObjectManagerFactory; use Magento\FunctionalTestingFramework\Page\Objects\ElementObject; use Magento\FunctionalTestingFramework\Page\Objects\SectionObject; +use Magento\FunctionalTestingFramework\Test\Util\TestObjectExtractor; +use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; use Magento\FunctionalTestingFramework\XmlParser\SectionParser; use Magento\FunctionalTestingFramework\Exceptions\XmlException; @@ -73,14 +75,21 @@ private function __construct() $elementLocatorFunc = $elementData[SectionObjectHandler::LOCATOR_FUNCTION] ?? null; $elementTimeout = $elementData[SectionObjectHandler::TIMEOUT] ?? null; $elementParameterized = $elementData[SectionObjectHandler::PARAMETERIZED] ?? false; - + $elementDeprecated = $elementData['deprecated'] ?? null; + if ($elementDeprecated !== null) { + LoggingUtil::getInstance()->getLogger(ElementObject::class)->deprecation( + $elementDeprecated, + ["elementName" => $elementName, "deprecatedElement" => $elementDeprecated] + ); + } $elements[$elementName] = new ElementObject( $elementName, $elementType, $elementSelector, $elementLocatorFunc, $elementTimeout, - $elementParameterized + $elementParameterized, + $elementDeprecated ); } } catch (XmlException $exception) { @@ -88,7 +97,21 @@ private function __construct() } $filename = $sectionData[self::FILENAME] ?? null; - $this->sectionObjects[$sectionName] = new SectionObject($sectionName, $elements, $filename); + $sectionDeprecated = $sectionData['deprecated'] ?? null; + + if ($sectionDeprecated !== null) { + LoggingUtil::getInstance()->getLogger(ElementObject::class)->deprecation( + $sectionDeprecated, + ["sectionName" => $filename, "deprecatedSection" => $sectionDeprecated] + ); + } + + $this->sectionObjects[$sectionName] = new SectionObject( + $sectionName, + $elements, + $filename, + $sectionDeprecated + ); } } diff --git a/src/Magento/FunctionalTestingFramework/Page/Objects/ElementObject.php b/src/Magento/FunctionalTestingFramework/Page/Objects/ElementObject.php index 6b0626f10..567872fc7 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Objects/ElementObject.php +++ b/src/Magento/FunctionalTestingFramework/Page/Objects/ElementObject.php @@ -56,6 +56,13 @@ class ElementObject */ private $parameterized; + /** + * Deprecated message. + * + * @var string + */ + private $deprecated; + /** * ElementObject constructor. * @param string $name @@ -66,7 +73,7 @@ class ElementObject * @param boolean $parameterized * @throws XmlException */ - public function __construct($name, $type, $selector, $locatorFunction, $timeout, $parameterized) + public function __construct($name, $type, $selector, $locatorFunction, $timeout, $parameterized, $deprecated = null) { if ($selector != null && $locatorFunction != null) { throw new XmlException("Element '{$name}' cannot have both a selector and a locatorFunction."); @@ -83,6 +90,17 @@ public function __construct($name, $type, $selector, $locatorFunction, $timeout, } $this->timeout = $timeout; $this->parameterized = $parameterized; + $this->deprecated = $deprecated; + } + + /** + * Getter for the deprecated attr + * + * @return string + */ + public function getDeprecated() + { + return $this->deprecated; } /** diff --git a/src/Magento/FunctionalTestingFramework/Page/Objects/PageObject.php b/src/Magento/FunctionalTestingFramework/Page/Objects/PageObject.php index d99c40240..19525a415 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Objects/PageObject.php +++ b/src/Magento/FunctionalTestingFramework/Page/Objects/PageObject.php @@ -65,18 +65,34 @@ class PageObject */ private $filename; + /** + * Deprecated message. + * + * @var string + */ + private $deprecated; + /** * PageObject constructor. - * @param string $name - * @param string $url - * @param string $module - * @param array $sections + * @param string $name + * @param string $url + * @param string $module + * @param array $sections * @param boolean $parameterized - * @param string $area - * @param string $filename - */ - public function __construct($name, $url, $module, $sections, $parameterized, $area, $filename = null) - { + * @param string $area + * @param string|null $filename + * @param string|null $deprecated + */ + public function __construct( + $name, + $url, + $module, + $sections, + $parameterized, + $area, + $filename = null, + $deprecated = null + ) { $this->name = $name; $this->url = $url; $this->module = $module; @@ -84,6 +100,17 @@ public function __construct($name, $url, $module, $sections, $parameterized, $ar $this->parameterized = $parameterized; $this->area = $area; $this->filename = $filename; + $this->deprecated = $deprecated; + } + + /** + * Getter for the deprecated attr of the section + * + * @return string + */ + public function getDeprecated() + { + return $this->deprecated; } /** diff --git a/src/Magento/FunctionalTestingFramework/Page/Objects/SectionObject.php b/src/Magento/FunctionalTestingFramework/Page/Objects/SectionObject.php index 8c1cac326..57883e393 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Objects/SectionObject.php +++ b/src/Magento/FunctionalTestingFramework/Page/Objects/SectionObject.php @@ -32,17 +32,26 @@ class SectionObject */ private $filename; + /** + * Deprecated message. + * + * @var string + */ + private $deprecated; + /** * SectionObject constructor. * @param string $name - * @param array $elements - * @param string $filename + * @param array $elements + * @param string|null $filename + * @param string|null $deprecated */ - public function __construct($name, $elements, $filename = null) + public function __construct($name, $elements, $filename = null, $deprecated = null) { $this->name = $name; $this->elements = $elements; $this->filename = $filename; + $this->deprecated = $deprecated; } /** @@ -55,6 +64,16 @@ public function getName() return $this->name; } + /** + * Getter for the deprecated attr of the section + * + * @return string + */ + public function getDeprecated() + { + return $this->deprecated; + } + /** * Getter for the Section Filename * diff --git a/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd b/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd index c6f399a67..65ac8290d 100644 --- a/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd +++ b/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd @@ -48,6 +48,14 @@ + + + + Message and flag which shows that entity is deprecated. + + + + diff --git a/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd b/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd index 44e057369..1b5b44ddd 100644 --- a/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd +++ b/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd @@ -44,6 +44,13 @@ + + + + Message and flag which shows that entity is deprecated. + + + @@ -58,6 +65,13 @@ + + + + Message and flag which shows that entity is deprecated. + + + diff --git a/src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd b/src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd index 34ef37594..b36e35517 100644 --- a/src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Suite/etc/suiteSchema.xsd @@ -61,6 +61,13 @@ + + + + Message and flag which shows that entity is deprecated. + + + diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index fc38a7fce..1a1e93dab 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -94,18 +94,33 @@ class ActionGroupObject */ private $cachedStepKeys = null; + /** + * Deprecation message. + * + * @var string|null + */ + private $deprecated; + /** * ActionGroupObject constructor. * - * @param string $name - * @param array $annotations + * @param string $name + * @param array $annotations * @param ArgumentObject[] $arguments - * @param array $actions - * @param string $parentActionGroup - * @param string $filename + * @param array $actions + * @param string $parentActionGroup + * @param string $filename + * @param $deprecated */ - public function __construct($name, $annotations, $arguments, $actions, $parentActionGroup, $filename = null) - { + public function __construct( + $name, + $annotations, + $arguments, + $actions, + $parentActionGroup, + $filename = null, + $deprecated = null + ) { $this->varAttributes = array_merge( ActionObject::SELECTOR_ENABLED_ATTRIBUTES, ActionObject::DATA_ENABLED_ATTRIBUTES @@ -117,6 +132,17 @@ public function __construct($name, $annotations, $arguments, $actions, $parentAc $this->parsedActions = $actions; $this->parentActionGroup = $parentActionGroup; $this->filename = $filename; + $this->deprecated = $deprecated; + } + + /** + * Returns deprecated messages. + * + * @return string|null + */ + public function getDeprecated() + { + return $this->deprecated; } /** @@ -213,7 +239,8 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey) $action->getLinkedAction() == null ? null : $action->getLinkedAction() . ucfirst($actionReferenceKey), $orderOffset, [self::ACTION_GROUP_ORIGIN_NAME => $this->name, - self::ACTION_GROUP_ORIGIN_TEST_REF => $actionReferenceKey] + self::ACTION_GROUP_ORIGIN_TEST_REF => $actionReferenceKey], + $action->getDeprecatedUsages() ); } @@ -543,10 +570,20 @@ private function addContextCommentsToActionList($actionList, $actionReferenceKey { $actionStartComment = self::ACTION_GROUP_CONTEXT_START . "[" . $actionReferenceKey . "] " . $this->name; $actionEndComment = self::ACTION_GROUP_CONTEXT_END . "[" . $actionReferenceKey . "] " . $this->name; + + $deprecationNotices = []; + if ($this->getDeprecated() !== null) { + $deprecationNotices[] = "DEPRECATED ACTION GROUP in Test: " . $this->name . ' ' . $this->getDeprecated(); + } + $startAction = new ActionObject( $actionStartComment, ActionObject::ACTION_TYPE_COMMENT, - [ActionObject::ACTION_ATTRIBUTE_USERINPUT => $actionStartComment] + [ActionObject::ACTION_ATTRIBUTE_USERINPUT => $actionStartComment], + null, + ActionObject::MERGE_ACTION_ORDER_BEFORE, + null, + $deprecationNotices ); $endAction = new ActionObject( $actionEndComment, diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index 53743330e..207d05bc7 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -84,6 +84,14 @@ class ActionObject */ private $stepKey; + + /** + * Array of deprecated entities used in action. + * + * @var array + */ + private $deprecatedUsage = []; + /** * The type of action (e.g. fillField, createData, etc) * @@ -136,12 +144,13 @@ class ActionObject /** * ActionObject constructor. * - * @param string $stepKey - * @param string $type - * @param array $actionAttributes + * @param string $stepKey + * @param string $type + * @param array $actionAttributes * @param string|null $linkedAction - * @param string $order - * @param array $actionOrigin + * @param string $order + * @param array $actionOrigin + * @param array $deprecatedUsage */ public function __construct( $stepKey, @@ -149,13 +158,15 @@ public function __construct( $actionAttributes, $linkedAction = null, $order = ActionObject::MERGE_ACTION_ORDER_BEFORE, - $actionOrigin = null + $actionOrigin = null, + $deprecatedUsage = [] ) { $this->stepKey = $stepKey; $this->type = $type === self::COMMENT_ACTION ? self::ACTION_TYPE_COMMENT : $type; $this->actionAttributes = $actionAttributes; $this->linkedAction = $linkedAction; $this->actionOrigin = $actionOrigin; + $this->deprecatedUsage = $deprecatedUsage; if ($order === ActionObject::MERGE_ACTION_ORDER_AFTER) { $this->orderOffset = 1; @@ -534,11 +545,18 @@ private function findAndReplaceReferences($objectHandler, $inputString) $replacement = null; $parameterized = false; } elseif (get_class($obj) == PageObject::class) { + if ($obj->getDeprecated() !== null) { + $this->deprecatedUsage[] = "DEPRECATED PAGE in Test: " . $match . ' ' . $obj->getDeprecated(); + } $this->validateUrlAreaAgainstActionType($obj); $replacement = $obj->getUrl(); $parameterized = $obj->isParameterized(); } elseif (get_class($obj) == SectionObject::class) { + if ($obj->getDeprecated() !== null) { + $this->deprecatedUsage[] = "DEPRECATED SECTION in Test: " . $match . ' ' . $obj->getDeprecated(); + } list(,$objField) = $this->stripAndSplitReference($match); + if ($obj->getElement($objField) == null) { throw new TestReferenceException( "Could not resolve entity reference \"{$inputString}\" " @@ -549,7 +567,14 @@ private function findAndReplaceReferences($objectHandler, $inputString) $parameterized = $obj->getElement($objField)->isParameterized(); $replacement = $obj->getElement($objField)->getPrioritizedSelector(); $this->setTimeout($obj->getElement($objField)->getTimeout()); + if ($obj->getElement($objField)->getDeprecated() !== null) { + $this->deprecatedUsage[] = "DEPRECATED ELEMENT in Test: " . $match . ' ' + . $obj->getElement($objField)->getDeprecated(); + } } elseif (get_class($obj) == EntityDataObject::class) { + if ($obj->getDeprecated() !== null) { + $this->deprecatedUsage[] = "DEPRECATED DATA ENTITY in Test: " . $match . ' ' . $obj->getDeprecated(); + } $replacement = $this->resolveEntityDataObjectReference($obj, $match); if (is_array($replacement)) { @@ -766,4 +791,14 @@ private function checkParameterCount($matches, $parameters, $reference) ); } } + + /** + * Returns array of deprecated usages in Action. + * + * @return array + */ + public function getDeprecatedUsages() + { + return $this->deprecatedUsage; + } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php index e41329cb3..0b606c6d8 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php @@ -11,6 +11,8 @@ use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; use Magento\FunctionalTestingFramework\Test\Objects\ArgumentObject; +use Magento\FunctionalTestingFramework\Test\Objects\TestObject; +use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; /** * Class ActionGroupObjectExtractor @@ -58,7 +60,15 @@ public function __construct() public function extractActionGroup($actionGroupData) { $arguments = []; + $deprecated = null; + if (array_key_exists('deprecated', $actionGroupData)) { + $deprecated = $actionGroupData['deprecated']; + LoggingUtil::getInstance()->getLogger(ActionGroupObject::class)->deprecation( + $deprecated, + ["actionGroupName" => $actionGroupData[self::FILENAME], "deprecatedActionGroup" => $deprecated] + ); + } $actionGroupReference = $actionGroupData[self::EXTENDS_ACTION_GROUP] ?? null; $actionData = $this->stripDescriptorTags( $actionGroupData, @@ -69,7 +79,8 @@ public function extractActionGroup($actionGroupData) self::FILENAME, self::ACTION_GROUP_INSERT_BEFORE, self::ACTION_GROUP_INSERT_AFTER, - self::EXTENDS_ACTION_GROUP + self::EXTENDS_ACTION_GROUP, + 'deprecated' ); // TODO filename is now available to the ActionGroupObject, integrate this into debug and error statements @@ -99,7 +110,8 @@ public function extractActionGroup($actionGroupData) $arguments, $actions, $actionGroupReference, - $actionGroupData[self::FILENAME] + $actionGroupData[self::FILENAME], + $deprecated ); } diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php index cd81ade24..159822db1 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionMergeUtil.php @@ -128,7 +128,8 @@ private function resolveSecretFieldAccess($resolvedActions) $action->getCustomActionAttributes(), $action->getLinkedAction(), $action->getOrderOffset(), - $action->getActionOrigin() + $action->getActionOrigin(), + $action->getDeprecatedUsages() ); $actions[$action->getStepKey()] = $action; diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php index d5420e355..c55e35b9a 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php @@ -8,8 +8,10 @@ use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; use Magento\FunctionalTestingFramework\Exceptions\XmlException; +use Magento\FunctionalTestingFramework\Page\Objects\ElementObject; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; use Magento\FunctionalTestingFramework\Test\Objects\TestObject; +use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; use Magento\FunctionalTestingFramework\Util\ModulePathExtractor; use Magento\FunctionalTestingFramework\Util\Validation\NameValidationUtil; @@ -19,6 +21,7 @@ class TestObjectExtractor extends BaseObjectExtractor { const TEST_ANNOTATIONS = 'annotations'; + const TEST_DEPRECATED = 'deprecated'; const TEST_BEFORE_HOOK = 'before'; const TEST_AFTER_HOOK = 'after'; const TEST_FAILED_HOOK = 'failed'; @@ -95,7 +98,8 @@ public function extractTestData($testData) $fileNames = explode(",", $filename); $baseFileName = $fileNames[0]; $module = $this->modulePathExtractor->extractModuleName($baseFileName); - $testReference = $testData['extends'] ?? null; + $testReference = $testData['extends'] ?? null; + $deprecated = isset($testData[self::TEST_DEPRECATED]) ? $testData[self::TEST_DEPRECATED] : null; $testActions = $this->stripDescriptorTags( $testData, self::NODE_NAME, @@ -107,6 +111,7 @@ public function extractTestData($testData) self::TEST_INSERT_BEFORE, self::TEST_INSERT_AFTER, self::TEST_FILENAME, + self::TEST_DEPRECATED, 'extends' ); @@ -122,12 +127,19 @@ public function extractTestData($testData) // when $fileNames is not available if (!isset($testAnnotations["description"])) { $testAnnotations["description"] = []; + } else { + $testAnnotations["description"]['main'] = $testAnnotations["description"][0]; + unset($testAnnotations["description"][0]); + } + $testAnnotations["description"]['test_files'] = $this->appendFileNamesInDescriptionAnnotation($fileNames); + + if ($deprecated !== null) { + $testAnnotations["description"][self::TEST_DEPRECATED][] = $deprecated; + LoggingUtil::getInstance()->getLogger(TestObject::class)->deprecation( + $deprecated, + ["testName" => $filename, "deprecatedTest" => $deprecated] + ); } - $description = $testAnnotations["description"][0] ?? ''; - $testAnnotations["description"][0] = $this->appendFileNamesInDescriptionAnnotation( - $description, - $fileNames - ); // extract before if (array_key_exists(self::TEST_BEFORE_HOOK, $testData) && is_array($testData[self::TEST_BEFORE_HOOK])) { @@ -152,6 +164,10 @@ public function extractTestData($testData) ); } + if (!empty($testData[self::TEST_DEPRECATED])) { + $testAnnotations[self::TEST_DEPRECATED] = $testData[self::TEST_DEPRECATED]; + } + // TODO extract filename info and store try { return new TestObject( @@ -170,14 +186,13 @@ public function extractTestData($testData) /** * Append names of test files, including merge files, in description annotation * - * @param string $description - * @param array $fileNames + * @param array $fileNames * * @return string */ - private function appendFileNamesInDescriptionAnnotation($description, $fileNames) + private function appendFileNamesInDescriptionAnnotation(array $fileNames) { - $description .= '

    Test files

    '; + $filePaths = '

    Test files

    '; foreach ($fileNames as $fileName) { if (!empty($fileName) && realpath($fileName) !== false) { @@ -187,11 +202,11 @@ private function appendFileNamesInDescriptionAnnotation($description, $fileNames DIRECTORY_SEPARATOR ); if (!empty($relativeFileName)) { - $description .= $relativeFileName . '
    '; + $filePaths .= $relativeFileName . '
    '; } } } - return $description; + return $filePaths; } } diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd index 6e9e798f1..bd32ba879 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd @@ -43,6 +43,13 @@ + + + + Message and flag which shows that entity is deprecated. + + +
    diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd index fe45945ee..6ded366bb 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/mergedTestSchema.xsd @@ -86,6 +86,13 @@ + + + + Message and flag which shows that entity is deprecated. + + + diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index c67d8288f..e16c4cde6 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -112,6 +112,13 @@ class TestGenerator */ private $currentGenerationScope = TestGenerator::TEST_SCOPE; + /** + * Test deprecation messages. + * + * @var array + */ + private $deprecationMessages = []; + /** * Private constructor for Factory * @@ -244,7 +251,6 @@ public function createAllTestFiles($testManifest = null, $testsToIgnore = null) public function assembleTestPhp($testObject) { $usePhp = $this->generateUseStatementsPhp(); - $classAnnotationsPhp = $this->generateAnnotationsPhp($testObject->getAnnotations()); $className = $testObject->getCodeceptionName(); try { @@ -257,6 +263,7 @@ public function assembleTestPhp($testObject) } catch (TestReferenceException $e) { throw new TestReferenceException($e->getMessage() . "\n" . $testObject->getFilename()); } + $classAnnotationsPhp = $this->generateAnnotationsPhp($testObject->getAnnotations()); $cestPhp = "exportDirName . "\Backend;\n\n"; @@ -456,7 +463,7 @@ private function generateMethodAnnotations($annotationType = null, $annotationNa * Method which return formatted class level annotations based on type and name(s). * * @param string $annotationType - * @param string $annotationName + * @param array $annotationName * @return null|string * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ @@ -470,7 +477,8 @@ private function generateClassAnnotations($annotationType, $annotationName) break; case "description": - $annotationToAppend = sprintf(" * @Description(\"%s\")\n", $annotationName[0]); + $template = " * @Description(\"%s\")\n"; + $annotationToAppend = sprintf($template, $this->generateDescriptionAnnotation($annotationName)); break; case "testCaseId": @@ -491,6 +499,36 @@ private function generateClassAnnotations($annotationType, $annotationName) return $annotationToAppend; } + /** + * Generates Description + * + * @param array $descriptions + * @return string + */ + private function generateDescriptionAnnotation(array $descriptions) + { + $descriptionText = ""; + + $descriptionText .= $descriptions["main"]; + if (!empty($descriptions[TestObjectExtractor::TEST_DEPRECATED])) { + $deprecatedMessages = array_merge( + $descriptions[TestObjectExtractor::TEST_DEPRECATED], + $this->deprecationMessages + ); + + $descriptionText .= "

    Deprecated Notice(s):

    "; + $descriptionText .= "
      "; + + foreach ($deprecatedMessages as $deprecatedMessage) { + $descriptionText .= "
    • " . $deprecatedMessage . "
    • "; + } + $descriptionText .= "
    "; + } + $descriptionText .= $descriptions["test_files"]; + + return $descriptionText; + } + /** * Creates a PHP string for the actions contained withing a block. * Since nearly half of all Codeception methods don't share the same signature I had to setup a massive Case @@ -511,8 +549,10 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato $testSteps = ''; $this->actor = $actor; $this->currentGenerationScope = $generationScope; + $this->deprecationMessages = []; foreach ($actionObjects as $actionObject) { + $this->deprecationMessages = array_merge($this->deprecationMessages, $actionObject->getDeprecatedUsages()); $stepKey = $actionObject->getStepKey(); $customActionAttributes = $actionObject->getCustomActionAttributes(); $attribute = null; From 731a7703e298d12cfd7208eaf5047bc830675a2b Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Sun, 26 Jan 2020 22:12:42 -0600 Subject: [PATCH 53/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments Refactored to read xml content from files directly to avoid flagging arguments due to step removals during merging/extensions. --- .../StaticCheck/ActionGroupArgumentsCheck.php | 145 ++++++++---------- .../StaticCheck/StaticCheckHelper.php | 21 +++ .../StaticCheck/TestDependencyCheck.php | 25 +-- .../Handlers/ActionGroupObjectHandler.php | 5 +- 4 files changed, 94 insertions(+), 102 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php index 705b2103d..8e630bd63 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php @@ -9,8 +9,9 @@ use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; use Magento\FunctionalTestingFramework\Test\Handlers\ActionGroupObjectHandler; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; -use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; use Symfony\Component\Console\Input\InputInterface; +use Magento\FunctionalTestingFramework\Util\ModuleResolver; +use Symfony\Component\Finder\Finder; use Exception; /** @@ -19,6 +20,11 @@ */ class ActionGroupArgumentsCheck implements StaticCheckInterface { + + const ACTIONGROUP_XML_REGEX_PATTERN = '/).)*/mxs'; + const ACTIONGROUP_ARGUMENT_REGEX_PATTERN = '/]*name="([^"\']*)/mxs'; + const ACTIONGROUP_NAME_REGEX_PATTERN = '/initActionGroups(); + $allModules = ModuleResolver::getInstance()->getModulesPath(); - $unusedArgumentList = $this->buildUnusedArgumentList($actionGroups); + $actionGroupXmlFiles = StaticCheckHelper::buildFileList( + $allModules, + DIRECTORY_SEPARATOR . 'ActionGroup' . DIRECTORY_SEPARATOR + ); - $this->errors += $this->setErrorOutput($unusedArgumentList); + $this->errors = $this->findErrorsInFileSet($actionGroupXmlFiles); $this->output = StaticCheckHelper::printErrorsToFile( $this->errors, @@ -84,7 +92,24 @@ public function getOutput() } /** - * Builds array of action groups => unused arguments + * Finds all unused arguments in given set of actionGroup files + * @param Finder $files + * @return array $testErrors + */ + private function findErrorsInFileSet($files) + { + $actionGroupErrors = []; + foreach ($files as $filePath) { + $contents = file_get_contents($filePath); + preg_match_all(self::ACTIONGROUP_XML_REGEX_PATTERN, $contents, $actionGroups); + $actionGroupToArguments = $this->buildUnusedArgumentList($actionGroups[0]); + $actionGroupErrors += $this->setErrorOutput($actionGroupToArguments, $filePath); + } + return $actionGroupErrors; + } + + /** + * Builds array of action group => unused arguments * @param array $actionGroups * @return array $actionGroupToArguments */ @@ -92,46 +117,48 @@ private function buildUnusedArgumentList($actionGroups) { $actionGroupToArguments = []; - foreach ($actionGroups as $actionGroup) { - $unusedArguments = $this->findUnusedArguments($actionGroup); + foreach ($actionGroups as $actionGroupXml) { + preg_match(self::ACTIONGROUP_NAME_REGEX_PATTERN, $actionGroupXml, $actionGroupName); + $unusedArguments = $this->findUnusedArguments($actionGroupXml); if (!empty($unusedArguments)) { - $actionGroupToArguments[$actionGroup->getFilename()][$actionGroup->getName()] = $unusedArguments; + $actionGroupToArguments[$actionGroupName[1]] = $unusedArguments; } } return $actionGroupToArguments; } /** - * Returns unused arguments in an action group. - * @param ActionGroupObject $actionGroup - * @return array $unusedArguments + * @param $actionGroupXml + * @return array */ - private function findUnusedArguments($actionGroup) + private function findUnusedArguments($actionGroupXml) { $unusedArguments = []; - //extract all action attribute values - $actionAttributeValues = $this->getAllActionAttributeValues($actionGroup); - $argumentList = $actionGroup->getArguments(); - foreach ($argumentList as $argument) { - $argumentName = $argument->getName(); + + preg_match_all(self::ACTIONGROUP_ARGUMENT_REGEX_PATTERN, $actionGroupXml, $arguments); + preg_match(self::ACTIONGROUP_NAME_REGEX_PATTERN, $actionGroupXml, $actionGroupName); + + $actionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroupName[1]); + + foreach ($arguments[1] as $argument) { //pattern to match all argument references $patterns = [ - '(\{{2}' . $argumentName . '(\.[a-zA-Z0-9_\[\]\(\).,\'\/ ]+)?}{2})', - '([(,\s\']' . $argumentName . '(\.[a-zA-Z0-9_\[\]]+)?[),\s\'])' + '(\{{2}' . $argument . '(\.[a-zA-Z0-9_\[\]\(\).,\'\/ ]+)?}{2})', + '([(,\s\']' . $argument . '(\.[a-zA-Z0-9_\[\]]+)?[),\s\'])' ]; // matches entity references - if (preg_grep($patterns[0], $actionAttributeValues)) { + if (preg_match($patterns[0], $actionGroupXml)) { continue; } //matches parametrized references - if (preg_grep($patterns[1], $actionAttributeValues)) { + if (preg_match($patterns[1], $actionGroupXml)) { continue; } - //exclude arguments that are also defined in parent action group for extending action groups + //for extending action groups, exclude arguments that are also defined in parent action group if ($this->isParentActionGroupArgument($argument, $actionGroup)) { continue; } - $unusedArguments[] = $argumentName; + $unusedArguments[] = $argument; } return $unusedArguments; } @@ -147,70 +174,34 @@ private function isParentActionGroupArgument($argument, $actionGroup) if ($actionGroup->getParentName() !== null) { $parentActionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroup->getParentName()); $parentArguments = $parentActionGroup->getArguments(); - if ($parentArguments !== null) { - return in_array($argument, $parentArguments); - } - return false; - } - } - - /** - * Returns array of all action attribute values in an action group. - * @param ActionGroupObject $actionGroup - * @return array $allAttributeValues - */ - private function getAllActionAttributeValues($actionGroup) - { - $allAttributeValues = []; - $actions = $actionGroup->getActions(); - foreach ($actions as $action) { - $actionAttributeValues = $this->extractAttributeValues($action); - $allAttributeValues = array_merge($allAttributeValues, $actionAttributeValues); - } - return array_unique($allAttributeValues); - } - - /** - * Builds and returns flattened attribute value list for an action. - * @param ActionObject $action - * @return array $flattenedAttributeValues - */ - private function extractAttributeValues($action) - { - $flattenedAttributeValues = []; - $actionAttributes = $action->getCustomActionAttributes(); - //check if action has nodes eg. expectedResult, actualResult and flatten array - foreach ($actionAttributes as $attributeName => $attributeValue) { - if (is_array($attributeValue)) { - $flattenedAttributeValues = array_merge($flattenedAttributeValues, array_values($attributeValue)); - } else { - $flattenedAttributeValues[] = $attributeValue; + foreach ($parentArguments as $parentArgument) { + if ($argument === $parentArgument->getName()) { + return true; + } } } - return $flattenedAttributeValues; + return false; } /** - * Builds and returns error output for unused arguments + * Builds and returns error output for violating references * - * @param array $unusedArgumentList + * @param array $actionGroupToArguments + * @param string $path * @return mixed */ - private function setErrorOutput($unusedArgumentList) + private function setErrorOutput($actionGroupToArguments, $path) { - $testErrors = []; - if (!empty($unusedArgumentList)) { + $actionGroupErrors = []; + if (!empty($actionGroupToArguments)) { // Build error output - foreach ($unusedArgumentList as $path => $actionGroupToArguments) { - $errorOutput = "\nFile \"{$path}\""; - $errorOutput .= "\ncontains action group(s) with unused arguments.\n\t\t"; - - foreach ($actionGroupToArguments as $actionGroup => $arguments) { - $errorOutput .= "\n\t {$actionGroup} has unused argument(s): " . implode(", ", $arguments); - } - $testErrors[$path][] = $errorOutput; + $errorOutput = "\nFile \"{$path->getRealPath()}\""; + $errorOutput .= "\ncontains action group(s) with unused arguments.\n\t\t"; + foreach ($actionGroupToArguments as $actionGroup => $arguments) { + $errorOutput .= "\n\t {$actionGroup} has unused argument(s): " . implode(", ", $arguments); } + $actionGroupErrors[$path->getRealPath()][] = $errorOutput; } - return $testErrors; + return $actionGroupErrors; } } diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php index 5e3e8520d..6430774d4 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php @@ -5,6 +5,8 @@ */ namespace Magento\FunctionalTestingFramework\StaticCheck; +use Symfony\Component\Finder\Finder; + class StaticCheckHelper { /** @@ -33,4 +35,23 @@ public static function printErrorsToFile($errors, $filename, $message) return $output; } + + /** + * Builds list of all XML files in given modulePaths + path given + * @param array $modulePaths + * @param string $path + * @return Finder + */ + public static function buildFileList($modulePaths, $path) + { + $finder = new Finder(); + foreach ($modulePaths as $modulePath) { + if (!realpath($modulePath . $path)) { + continue; + } + $finder->files()->in($modulePath . $path)->name("*.xml"); + } + return $finder->files(); + } + } diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php index 2b309c015..3c3ed6a37 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php @@ -6,7 +6,6 @@ namespace Magento\FunctionalTestingFramework\StaticCheck; -use Magento\FunctionalTestingFramework\StaticCheck\StaticCheckHelper; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler; use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; @@ -117,9 +116,9 @@ public function execute(InputInterface $input) DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR, ]; // These files can contain references to other modules. - $testXmlFiles = $this->buildFileList($allModules, $filePaths[0]); - $actionGroupXmlFiles = $this->buildFileList($allModules, $filePaths[1]); - $dataXmlFiles= $this->buildFileList($allModules, $filePaths[2]); + $testXmlFiles = StaticCheckHelper::buildFileList($allModules, $filePaths[0]); + $actionGroupXmlFiles = StaticCheckHelper::buildFileList($allModules, $filePaths[1]); + $dataXmlFiles= StaticCheckHelper::buildFileList($allModules, $filePaths[2]); $this->errors = []; $this->errors += $this->findErrorsInFileSet($testXmlFiles); @@ -421,24 +420,6 @@ private function getModuleDependenciesFromReferences($array) return $filenames; } - /** - * Builds list of all XML files in given modulePaths + path given - * @param string $modulePaths - * @param string $path - * @return Finder - */ - private function buildFileList($modulePaths, $path) - { - $finder = new Finder(); - foreach ($modulePaths as $modulePath) { - if (!realpath($modulePath . $path)) { - continue; - } - $finder->files()->in($modulePath . $path)->name("*.xml"); - } - return $finder->files(); - } - /** * Attempts to find any MFTF entity by its name. Returns null if none are found. * @param string $name diff --git a/src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php b/src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php index 91f1f2b0d..131ae0a26 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Test/Handlers/ActionGroupObjectHandler.php @@ -99,10 +99,10 @@ public function getAllObjects(): array /** * Method which populates field array with objects from parsed action_group.xml * - * @return array + * @return void * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ - public function initActionGroups() + private function initActionGroups() { $actionGroupParser = ObjectManagerFactory::getObjectManager()->create(ActionGroupDataParser::class); $parsedActionGroups = $actionGroupParser->readActionGroupData(); @@ -118,7 +118,6 @@ public function initActionGroups() $this->actionGroups[$actionGroupName] = $actionGroupObjectExtractor->extractActionGroup($actionGroupData); } - return $this->actionGroups; } /** From 089b88d9d777318b0748b1536345b34e63057494 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan Date: Sun, 26 Jan 2020 22:31:29 -0600 Subject: [PATCH 54/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments fixed unit tests --- .../StaticCheck/ActionGroupArgumentsCheck.php | 8 +++++--- .../StaticCheck/StaticCheckHelper.php | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php index 8e630bd63..6c5c34203 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php @@ -128,7 +128,8 @@ private function buildUnusedArgumentList($actionGroups) } /** - * @param $actionGroupXml + * Returns unused arguments in an action group + * @param string $actionGroupXml * @return array */ private function findUnusedArguments($actionGroupXml) @@ -171,8 +172,9 @@ private function findUnusedArguments($actionGroupXml) */ private function isParentActionGroupArgument($argument, $actionGroup) { - if ($actionGroup->getParentName() !== null) { - $parentActionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroup->getParentName()); + $parentActionGroupName = $actionGroup->getParentName(); + if ($parentActionGroupName !== null) { + $parentActionGroup = ActionGroupObjectHandler::getInstance()->getObject($parentActionGroupName); $parentArguments = $parentActionGroup->getArguments(); foreach ($parentArguments as $parentArgument) { if ($argument === $parentArgument->getName()) { diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php index 6430774d4..f534544fc 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/StaticCheckHelper.php @@ -38,7 +38,7 @@ public static function printErrorsToFile($errors, $filename, $message) /** * Builds list of all XML files in given modulePaths + path given - * @param array $modulePaths + * @param array $modulePaths * @param string $path * @return Finder */ @@ -53,5 +53,4 @@ public static function buildFileList($modulePaths, $path) } return $finder->files(); } - } From c0a885cbc5e75e67925736152dc592105021563d Mon Sep 17 00:00:00 2001 From: Ji Lu Date: Fri, 24 Jan 2020 13:21:26 -0600 Subject: [PATCH 55/67] MQE-1919: MFTF AWS Secrets Manager - CI Use --- docs/credentials.md | 32 ++-- .../Handlers/CredentialStore.php | 155 +++++++++++++++--- .../Handlers/PersistedObjectHandler.php | 8 +- .../AwsSecretsManagerStorage.php | 15 ++ .../Handlers/SecretStorage/BaseStorage.php | 24 ++- .../Handlers/SecretStorage/VaultStorage.php | 18 +- .../Util/RuntimeDataReferenceResolver.php | 6 +- .../Collector/ExceptionCollector.php | 20 +++ .../Module/MagentoWebDriver.php | 6 + 9 files changed, 231 insertions(+), 53 deletions(-) diff --git a/docs/credentials.md b/docs/credentials.md index 1ea91a5c3..402030985 100644 --- a/docs/credentials.md +++ b/docs/credentials.md @@ -147,31 +147,33 @@ AWS Secrets Manager offers secret management that supports: #### Use AWS Secrets Manager from your own AWS account -- AWS account with Secrets Manager service available -- IAM User or Role is created with appropriate AWS Secrets Manger access permission +- An AWS account with Secrets Manager service +- An IAM user with AWS Secrets Manager access permission -#### Use AWS Secrets Manager from other AWS account +#### Use AWS Secrets Manager in CI/CD - AWS account ID where the AWS Secrets Manager service is hosted -- IAM User or Role with appropriate access permission +- Authorized CI/CD EC2 instances with AWS Secrets Manager service access IAM role attached ### Store secrets in AWS Secrets Manager - #### Secrets format `Secret Name` and `Secret Value` are two key pieces of information for creating a secret. `Secret Value` can be either plaintext or key/value pairs in JSON format. -`Secrets Name` must use the following format: +`Secret Name` must use the following format: ```conf mftf// ``` -`Secrets Value` in plaintext format can be any content you want to secure. `Secrets Value` in key/value pairs format, however, the `key` must be same as the `Secret Name` with `mftf//` part removed. -e.g. in above example, `key` should be `` +`Secret Value` can be stored in two different formats: plaintext or key/value pairs. + +For plaintext format, `Secret Value` can be any string you want to secure. + +For key/value pairs format, `Secret Value` is a key/value pair with `key` the same as `Secret Name` without `mftf//` prefix, which is ``, and value can be any string you want to secure. ##### Create Secrets using AWS CLI @@ -181,8 +183,11 @@ aws secretsmanager create-secret --name "mftf/magento/shipping/carriers_usps_use ##### Create Secrets using AWS Console -To save the same secret in key/value JSON format, you should use - +- Sign in to the AWS Secrets Manager console +- Choose Store a new secret +- In the Select secret type section, specify "Other type of secret" +- For `Secret Name`, `Secret Key` and `Secret Value` field, for example, to save the same secret in key/value JSON format, you should use + ```conf # Secret Name mftf/magento/shipping/carriers_usps_userid @@ -210,9 +215,8 @@ CREDENTIAL_AWS_SECRETS_MANAGER_PROFILE=default ### Optionally set CREDENTIAL_AWS_ACCOUNT_ID environment variable -Full AWS KMS ([Key Management Service][]) key ARN ([Amazon Resource Name][]) is required when accessing secrets stored in other AWS account. -If this is the case, you will also need to set `CREDENTIAL_AWS_ACCOUNT_ID` environment variable so that MFTF can construct the full ARN. -This is also commonly used in CI system. +In case AWS credentials cannot resolve to a valid AWS account, full AWS KMS ([Key Management Service][]) key ARN ([Amazon Resource Name][]) is required. +You will also need to set `CREDENTIAL_AWS_ACCOUNT_ID` environment variable so that MFTF can construct the full ARN. This is mostly used for CI/CD. ```bash export CREDENTIAL_AWS_ACCOUNT_ID= @@ -236,7 +240,7 @@ Define the value as a reference to the corresponding key in the credentials file - `_CREDS` is an environment constant pointing to the `.credentials` file - `my_data_key` is a key in the the `.credentials` file or vault that contains the value to be used in a test step - - for File Storage, ensure your key contains the vendor prefix, i.e. `vendor/my_data_key` + - for File Storage, ensure your key contains the vendor prefix, which is `vendor/my_data_key` For example, to reference secret data in the [`fillField`][] action, use the `userInput` attribute using a typical File Storage: diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php index b66d19799..d6e6b9a69 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/CredentialStore.php @@ -6,7 +6,9 @@ namespace Magento\FunctionalTestingFramework\DataGenerator\Handlers; +use Magento\FunctionalTestingFramework\Exceptions\Collector\ExceptionCollector; use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\BaseStorage; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\FileStorage; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\VaultStorage; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage\AwsSecretsManagerStorage; @@ -24,10 +26,17 @@ class CredentialStore /** * Credential storage array * - * @var array + * @var BaseStorage[] */ private $credStorage = []; + /** + * Boolean to indicate if credential storage have been initialized + * + * @var boolean + */ + private $initialized; + /** * Singleton instance * @@ -35,11 +44,17 @@ class CredentialStore */ private static $INSTANCE = null; + /** + * Exception contexts + * + * @var ExceptionCollector + */ + private $exceptionContexts; + /** * Static singleton getter for CredentialStore Instance * * @return CredentialStore - * @throws TestFrameworkException */ public static function getInstance() { @@ -52,21 +67,11 @@ public static function getInstance() /** * CredentialStore constructor - * - * @throws TestFrameworkException */ private function __construct() { - // Initialize credential storage by defined order of precedence as the following - $this->initializeFileStorage(); - $this->initializeVaultStorage(); - $this->initializeAwsSecretsManagerStorage(); - - if (empty($this->credStorage)) { - throw new TestFrameworkException( - 'Invalid Credential Storage. ' . self::CREDENTIAL_STORAGE_INFO . '.' - ); - } + $this->initialized = false; + $this->exceptionContexts = new ExceptionCollector(); } /** @@ -78,6 +83,9 @@ private function __construct() */ public function getSecret($key) { + // Initialize credential storage if it's not been done + $this->initializeCredentialStorage(); + // Get secret data from storage according to the order they are stored which follows this precedence: // FileStorage > VaultStorage > AwsSecretsManagerStorage foreach ($this->credStorage as $storage) { @@ -87,9 +95,12 @@ public function getSecret($key) } } + $exceptionContexts = $this->getExceptionContexts(); + $this->resetExceptionContext(); throw new TestFrameworkException( "{$key} not found. " . self::CREDENTIAL_STORAGE_INFO - . ' and ensure key, value exists to use _CREDS in tests.' + . " and ensure key, value exists to use _CREDS in tests." + . $exceptionContexts ); } @@ -97,28 +108,112 @@ public function getSecret($key) * Return decrypted input value * * @param string $value - * @return string + * @return string|false The decrypted string on success or false on failure + * @throws TestFrameworkException */ public function decryptSecretValue($value) { - // Loop through storage to decrypt value - foreach ($this->credStorage as $storage) { - return $storage->getDecryptedValue($value); - } + // Initialize credential storage if it's not been done + $this->initializeCredentialStorage(); + + // Decrypt secret value + return BaseStorage::getDecryptedValue($value); } /** * Return decrypted values for all occurrences from input string * * @param string $string - * @return mixed + * @return string|false The decrypted string on success or false on failure + * @throws TestFrameworkException */ public function decryptAllSecretsInString($string) { - // Loop through storage to decrypt all occurrences from input string - foreach ($this->credStorage as $storage) { - return $storage->getAllDecryptedValuesInString($string); + // Initialize credential storage if it's not been done + $this->initializeCredentialStorage(); + + // Decrypt all secret values in string + return BaseStorage::getAllDecryptedValuesInString($string); + } + + /** + * Setter for exception contexts + * + * @param string $type + * @param string $context + * @return void + */ + public function setExceptionContexts($type, $context) + { + $typeArray = [self::ARRAY_KEY_FOR_FILE, self::ARRAY_KEY_FOR_VAULT, self::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER]; + if (in_array($type, $typeArray) && !empty($context)) { + $this->exceptionContexts->addError($type, $context); + } + } + + /** + * Return collected exception contexts + * + * @return string + */ + private function getExceptionContexts() + { + // Gather all exceptions collected + $exceptionMessage = "\n"; + foreach ($this->exceptionContexts->getErrors() as $type => $exceptions) { + $exceptionMessage .= "\nException from "; + if ($type == self::ARRAY_KEY_FOR_FILE) { + $exceptionMessage .= "File Storage: \n"; + } + if ($type == self::ARRAY_KEY_FOR_VAULT) { + $exceptionMessage .= "Vault Storage: \n"; + } + if ($type == self::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER) { + $exceptionMessage .= "AWS Secrets Manager Storage: \n"; + } + + if (is_array($exceptions)) { + $exceptionMessage .= implode("\n", $exceptions) . "\n"; + } else { + $exceptionMessage .= $exceptions . "\n"; + } + } + return $exceptionMessage; + } + + /** + * Reset exception contexts to empty array + * + * @return void + */ + private function resetExceptionContext() + { + $this->exceptionContexts->reset(); + } + + /** + * Initialize all available credential storage + * + * @return void + * @throws TestFrameworkException + */ + private function initializeCredentialStorage() + { + if (!$this->initialized) { + // Initialize credential storage by defined order of precedence as the following + $this->initializeFileStorage(); + $this->initializeVaultStorage(); + $this->initializeAwsSecretsManagerStorage(); + $this->initialized = true; + } + + if (empty($this->credStorage)) { + throw new TestFrameworkException( + 'Invalid Credential Storage. ' . self::CREDENTIAL_STORAGE_INFO + . '.' . $this->getExceptionContexts() + ); } + $this->resetExceptionContext(); } /** @@ -132,6 +227,10 @@ private function initializeFileStorage() try { $this->credStorage[self::ARRAY_KEY_FOR_FILE] = new FileStorage(); } catch (TestFrameworkException $e) { + // Print error message in console + print_r($e->getMessage()); + // Save to exception context for Allure report + $this->setExceptionContexts(self::ARRAY_KEY_FOR_FILE, $e->getMessage()); } } @@ -152,6 +251,10 @@ private function initializeVaultStorage() '/' . trim($cvSecretPath, '/') ); } catch (TestFrameworkException $e) { + // Print error message in console + print_r($e->getMessage()); + // Save to exception context for Allure report + $this->setExceptionContexts(self::ARRAY_KEY_FOR_VAULT, $e->getMessage()); } } } @@ -181,6 +284,10 @@ private function initializeAwsSecretsManagerStorage() $awsId ); } catch (TestFrameworkException $e) { + // Print error message in console + print_r($e->getMessage()); + // Save to exception context for Allure report + $this->setExceptionContexts(self::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER, $e->getMessage()); } } } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php index 00353856b..927c0ab4e 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/PersistedObjectHandler.php @@ -89,10 +89,12 @@ public function createEntity( foreach ($overrideFields as $index => $field) { try { - $overrideFields[$index] = CredentialStore::getInstance()->decryptAllSecretsInString($field); + $decrptedField = CredentialStore::getInstance()->decryptAllSecretsInString($field); + if ($decrptedField !== false) { + $overrideFields[$index] = $decrptedField; + } } catch (TestFrameworkException $e) { - //do not rethrow if Credentials are not defined - $overrideFields[$index] = $field; + //catch exception if Credentials are not defined } } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php index bb6044c7f..6bd1ff144 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/AwsSecretsManagerStorage.php @@ -7,6 +7,7 @@ namespace Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; use Aws\SecretsManager\SecretsManagerClient; @@ -117,17 +118,31 @@ public function getEncryptedValue($key) } catch (AwsException $e) { $errMessage = "\nAWS Exception:\n" . $e->getAwsErrorMessage() . "\nUnable to read value for key {$key} from AWS Secrets Manager\n"; + // Print error message in console print_r($errMessage); + // Add error message in mftf log if verbose is enable if (MftfApplicationConfig::getConfig()->verboseEnabled()) { LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug($errMessage); } + // Save to exception context for Allure report + CredentialStore::getInstance()->setExceptionContexts( + CredentialStore::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER, + $errMessage + ); } catch (\Exception $e) { $errMessage = "\nException:\n" . $e->getMessage() . "\nUnable to read value for key {$key} from AWS Secrets Manager\n"; + // Print error message in console print_r($errMessage); + // Add error message in mftf log if verbose is enable if (MftfApplicationConfig::getConfig()->verboseEnabled()) { LoggingUtil::getInstance()->getLogger(AwsSecretsManagerStorage::class)->debug($errMessage); } + // Save to exception context for Allure report + CredentialStore::getInstance()->setExceptionContexts( + CredentialStore::ARRAY_KEY_FOR_AWS_SECRETS_MANAGER, + $errMessage + ); } return $reValue; } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/BaseStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/BaseStorage.php index cb892a545..6eb7fa7e8 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/BaseStorage.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/BaseStorage.php @@ -58,30 +58,38 @@ public function getEncryptedValue($key) /** * Takes a value encrypted at runtime and decrypts it using the object's initial vector + * return the decrypted string on success or false on failure * * @param string $value - * @return string + * @return string|false The decrypted string on success or false on failure */ - public function getDecryptedValue($value) + public static function getDecryptedValue($value) { return openssl_decrypt($value, self::ENCRYPTION_ALGO, self::$encodedKey, 0, self::$iv); } /** * Takes a string that contains encrypted data at runtime and decrypts each value + * return false if no decryption happens or a failure occurs * * @param string $string - * @return mixed + * @return string|false The decrypted string on success or false on failure */ - public function getAllDecryptedValuesInString($string) + public static function getAllDecryptedValuesInString($string) { - $newString = $string; + $decrypted = false; foreach (self::$cachedSecretData as $key => $secretValue) { - if (strpos($newString, $secretValue) !== false) { + if (strpos($string, $secretValue) !== false) { $decryptedValue = self::getDecryptedValue($secretValue); - $newString = str_replace($secretValue, $decryptedValue, $newString); + if ($decryptedValue === false) { + return false; + } + if (!$decrypted) { + $decrypted = true; + } + $string = str_replace($secretValue, $decryptedValue, $string); } } - return $newString; + return $decrypted ? $string : false; } } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php index 798ac660c..39839e8f9 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/SecretStorage/VaultStorage.php @@ -7,6 +7,7 @@ namespace Magento\FunctionalTestingFramework\DataGenerator\Handlers\SecretStorage; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; +use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; use Vault\Client; @@ -123,10 +124,14 @@ public function getEncryptedValue($key) $reValue = openssl_encrypt($value, parent::ENCRYPTION_ALGO, parent::$encodedKey, 0, parent::$iv); parent::$cachedSecretData[$key] = $reValue; } catch (\Exception $e) { + $errMessage = "\nUnable to read secret for key name {$key} from vault." . $e->getMessage(); + // Print error message in console + print_r($errMessage); + // Save to exception context for Allure report + CredentialStore::getInstance()->setExceptionContexts('vault', $errMessage); + // Add error message in mftf log if verbose is enable if (MftfApplicationConfig::getConfig()->verboseEnabled()) { - LoggingUtil::getInstance()->getLogger(VaultStorage::class)->debug( - "Unable to read secret for key name {$key} from vault" - ); + LoggingUtil::getInstance()->getLogger(VaultStorage::class)->debug($errMessage); } } return $reValue; @@ -149,6 +154,13 @@ private function authenticated() return true; } } catch (\Exception $e) { + // Print error message in console + print_r($e->getMessage()); + // Save to exception context for Allure report + CredentialStore::getInstance()->setExceptionContexts( + CredentialStore::ARRAY_KEY_FOR_VAULT, + $e->getMessage() + ); } return false; } diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Util/RuntimeDataReferenceResolver.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Util/RuntimeDataReferenceResolver.php index a09afd01a..220d4ab7f 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Util/RuntimeDataReferenceResolver.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Util/RuntimeDataReferenceResolver.php @@ -9,6 +9,7 @@ use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler; use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; +use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; /** @@ -23,7 +24,7 @@ class RuntimeDataReferenceResolver implements DataReferenceResolverInterface * @param string $originalDataEntity * @return array|false|string|null * @throws TestReferenceException - * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException + * @throws TestFrameworkException */ public function getDataReference(string $data, string $originalDataEntity) { @@ -43,6 +44,9 @@ public function getDataReference(string $data, string $originalDataEntity) case ActionObject::__CREDS: $value = CredentialStore::getInstance()->getSecret($var); $result = CredentialStore::getInstance()->decryptSecretValue($value); + if ($result === false) { + throw new TestFrameworkException("\nFailed to decrypt value {$value}\n"); + } $result = str_replace($matches['reference'], $result, $data); break; default: diff --git a/src/Magento/FunctionalTestingFramework/Exceptions/Collector/ExceptionCollector.php b/src/Magento/FunctionalTestingFramework/Exceptions/Collector/ExceptionCollector.php index c1e023ef4..f64b35446 100644 --- a/src/Magento/FunctionalTestingFramework/Exceptions/Collector/ExceptionCollector.php +++ b/src/Magento/FunctionalTestingFramework/Exceptions/Collector/ExceptionCollector.php @@ -43,6 +43,26 @@ public function throwException() throw new \Exception("\n" . $errorMsg); } + /** + * Return all errors + * + * @return array + */ + public function getErrors() + { + return $this->errors ?? []; + } + + /** + * Reset error to empty array + * + * @return void + */ + public function reset() + { + $this->errors = []; + } + /** * If there are multiple exceptions for a single file, the function flattens the array so they can be printed * as separate messages. diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index f44d7e1a0..cd2768a06 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -769,6 +769,9 @@ public function fillSecretField($field, $value) // decrypted value $decryptedValue = CredentialStore::getInstance()->decryptSecretValue($value); + if ($decryptedValue === false) { + throw new TestFrameworkException("\nFailed to decrypt value {$value} for field {$field}\n"); + } $this->fillField($field, $decryptedValue); } @@ -788,6 +791,9 @@ public function magentoCLISecret($command, $timeout = null, $arguments = null) // decrypted value $decryptedCommand = CredentialStore::getInstance()->decryptAllSecretsInString($command); + if ($decryptedCommand === false) { + throw new TestFrameworkException("\nFailed to decrypt magentoCLI command {$command}\n"); + } return $this->magentoCLI($decryptedCommand, $timeout, $arguments); } From 6ff290a11305768719c3a02d4d8eb578bef9593c Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk Date: Mon, 27 Jan 2020 10:45:58 -0600 Subject: [PATCH 56/67] MFTF deprecation notice attributes - fix failing tests --- .../DeprecatedCommentActionGroup.xml | 13 +++++++++ .../DevDocs/Data/DeprecatedMessageData.xml | 14 +++++++++ .../tests/MFTF/DevDocs/Data/MessageData.xml | 14 +++++++++ .../DevDocs/Page/DeprecatedMFTFDocPage.xml | 14 +++++++++ .../Section/DeprecatedContentSection.xml | 14 +++++++++ .../DevDocs/Test/DeprecatedDevDocsTest.xml | 27 +++++++++++++++++ .../Test/Handlers/TestObjectHandlerTest.php | 2 +- .../ActionGroupContainsStepKeyInArgText.txt | 2 +- .../ActionGroupMergedViaInsertAfter.txt | 2 +- .../ActionGroupMergedViaInsertBefore.txt | 2 +- .../Resources/ActionGroupSkipReadiness.txt | 2 +- .../Resources/ActionGroupToExtend.txt | 2 +- .../Resources/ActionGroupUsingCreateData.txt | 2 +- .../ActionGroupUsingNestedArgument.txt | 2 +- .../ActionGroupWithDataOverrideTest.txt | 2 +- .../Resources/ActionGroupWithDataTest.txt | 2 +- ...hDefaultArgumentAndStringSelectorParam.txt | 2 +- ...eParameterSelectorsFromDefaultArgument.txt | 2 +- .../Resources/ActionGroupWithNoArguments.txt | 2 +- .../ActionGroupWithNoDefaultTest.txt | 2 +- ...roupWithParameterizedElementWithHyphen.txt | 2 +- ...meterizedElementsWithStepKeyReferences.txt | 2 +- ...thPassedArgumentAndStringSelectorParam.txt | 2 +- .../ActionGroupWithPersistedData.txt | 2 +- ...tionGroupWithSectionAndDataAsArguments.txt | 2 +- ...WithSimpleDataUsageFromDefaultArgument.txt | 2 +- ...pWithSimpleDataUsageFromPassedArgument.txt | 2 +- ...leParameterSelectorFromDefaultArgument.txt | 2 +- ...gleParameterSelectorFromPassedArgument.txt | 2 +- .../ActionGroupWithStepKeyReferences.txt | 2 +- .../ActionGroupWithTopLevelPersistedData.txt | 2 +- .../ArgumentWithSameNameAsElement.txt | 2 +- .../verification/Resources/AssertTest.txt | 2 +- .../Resources/BasicActionGroupTest.txt | 2 +- .../Resources/BasicFunctionalTest.txt | 2 +- .../verification/Resources/BasicMergeTest.txt | 2 +- .../Resources/CharacterReplacementTest.txt | 2 +- .../Resources/ChildExtendedTestAddHooks.txt | 2 +- .../Resources/ChildExtendedTestMerging.txt | 2 +- .../Resources/ChildExtendedTestNoParent.txt | 2 +- .../ChildExtendedTestRemoveAction.txt | 2 +- .../ChildExtendedTestRemoveHookAction.txt | 2 +- .../Resources/ChildExtendedTestReplace.txt | 2 +- .../ChildExtendedTestReplaceHook.txt | 2 +- .../Resources/DataActionsTest.txt | 2 +- .../Resources/DataReplacementTest.txt | 2 +- .../Resources/ExecuteInSeleniumTest.txt | 2 +- .../Resources/ExecuteJsEscapingTest.txt | 2 +- .../Resources/ExtendParentDataTest.txt | 2 +- .../Resources/ExtendedActionGroup.txt | 2 +- .../ExtendedChildTestInSuiteCest.txt | 2 +- .../Resources/ExtendedChildTestNotInSuite.txt | 2 +- .../Resources/ExtendedRemoveActionGroup.txt | 2 +- .../Resources/ExtendingSkippedTest.txt | 2 +- .../Resources/HookActionsTest.txt | 2 +- .../Resources/LocatorFunctionTest.txt | 2 +- .../Resources/MergeMassViaInsertAfter.txt | 2 +- .../Resources/MergeMassViaInsertBefore.txt | 2 +- .../verification/Resources/MergeSkip.txt | 2 +- .../Resources/MergedActionGroupTest.txt | 2 +- .../Resources/MergedReferencesTest.txt | 2 +- .../Resources/MultipleActionGroupsTest.txt | 2 +- .../Resources/PageReplacementTest.txt | 2 +- .../Resources/ParameterArrayTest.txt | 2 +- .../Resources/ParentExtendedTest.txt | 2 +- .../PersistedAndXmlEntityArguments.txt | 2 +- .../Resources/PersistedReplacementTest.txt | 2 +- .../PersistenceActionGroupAppendingTest.txt | 2 +- .../Resources/PersistenceCustomFieldsTest.txt | 2 +- .../Resources/SectionReplacementTest.txt | 2 +- .../verification/Resources/SkippedTest.txt | 2 +- .../Resources/SkippedTestNoIssues.txt | 2 +- .../Resources/SkippedTestTwoIssues.txt | 2 +- .../Resources/SkippedTestWithHooks.txt | 2 +- .../Resources/XmlCommentedActionGroupTest.txt | 2 +- .../Resources/XmlCommentedTest.txt | 2 +- .../Allure/Adapter/MagentoAllureAdapter.php | 1 - .../Codeception/Subscriber/Console.php | 12 +++++++- .../Handlers/DataObjectHandler.php | 3 +- .../OperationDefinitionObjectHandler.php | 4 +-- .../Objects/EntityDataObject.php | 16 +++++----- .../Objects/OperationDefinitionObject.php | 29 ++++++++++--------- .../Page/Objects/PageObject.php | 12 ++++---- .../Page/Objects/SectionObject.php | 4 +-- .../Test/Objects/ActionGroupObject.php | 12 ++++---- .../Test/Objects/ActionObject.php | 16 +++++----- .../Test/Util/TestObjectExtractor.php | 2 ++ .../Util/TestGenerator.php | 6 ++-- 88 files changed, 230 insertions(+), 123 deletions(-) create mode 100644 dev/tests/functional/tests/MFTF/DevDocs/ActionGroup/DeprecatedCommentActionGroup.xml create mode 100644 dev/tests/functional/tests/MFTF/DevDocs/Data/DeprecatedMessageData.xml create mode 100644 dev/tests/functional/tests/MFTF/DevDocs/Data/MessageData.xml create mode 100644 dev/tests/functional/tests/MFTF/DevDocs/Page/DeprecatedMFTFDocPage.xml create mode 100644 dev/tests/functional/tests/MFTF/DevDocs/Section/DeprecatedContentSection.xml create mode 100644 dev/tests/functional/tests/MFTF/DevDocs/Test/DeprecatedDevDocsTest.xml diff --git a/dev/tests/functional/tests/MFTF/DevDocs/ActionGroup/DeprecatedCommentActionGroup.xml b/dev/tests/functional/tests/MFTF/DevDocs/ActionGroup/DeprecatedCommentActionGroup.xml new file mode 100644 index 000000000..908808a8c --- /dev/null +++ b/dev/tests/functional/tests/MFTF/DevDocs/ActionGroup/DeprecatedCommentActionGroup.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/dev/tests/functional/tests/MFTF/DevDocs/Data/DeprecatedMessageData.xml b/dev/tests/functional/tests/MFTF/DevDocs/Data/DeprecatedMessageData.xml new file mode 100644 index 000000000..5835a78af --- /dev/null +++ b/dev/tests/functional/tests/MFTF/DevDocs/Data/DeprecatedMessageData.xml @@ -0,0 +1,14 @@ + + + + + + Introduction to the Magento Functional Testing Framework + + diff --git a/dev/tests/functional/tests/MFTF/DevDocs/Data/MessageData.xml b/dev/tests/functional/tests/MFTF/DevDocs/Data/MessageData.xml new file mode 100644 index 000000000..eb77e73bc --- /dev/null +++ b/dev/tests/functional/tests/MFTF/DevDocs/Data/MessageData.xml @@ -0,0 +1,14 @@ + + + + + + Introduction to the Magento Functional Testing Framework + + diff --git a/dev/tests/functional/tests/MFTF/DevDocs/Page/DeprecatedMFTFDocPage.xml b/dev/tests/functional/tests/MFTF/DevDocs/Page/DeprecatedMFTFDocPage.xml new file mode 100644 index 000000000..ee47fe954 --- /dev/null +++ b/dev/tests/functional/tests/MFTF/DevDocs/Page/DeprecatedMFTFDocPage.xml @@ -0,0 +1,14 @@ + + + + + +
    + + diff --git a/dev/tests/functional/tests/MFTF/DevDocs/Section/DeprecatedContentSection.xml b/dev/tests/functional/tests/MFTF/DevDocs/Section/DeprecatedContentSection.xml new file mode 100644 index 000000000..cc316d6ed --- /dev/null +++ b/dev/tests/functional/tests/MFTF/DevDocs/Section/DeprecatedContentSection.xml @@ -0,0 +1,14 @@ + + + + +
    + +
    +
    diff --git a/dev/tests/functional/tests/MFTF/DevDocs/Test/DeprecatedDevDocsTest.xml b/dev/tests/functional/tests/MFTF/DevDocs/Test/DeprecatedDevDocsTest.xml new file mode 100644 index 000000000..bf0078df4 --- /dev/null +++ b/dev/tests/functional/tests/MFTF/DevDocs/Test/DeprecatedDevDocsTest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + <description value="[Deprecated] Magento Functional Testing Framework Documentation is available."/> + <severity value="CRITICAL"/> + <group value="mftf"/> + </annotations> + + <!-- Open MFTF DevDocs Page --> + <amOnPage stepKey="openMFTFDevDocPage" url="{{DeprecatedMFTFDocPage.url}}" /> + <see stepKey="verifyPageIntroText" selector="{{DeprecatedContentSection.pageIntro}}" userInput="{{DeprecatedMessageData.message}}" /> + <actionGroup ref="DeprecatedCommentActionGroup" stepKey="commentActionGroup" /> + </test> +</tests> diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php index 39e80d556..67f6f2b43 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Handlers/TestObjectHandlerTest.php @@ -92,7 +92,7 @@ public function testGetTestObject() [ 'features' => ['NO MODULE DETECTED'], 'group' => ['test'], - 'description' => ['<br><br><b><font size=+0.9>Test files</font></b><br><br>'] + 'description' => ['test_files' => '<h3>Test files</h3>', 'deprecated' => []] ], [ TestObjectExtractor::TEST_BEFORE_HOOK => $expectedBeforeHookObject, diff --git a/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt b/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt index 1eb3d6566..23e0f0b69 100644 --- a/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt +++ b/dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupContainsStepKeyInArgTextCest { diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt index b4745e0c0..da3d84daf 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class ActionGroupMergedViaInsertAfterCest { diff --git a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt index b27328275..22e8148d9 100644 --- a/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt +++ b/dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class ActionGroupMergedViaInsertBeforeCest { diff --git a/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt b/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt index 11025fefe..efd5a8cb5 100644 --- a/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt +++ b/dev/tests/verification/Resources/ActionGroupSkipReadiness.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupSkipReadinessCest { diff --git a/dev/tests/verification/Resources/ActionGroupToExtend.txt b/dev/tests/verification/Resources/ActionGroupToExtend.txt index 133c9fb9b..29d08c0b6 100644 --- a/dev/tests/verification/Resources/ActionGroupToExtend.txt +++ b/dev/tests/verification/Resources/ActionGroupToExtend.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupToExtendCest { diff --git a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt index fb76b4f44..b64822cf6 100644 --- a/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt +++ b/dev/tests/verification/Resources/ActionGroupUsingCreateData.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupUsingCreateDataCest { diff --git a/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt b/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt index 5814e85e0..5eb67f577 100644 --- a/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupUsingNestedArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt index a455d98e0..bb6404315 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class ActionGroupWithDataOverrideTestCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt index 7ac32f550..6b22f83e0 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDataTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDataTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class ActionGroupWithDataTestCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt b/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt index 289bbe4e1..ca5f72cc0 100644 --- a/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt +++ b/dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With Default Argument Value and Hardcoded Value in Param") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithDefaultArgumentAndStringSelectorParamCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt index 4e94978ad..f3ad492b0 100644 --- a/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With Passed Argument Value and Multiple Argument Values in Param") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithMultipleParameterSelectorsFromDefaultArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt b/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt index 6158b5af7..0f69c40e8 100644 --- a/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt +++ b/dev/tests/verification/Resources/ActionGroupWithNoArguments.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With No Argument") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithNoArgumentsCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt index ca6474a7b..533e14b9d 100644 --- a/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt +++ b/dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class ActionGroupWithNoDefaultTestCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt index 52dc8bd1b..acc6aa58a 100644 --- a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt +++ b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithParameterizedElementWithHyphenCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt index b0758e679..ac20299a8 100644 --- a/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithParameterizedElementsWithStepKeyReferencesCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt b/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt index 254fbe0f2..e816da90b 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With Passed Argument Value and Hardcoded Value in Param") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithPassedArgumentAndStringSelectorParamCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt index e8eb29996..7d0bb58e9 100644 --- a/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithPersistedData.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class ActionGroupWithPersistedDataCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt b/dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt index ec6111062..f629f32f1 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithSectionAndDataAsArgumentsCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt index f4faf0773..10206867a 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With Simple Data Usage From Default Argument") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithSimpleDataUsageFromDefaultArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt index 86791407d..54aec35a7 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With Simple Data Usage From Passed Argument") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithSimpleDataUsageFromPassedArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt index 5d8298108..c23b99cab 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With Default Argument Value and Argument Value in Param") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithSingleParameterSelectorFromDefaultArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt index 283a9fdd7..4a0932b99 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With Passed Argument Value and Argument Value in Param") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithSingleParameterSelectorFromPassedArgumentCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt index 2ee5b4bf9..8098142fd 100644 --- a/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt +++ b/dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ActionGroupWithStepKeyReferencesCest { diff --git a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt index ca8325402..a8f80eae6 100644 --- a/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt +++ b/dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class ActionGroupWithTopLevelPersistedDataCest { diff --git a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt index 44a00dbd9..e45207249 100644 --- a/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt +++ b/dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class ArgumentWithSameNameAsElementCest { diff --git a/dev/tests/verification/Resources/AssertTest.txt b/dev/tests/verification/Resources/AssertTest.txt index e7f24b605..bb29759d5 100644 --- a/dev/tests/verification/Resources/AssertTest.txt +++ b/dev/tests/verification/Resources/AssertTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/AssertTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/AssertTest.xml<br>") */ class AssertTestCest { diff --git a/dev/tests/verification/Resources/BasicActionGroupTest.txt b/dev/tests/verification/Resources/BasicActionGroupTest.txt index 02915d1a8..7d8c40f0b 100644 --- a/dev/tests/verification/Resources/BasicActionGroupTest.txt +++ b/dev/tests/verification/Resources/BasicActionGroupTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class BasicActionGroupTestCest { diff --git a/dev/tests/verification/Resources/BasicFunctionalTest.txt b/dev/tests/verification/Resources/BasicFunctionalTest.txt index e78f1b49c..ac42f395e 100644 --- a/dev/tests/verification/Resources/BasicFunctionalTest.txt +++ b/dev/tests/verification/Resources/BasicFunctionalTest.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: A Functional Cest") * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/BasicFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/BasicFunctionalTest.xml<br>") */ class BasicFunctionalTestCest { diff --git a/dev/tests/verification/Resources/BasicMergeTest.txt b/dev/tests/verification/Resources/BasicMergeTest.txt index c6fb58e3a..8171cd892 100644 --- a/dev/tests/verification/Resources/BasicMergeTest.txt +++ b/dev/tests/verification/Resources/BasicMergeTest.txt @@ -16,7 +16,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; * @Title("[NO TESTCASEID]: BasicMergeTest") * @group functional * @group mergeTest - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/MergeFunctionalTest.xml<br>verification/TestModuleMerged/Test/MergeFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/MergeFunctionalTest.xml<br>verification/TestModuleMerged/Test/MergeFunctionalTest.xml<br>") */ class BasicMergeTestCest { diff --git a/dev/tests/verification/Resources/CharacterReplacementTest.txt b/dev/tests/verification/Resources/CharacterReplacementTest.txt index 61729cc8b..24d8e2ab1 100644 --- a/dev/tests/verification/Resources/CharacterReplacementTest.txt +++ b/dev/tests/verification/Resources/CharacterReplacementTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/CharacterReplacementTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/CharacterReplacementTest.xml<br>") */ class CharacterReplacementTestCest { diff --git a/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt b/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt index 8362cf513..86d81f848 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestAddHooks.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ChildExtendedTestAddHooks") * @group Parent - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ChildExtendedTestAddHooksCest { diff --git a/dev/tests/verification/Resources/ChildExtendedTestMerging.txt b/dev/tests/verification/Resources/ChildExtendedTestMerging.txt index 590ba6003..08345bd86 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestMerging.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestMerging.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ChildExtendedTestMerging") * @group Child - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ChildExtendedTestMergingCest { diff --git a/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt b/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt index 5d72176c5..4cca6ec06 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestNoParent.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ChildExtendedTestNoParent") * @group Child - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") * @group skip */ class ChildExtendedTestNoParentCest diff --git a/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt b/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt index 766bfd331..370ffe404 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestRemoveAction.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ChildExtendedTestRemoveAction") * @group Child - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ChildExtendedTestRemoveActionCest { diff --git a/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt b/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt index 8497c29af..50b6e030d 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestRemoveHookAction.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ChildExtendedTestRemoveHookAction") * @group Child - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ChildExtendedTestRemoveHookActionCest { diff --git a/dev/tests/verification/Resources/ChildExtendedTestReplace.txt b/dev/tests/verification/Resources/ChildExtendedTestReplace.txt index 3b2e9d369..ce32f6af1 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestReplace.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestReplace.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ChildExtendedTestReplace") * @group Child - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ChildExtendedTestReplaceCest { diff --git a/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt b/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt index 53ae22361..bbb6c5ef9 100644 --- a/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt +++ b/dev/tests/verification/Resources/ChildExtendedTestReplaceHook.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ChildExtendedTestReplaceHook") * @group Child - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ChildExtendedTestReplaceHookCest { diff --git a/dev/tests/verification/Resources/DataActionsTest.txt b/dev/tests/verification/Resources/DataActionsTest.txt index c3f8400b3..84a94174a 100644 --- a/dev/tests/verification/Resources/DataActionsTest.txt +++ b/dev/tests/verification/Resources/DataActionsTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/DataActionsTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/DataActionsTest.xml<br>") */ class DataActionsTestCest { diff --git a/dev/tests/verification/Resources/DataReplacementTest.txt b/dev/tests/verification/Resources/DataReplacementTest.txt index 2912ee8a2..b75d93f0d 100644 --- a/dev/tests/verification/Resources/DataReplacementTest.txt +++ b/dev/tests/verification/Resources/DataReplacementTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/DataReplacementTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/DataReplacementTest.xml<br>") */ class DataReplacementTestCest { diff --git a/dev/tests/verification/Resources/ExecuteInSeleniumTest.txt b/dev/tests/verification/Resources/ExecuteInSeleniumTest.txt index cfd7a14ce..bbed61691 100644 --- a/dev/tests/verification/Resources/ExecuteInSeleniumTest.txt +++ b/dev/tests/verification/Resources/ExecuteInSeleniumTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExecuteInSeleniumTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExecuteInSeleniumTest.xml<br>") */ class ExecuteInSeleniumTestCest { diff --git a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt index d0b7acc83..ad3696e00 100644 --- a/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt +++ b/dev/tests/verification/Resources/ExecuteJsEscapingTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExecuteJsTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExecuteJsTest.xml<br>") */ class ExecuteJsEscapingTestCest { diff --git a/dev/tests/verification/Resources/ExtendParentDataTest.txt b/dev/tests/verification/Resources/ExtendParentDataTest.txt index d26d91b08..70cb6b70b 100644 --- a/dev/tests/verification/Resources/ExtendParentDataTest.txt +++ b/dev/tests/verification/Resources/ExtendParentDataTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedDataTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedDataTest.xml<br>") */ class ExtendParentDataTestCest { diff --git a/dev/tests/verification/Resources/ExtendedActionGroup.txt b/dev/tests/verification/Resources/ExtendedActionGroup.txt index 3158161d9..8996526ba 100644 --- a/dev/tests/verification/Resources/ExtendedActionGroup.txt +++ b/dev/tests/verification/Resources/ExtendedActionGroup.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ExtendedActionGroupCest { diff --git a/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt b/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt index bde2ce2b3..e4a006c8f 100644 --- a/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt +++ b/dev/tests/verification/Resources/ExtendedChildTestInSuiteCest.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ExtendedChildTestInSuite") * @group ExtendedTestInSuite - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ExtendedChildTestInSuiteCest { diff --git a/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt b/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt index fc67be840..1d5af7d3e 100644 --- a/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt +++ b/dev/tests/verification/Resources/ExtendedChildTestNotInSuite.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ExtendedChildTestNotInSuite") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ExtendedChildTestNotInSuiteCest { diff --git a/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt b/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt index 5ba7a3cce..fde8842e7 100644 --- a/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt +++ b/dev/tests/verification/Resources/ExtendedRemoveActionGroup.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupTest.xml<br>") */ class ExtendedRemoveActionGroupCest { diff --git a/dev/tests/verification/Resources/ExtendingSkippedTest.txt b/dev/tests/verification/Resources/ExtendingSkippedTest.txt index 73a1c89d7..93e9b6a60 100644 --- a/dev/tests/verification/Resources/ExtendingSkippedTest.txt +++ b/dev/tests/verification/Resources/ExtendingSkippedTest.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ChildExtendedTestSkippedParent") * @group Child - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ExtendingSkippedTestCest { diff --git a/dev/tests/verification/Resources/HookActionsTest.txt b/dev/tests/verification/Resources/HookActionsTest.txt index c61cc86e2..0b77325c1 100644 --- a/dev/tests/verification/Resources/HookActionsTest.txt +++ b/dev/tests/verification/Resources/HookActionsTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/HookActionsTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/HookActionsTest.xml<br>") */ class HookActionsTestCest { diff --git a/dev/tests/verification/Resources/LocatorFunctionTest.txt b/dev/tests/verification/Resources/LocatorFunctionTest.txt index f00392778..76c48a921 100644 --- a/dev/tests/verification/Resources/LocatorFunctionTest.txt +++ b/dev/tests/verification/Resources/LocatorFunctionTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/LocatorFunctionTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/LocatorFunctionTest.xml<br>") */ class LocatorFunctionTestCest { diff --git a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt index 90c8c5373..a57ca4471 100644 --- a/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt +++ b/dev/tests/verification/Resources/MergeMassViaInsertAfter.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/BasicFunctionalTest.xml<br>verification/TestModule/Test/MergeFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/BasicFunctionalTest.xml<br>verification/TestModule/Test/MergeFunctionalTest.xml<br>") */ class MergeMassViaInsertAfterCest { diff --git a/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt index df569d66b..7c6fdc906 100644 --- a/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt +++ b/dev/tests/verification/Resources/MergeMassViaInsertBefore.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/BasicFunctionalTest.xml<br>verification/TestModule/Test/MergeFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/BasicFunctionalTest.xml<br>verification/TestModule/Test/MergeFunctionalTest.xml<br>") */ class MergeMassViaInsertBeforeCest { diff --git a/dev/tests/verification/Resources/MergeSkip.txt b/dev/tests/verification/Resources/MergeSkip.txt index bf5903065..b2a1b8918 100644 --- a/dev/tests/verification/Resources/MergeSkip.txt +++ b/dev/tests/verification/Resources/MergeSkip.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/MergeFunctionalTest.xml<br>verification/TestModuleMerged/Test/MergeFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/MergeFunctionalTest.xml<br>verification/TestModuleMerged/Test/MergeFunctionalTest.xml<br>") */ class MergeSkipCest { diff --git a/dev/tests/verification/Resources/MergedActionGroupTest.txt b/dev/tests/verification/Resources/MergedActionGroupTest.txt index e0067b479..a9c740127 100644 --- a/dev/tests/verification/Resources/MergedActionGroupTest.txt +++ b/dev/tests/verification/Resources/MergedActionGroupTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class MergedActionGroupTestCest { diff --git a/dev/tests/verification/Resources/MergedReferencesTest.txt b/dev/tests/verification/Resources/MergedReferencesTest.txt index c4cc7276e..b3fc29966 100644 --- a/dev/tests/verification/Resources/MergedReferencesTest.txt +++ b/dev/tests/verification/Resources/MergedReferencesTest.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: MergedReferencesTest") * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/MergeFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/MergeFunctionalTest.xml<br>") */ class MergedReferencesTestCest { diff --git a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt index 8e5ea542e..5f1db5081 100644 --- a/dev/tests/verification/Resources/MultipleActionGroupsTest.txt +++ b/dev/tests/verification/Resources/MultipleActionGroupsTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @group functional - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class MultipleActionGroupsTestCest { diff --git a/dev/tests/verification/Resources/PageReplacementTest.txt b/dev/tests/verification/Resources/PageReplacementTest.txt index f90a4fda7..cda119999 100644 --- a/dev/tests/verification/Resources/PageReplacementTest.txt +++ b/dev/tests/verification/Resources/PageReplacementTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/PageReplacementTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/PageReplacementTest.xml<br>") */ class PageReplacementTestCest { diff --git a/dev/tests/verification/Resources/ParameterArrayTest.txt b/dev/tests/verification/Resources/ParameterArrayTest.txt index af47657ea..8918bb619 100644 --- a/dev/tests/verification/Resources/ParameterArrayTest.txt +++ b/dev/tests/verification/Resources/ParameterArrayTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ParameterArrayTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ParameterArrayTest.xml<br>") */ class ParameterArrayTestCest { diff --git a/dev/tests/verification/Resources/ParentExtendedTest.txt b/dev/tests/verification/Resources/ParentExtendedTest.txt index 5662da744..8c756f010 100644 --- a/dev/tests/verification/Resources/ParentExtendedTest.txt +++ b/dev/tests/verification/Resources/ParentExtendedTest.txt @@ -15,7 +15,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: ParentExtendedTest") * @group Parent - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ExtendedFunctionalTest.xml<br>") */ class ParentExtendedTestCest { diff --git a/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt b/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt index 2f86f0af7..f6956f5d9 100644 --- a/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt +++ b/dev/tests/verification/Resources/PersistedAndXmlEntityArguments.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/ActionGroupFunctionalTest.xml<br>") */ class PersistedAndXmlEntityArgumentsCest { diff --git a/dev/tests/verification/Resources/PersistedReplacementTest.txt b/dev/tests/verification/Resources/PersistedReplacementTest.txt index 009a8eac2..eb1c9995d 100644 --- a/dev/tests/verification/Resources/PersistedReplacementTest.txt +++ b/dev/tests/verification/Resources/PersistedReplacementTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/PersistedReplacementTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/PersistedReplacementTest.xml<br>") */ class PersistedReplacementTestCest { diff --git a/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt b/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt index 118db353a..426003bc2 100644 --- a/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt +++ b/dev/tests/verification/Resources/PersistenceActionGroupAppendingTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/PersistenceActionGroupAppendingTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/PersistenceActionGroupAppendingTest.xml<br>") */ class PersistenceActionGroupAppendingTestCest { diff --git a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt index 221373be1..41251d2fb 100644 --- a/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt +++ b/dev/tests/verification/Resources/PersistenceCustomFieldsTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/PersistenceCustomFieldsTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/PersistenceCustomFieldsTest.xml<br>") */ class PersistenceCustomFieldsTestCest { diff --git a/dev/tests/verification/Resources/SectionReplacementTest.txt b/dev/tests/verification/Resources/SectionReplacementTest.txt index 2b2a8bcd6..109c198eb 100644 --- a/dev/tests/verification/Resources/SectionReplacementTest.txt +++ b/dev/tests/verification/Resources/SectionReplacementTest.txt @@ -13,7 +13,7 @@ use Yandex\Allure\Adapter\Model\SeverityLevel; use Yandex\Allure\Adapter\Annotation\TestCaseId; /** - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/SectionReplacementTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/SectionReplacementTest.xml<br>") */ class SectionReplacementTestCest { diff --git a/dev/tests/verification/Resources/SkippedTest.txt b/dev/tests/verification/Resources/SkippedTest.txt index dcad67e83..95783ca66 100644 --- a/dev/tests/verification/Resources/SkippedTest.txt +++ b/dev/tests/verification/Resources/SkippedTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: skippedTest") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/SkippedTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/SkippedTest.xml<br>") */ class SkippedTestCest { diff --git a/dev/tests/verification/Resources/SkippedTestNoIssues.txt b/dev/tests/verification/Resources/SkippedTestNoIssues.txt index 3a7ca6f59..e8f4726d9 100644 --- a/dev/tests/verification/Resources/SkippedTestNoIssues.txt +++ b/dev/tests/verification/Resources/SkippedTestNoIssues.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: skippedNoIssuesTest") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/SkippedTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/SkippedTest.xml<br>") * @group skip */ class SkippedTestNoIssuesCest diff --git a/dev/tests/verification/Resources/SkippedTestTwoIssues.txt b/dev/tests/verification/Resources/SkippedTestTwoIssues.txt index d3859978f..4a801856e 100644 --- a/dev/tests/verification/Resources/SkippedTestTwoIssues.txt +++ b/dev/tests/verification/Resources/SkippedTestTwoIssues.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: skippedMultipleIssuesTest") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/SkippedTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/SkippedTest.xml<br>") */ class SkippedTestTwoIssuesCest { diff --git a/dev/tests/verification/Resources/SkippedTestWithHooks.txt b/dev/tests/verification/Resources/SkippedTestWithHooks.txt index 667be6747..ad59d48c3 100644 --- a/dev/tests/verification/Resources/SkippedTestWithHooks.txt +++ b/dev/tests/verification/Resources/SkippedTestWithHooks.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: skippedTestWithHooks") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/SkippedTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/SkippedTest.xml<br>") */ class SkippedTestWithHooksCest { diff --git a/dev/tests/verification/Resources/XmlCommentedActionGroupTest.txt b/dev/tests/verification/Resources/XmlCommentedActionGroupTest.txt index 480e35b73..0eb546335 100644 --- a/dev/tests/verification/Resources/XmlCommentedActionGroupTest.txt +++ b/dev/tests/verification/Resources/XmlCommentedActionGroupTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Action Group With comment block in arguments and action group body") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/XmlCommentedActionGroupTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/XmlCommentedActionGroupTest.xml<br>") */ class XmlCommentedActionGroupTestCest { diff --git a/dev/tests/verification/Resources/XmlCommentedTest.txt b/dev/tests/verification/Resources/XmlCommentedTest.txt index 5b8057099..47d984d9e 100644 --- a/dev/tests/verification/Resources/XmlCommentedTest.txt +++ b/dev/tests/verification/Resources/XmlCommentedTest.txt @@ -14,7 +14,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; /** * @Title("[NO TESTCASEID]: Test With comment blocks in root element 'tests', in annotations and in test body.") - * @Description("<br><br><b><font size=+0.9>Test files</font></b><br><br>verification/TestModule/Test/XmlCommentedTest.xml<br>") + * @Description("<h3>Test files</h3>verification/TestModule/Test/XmlCommentedTest.xml<br>") */ class XmlCommentedTestCest { diff --git a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php index 97335726a..e9e1c344c 100644 --- a/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php +++ b/src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php @@ -5,7 +5,6 @@ */ namespace Magento\FunctionalTestingFramework\Allure\Adapter; -use Codeception\Event\TestEvent; use Codeception\Step\Comment; use Magento\FunctionalTestingFramework\Suite\Handlers\SuiteObjectHandler; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; diff --git a/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php b/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php index 01b385133..90f04abae 100644 --- a/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php +++ b/src/Magento/FunctionalTestingFramework/Codeception/Subscriber/Console.php @@ -18,6 +18,9 @@ use Magento\FunctionalTestingFramework\Util\TestGenerator; use Symfony\Component\Console\Formatter\OutputFormatter; +/** + * @SuppressWarnings(PHPMD) + */ class Console extends \Codeception\Subscriber\Console { /** @@ -60,6 +63,13 @@ public function __construct($extensionOptions = [], $options = []) parent::__construct($options); } + /** + * Triggered event before each test. + * + * @param TestEvent $e + * @return void + * @throws \Exception + */ public function startTest(TestEvent $e) { $test = $e->getTest()->getTestClass(); @@ -80,7 +90,7 @@ public function startTest(TestEvent $e) LoggingUtil::getInstance()->getLogger(self::class)->error($e->getMessage(), $e->getTrace()); } - return parent::startTest($e); + parent::startTest($e); } /** diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php index 0a7ae8ff2..0a188c6d0 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php @@ -13,7 +13,6 @@ use Magento\FunctionalTestingFramework\ObjectManager\ObjectHandlerInterface; use Magento\FunctionalTestingFramework\ObjectManagerFactory; use Magento\FunctionalTestingFramework\DataGenerator\Util\DataExtensionUtil; -use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; class DataObjectHandler implements ObjectHandlerInterface @@ -121,6 +120,7 @@ public function getAllObjects() * @param string[] $parserOutput Primitive array output from the Magento parser. * @return EntityDataObject[] * @throws XmlException + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function processParserOutput($parserOutput) { @@ -134,6 +134,7 @@ private function processParserOutput($parserOutput) $type = $rawEntity[self::_TYPE] ?? null; $data = []; + $deprecated = null; $linkedEntities = []; $uniquenessData = []; $vars = []; diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php index 7fbfe0be7..7181bc994 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php @@ -129,9 +129,7 @@ public function getOperationDefinition($operation, $dataType) * @return void * @throws \Exception * - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings(PHPMD) */ private function initialize() { diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php index a41ee03d8..2204364f5 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/EntityDataObject.php @@ -90,14 +90,14 @@ class EntityDataObject /** * Constructor * - * @param string $name - * @param string $type - * @param string[] $data - * @param string[] $linkedEntities - * @param string[] $uniquenessData - * @param string[] $vars - * @param string $parentEntity - * @param string $filename + * @param string $name + * @param string $type + * @param string[] $data + * @param string[] $linkedEntities + * @param string[] $uniquenessData + * @param string[] $vars + * @param string $parentEntity + * @param string $filename * @param string|null $deprecated */ public function __construct( diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php index a294ea1fd..67fe48300 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Objects/OperationDefinitionObject.php @@ -8,6 +8,7 @@ /** * Class OperationDefinitionObject + * @SuppressWarnings(PHPMD) */ class OperationDefinitionObject { @@ -126,20 +127,20 @@ class OperationDefinitionObject /** * OperationDefinitionObject constructor. - * @param string $name - * @param string $operation - * @param string $dataType - * @param string $apiMethod - * @param string $apiUri - * @param string $auth - * @param array $headers - * @param array $params - * @param array $metaData - * @param string $contentType - * @param boolean $removeBackend - * @param string $successRegex - * @param string $returnRegex - * @param string $returnIndex + * @param string $name + * @param string $operation + * @param string $dataType + * @param string $apiMethod + * @param string $apiUri + * @param string $auth + * @param array $headers + * @param array $params + * @param array $metaData + * @param string $contentType + * @param boolean $removeBackend + * @param string $successRegex + * @param string $returnRegex + * @param string $returnIndex * @param string|null $deprecated * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ diff --git a/src/Magento/FunctionalTestingFramework/Page/Objects/PageObject.php b/src/Magento/FunctionalTestingFramework/Page/Objects/PageObject.php index 19525a415..e4a1acdc0 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Objects/PageObject.php +++ b/src/Magento/FunctionalTestingFramework/Page/Objects/PageObject.php @@ -74,12 +74,12 @@ class PageObject /** * PageObject constructor. - * @param string $name - * @param string $url - * @param string $module - * @param array $sections - * @param boolean $parameterized - * @param string $area + * @param string $name + * @param string $url + * @param string $module + * @param array $sections + * @param boolean $parameterized + * @param string $area * @param string|null $filename * @param string|null $deprecated */ diff --git a/src/Magento/FunctionalTestingFramework/Page/Objects/SectionObject.php b/src/Magento/FunctionalTestingFramework/Page/Objects/SectionObject.php index 57883e393..3674eea16 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Objects/SectionObject.php +++ b/src/Magento/FunctionalTestingFramework/Page/Objects/SectionObject.php @@ -41,8 +41,8 @@ class SectionObject /** * SectionObject constructor. - * @param string $name - * @param array $elements + * @param string $name + * @param array $elements * @param string|null $filename * @param string|null $deprecated */ diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index 1a1e93dab..dc1b158e1 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -104,13 +104,13 @@ class ActionGroupObject /** * ActionGroupObject constructor. * - * @param string $name - * @param array $annotations + * @param string $name + * @param array $annotations * @param ArgumentObject[] $arguments - * @param array $actions - * @param string $parentActionGroup - * @param string $filename - * @param $deprecated + * @param array $actions + * @param string $parentActionGroup + * @param string $filename + * @param string|null $deprecated */ public function __construct( $name, diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index 207d05bc7..44bc8726f 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -84,7 +84,6 @@ class ActionObject */ private $stepKey; - /** * Array of deprecated entities used in action. * @@ -144,13 +143,13 @@ class ActionObject /** * ActionObject constructor. * - * @param string $stepKey - * @param string $type - * @param array $actionAttributes + * @param string $stepKey + * @param string $type + * @param array $actionAttributes * @param string|null $linkedAction - * @param string $order - * @param array $actionOrigin - * @param array $deprecatedUsage + * @param string $order + * @param array $actionOrigin + * @param array $deprecatedUsage */ public function __construct( $stepKey, @@ -573,7 +572,8 @@ private function findAndReplaceReferences($objectHandler, $inputString) } } elseif (get_class($obj) == EntityDataObject::class) { if ($obj->getDeprecated() !== null) { - $this->deprecatedUsage[] = "DEPRECATED DATA ENTITY in Test: " . $match . ' ' . $obj->getDeprecated(); + $this->deprecatedUsage[] = "DEPRECATED DATA ENTITY in Test: " + . $match . ' ' . $obj->getDeprecated(); } $replacement = $this->resolveEntityDataObjectReference($obj, $match); diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php index c55e35b9a..68b9b4c50 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php @@ -17,6 +17,7 @@ /** * Class TestObjectExtractor + * @SuppressWarnings(PHPMD) */ class TestObjectExtractor extends BaseObjectExtractor { @@ -133,6 +134,7 @@ public function extractTestData($testData) } $testAnnotations["description"]['test_files'] = $this->appendFileNamesInDescriptionAnnotation($fileNames); + $testAnnotations["description"][self::TEST_DEPRECATED] = []; if ($deprecated !== null) { $testAnnotations["description"][self::TEST_DEPRECATED][] = $deprecated; LoggingUtil::getInstance()->getLogger(TestObject::class)->deprecation( diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index e16c4cde6..e4e1c34c7 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -463,7 +463,7 @@ private function generateMethodAnnotations($annotationType = null, $annotationNa * Method which return formatted class level annotations based on type and name(s). * * @param string $annotationType - * @param array $annotationName + * @param array $annotationName * @return null|string * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ @@ -509,8 +509,8 @@ private function generateDescriptionAnnotation(array $descriptions) { $descriptionText = ""; - $descriptionText .= $descriptions["main"]; - if (!empty($descriptions[TestObjectExtractor::TEST_DEPRECATED])) { + $descriptionText .= $descriptions["main"] ?? ''; + if (!empty($descriptions[TestObjectExtractor::TEST_DEPRECATED]) || !empty($this->deprecationMessages)) { $deprecatedMessages = array_merge( $descriptions[TestObjectExtractor::TEST_DEPRECATED], $this->deprecationMessages From 3e86d4f8dca940416985fcfbf1ab0f5bf0597f22 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 27 Jan 2020 11:43:22 -0600 Subject: [PATCH 57/67] MFTF deprecation notice attributes - fix review comments --- .../DataGenerator/Handlers/DataObjectHandler.php | 4 ++-- .../Handlers/OperationDefinitionObjectHandler.php | 2 +- .../ObjectManager/ObjectHandlerInterface.php | 2 ++ .../Page/Handlers/PageObjectHandler.php | 2 +- .../Page/Handlers/SectionObjectHandler.php | 4 ++-- .../Test/Util/ActionGroupObjectExtractor.php | 4 ++-- .../Test/Util/BaseObjectExtractor.php | 1 + .../Test/Util/TestObjectExtractor.php | 13 ++++++------- .../Util/TestGenerator.php | 10 +++------- 9 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php index 0a188c6d0..a210710db 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/DataObjectHandler.php @@ -166,8 +166,8 @@ private function processParserOutput($parserOutput) $parentEntity = $rawEntity[self::_EXTENDS]; } - if (array_key_exists('deprecated', $rawEntity)) { - $deprecated = $rawEntity['deprecated']; + if (array_key_exists(self::OBJ_DEPRECATED, $rawEntity)) { + $deprecated = $rawEntity[self::OBJ_DEPRECATED]; LoggingUtil::getInstance()->getLogger(self::class)->deprecation( $deprecated, ["dataName" => $filename, "deprecatedEntity" => $deprecated] diff --git a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php index 7181bc994..8c2ec7b0a 100644 --- a/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/DataGenerator/Handlers/OperationDefinitionObjectHandler.php @@ -144,7 +144,7 @@ private function initialize() $auth = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_AUTH] ?? null; $successRegex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_SUCCESS_REGEX] ?? null; $returnRegex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_RETURN_REGEX] ?? null; - $deprecated = $opDefArray['deprecated'] ?? null; + $deprecated = $opDefArray[ObjectHandlerInterface::OBJ_DEPRECATED] ?? null; $returnIndex = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_RETURN_INDEX] ?? 0; $contentType = $opDefArray[OperationDefinitionObjectHandler::ENTITY_OPERATION_CONTENT_TYPE][0]['value'] ?? null; diff --git a/src/Magento/FunctionalTestingFramework/ObjectManager/ObjectHandlerInterface.php b/src/Magento/FunctionalTestingFramework/ObjectManager/ObjectHandlerInterface.php index 1bc79cbbb..94147dc08 100644 --- a/src/Magento/FunctionalTestingFramework/ObjectManager/ObjectHandlerInterface.php +++ b/src/Magento/FunctionalTestingFramework/ObjectManager/ObjectHandlerInterface.php @@ -11,6 +11,8 @@ */ interface ObjectHandlerInterface { + const OBJ_DEPRECATED = 'deprecated'; + /** * Function to enforce singleton design pattern * diff --git a/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php b/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php index a9c3b7cfb..c310b9bef 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Page/Handlers/PageObjectHandler.php @@ -69,7 +69,7 @@ private function __construct() $sectionNames = array_keys($pageData[self::SECTION] ?? []); $parameterized = $pageData[self::PARAMETERIZED] ?? false; $filename = $pageData[self::FILENAME] ?? null; - $deprecated = $pageData['deprecated'] ?? null; + $deprecated = $pageData[self::OBJ_DEPRECATED] ?? null; if ($deprecated !== null) { LoggingUtil::getInstance()->getLogger(self::class)->deprecation( diff --git a/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php b/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php index a827eac22..15c4fdd9e 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php @@ -75,7 +75,7 @@ private function __construct() $elementLocatorFunc = $elementData[SectionObjectHandler::LOCATOR_FUNCTION] ?? null; $elementTimeout = $elementData[SectionObjectHandler::TIMEOUT] ?? null; $elementParameterized = $elementData[SectionObjectHandler::PARAMETERIZED] ?? false; - $elementDeprecated = $elementData['deprecated'] ?? null; + $elementDeprecated = $elementData[self::OBJ_DEPRECATED] ?? null; if ($elementDeprecated !== null) { LoggingUtil::getInstance()->getLogger(ElementObject::class)->deprecation( $elementDeprecated, @@ -97,7 +97,7 @@ private function __construct() } $filename = $sectionData[self::FILENAME] ?? null; - $sectionDeprecated = $sectionData['deprecated'] ?? null; + $sectionDeprecated = $sectionData[self::OBJ_DEPRECATED] ?? null; if ($sectionDeprecated !== null) { LoggingUtil::getInstance()->getLogger(ElementObject::class)->deprecation( diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php index 0b606c6d8..618cddc09 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php @@ -62,8 +62,8 @@ public function extractActionGroup($actionGroupData) $arguments = []; $deprecated = null; - if (array_key_exists('deprecated', $actionGroupData)) { - $deprecated = $actionGroupData['deprecated']; + if (array_key_exists(self::OBJ_DEPRECATED, $actionGroupData)) { + $deprecated = $actionGroupData[self::OBJ_DEPRECATED]; LoggingUtil::getInstance()->getLogger(ActionGroupObject::class)->deprecation( $deprecated, ["actionGroupName" => $actionGroupData[self::FILENAME], "deprecatedActionGroup" => $deprecated] diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/BaseObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/BaseObjectExtractor.php index 26644937d..516f79d14 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/BaseObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/BaseObjectExtractor.php @@ -13,6 +13,7 @@ class BaseObjectExtractor { const NODE_NAME = 'nodeName'; const NAME = 'name'; + const OBJ_DEPRECATED = 'deprecated'; /** * BaseObjectExtractor constructor. diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php index 68b9b4c50..a25db0935 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/TestObjectExtractor.php @@ -22,7 +22,6 @@ class TestObjectExtractor extends BaseObjectExtractor { const TEST_ANNOTATIONS = 'annotations'; - const TEST_DEPRECATED = 'deprecated'; const TEST_BEFORE_HOOK = 'before'; const TEST_AFTER_HOOK = 'after'; const TEST_FAILED_HOOK = 'failed'; @@ -100,7 +99,7 @@ public function extractTestData($testData) $baseFileName = $fileNames[0]; $module = $this->modulePathExtractor->extractModuleName($baseFileName); $testReference = $testData['extends'] ?? null; - $deprecated = isset($testData[self::TEST_DEPRECATED]) ? $testData[self::TEST_DEPRECATED] : null; + $deprecated = isset($testData[self::OBJ_DEPRECATED]) ? $testData[self::OBJ_DEPRECATED] : null; $testActions = $this->stripDescriptorTags( $testData, self::NODE_NAME, @@ -112,7 +111,7 @@ public function extractTestData($testData) self::TEST_INSERT_BEFORE, self::TEST_INSERT_AFTER, self::TEST_FILENAME, - self::TEST_DEPRECATED, + self::OBJ_DEPRECATED, 'extends' ); @@ -134,9 +133,9 @@ public function extractTestData($testData) } $testAnnotations["description"]['test_files'] = $this->appendFileNamesInDescriptionAnnotation($fileNames); - $testAnnotations["description"][self::TEST_DEPRECATED] = []; + $testAnnotations["description"][self::OBJ_DEPRECATED] = []; if ($deprecated !== null) { - $testAnnotations["description"][self::TEST_DEPRECATED][] = $deprecated; + $testAnnotations["description"][self::OBJ_DEPRECATED][] = $deprecated; LoggingUtil::getInstance()->getLogger(TestObject::class)->deprecation( $deprecated, ["testName" => $filename, "deprecatedTest" => $deprecated] @@ -166,8 +165,8 @@ public function extractTestData($testData) ); } - if (!empty($testData[self::TEST_DEPRECATED])) { - $testAnnotations[self::TEST_DEPRECATED] = $testData[self::TEST_DEPRECATED]; + if (!empty($testData[self::OBJ_DEPRECATED])) { + $testAnnotations[self::OBJ_DEPRECATED] = $testData[self::OBJ_DEPRECATED]; } // TODO extract filename info and store diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index e4e1c34c7..e40f60dcf 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -7,7 +7,6 @@ namespace Magento\FunctionalTestingFramework\Util; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\CredentialStore; use Magento\FunctionalTestingFramework\DataGenerator\Handlers\PersistedObjectHandler; use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject; use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; @@ -17,14 +16,11 @@ use Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; -use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler; use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject; use Magento\FunctionalTestingFramework\Test\Objects\TestObject; -use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil; +use Magento\FunctionalTestingFramework\Test\Util\BaseObjectExtractor; use Magento\FunctionalTestingFramework\Util\Manifest\BaseTestManifest; -use Magento\FunctionalTestingFramework\Util\Manifest\TestManifestFactory; use Magento\FunctionalTestingFramework\Test\Util\ActionObjectExtractor; -use Magento\FunctionalTestingFramework\Test\Util\TestObjectExtractor; use Magento\FunctionalTestingFramework\Util\Filesystem\DirSetupUtil; use Magento\FunctionalTestingFramework\Test\Util\ActionMergeUtil; use Magento\FunctionalTestingFramework\Util\Path\FilePathFormatter; @@ -510,9 +506,9 @@ private function generateDescriptionAnnotation(array $descriptions) $descriptionText = ""; $descriptionText .= $descriptions["main"] ?? ''; - if (!empty($descriptions[TestObjectExtractor::TEST_DEPRECATED]) || !empty($this->deprecationMessages)) { + if (!empty($descriptions[BaseObjectExtractor::OBJ_DEPRECATED]) || !empty($this->deprecationMessages)) { $deprecatedMessages = array_merge( - $descriptions[TestObjectExtractor::TEST_DEPRECATED], + $descriptions[BaseObjectExtractor::OBJ_DEPRECATED], $this->deprecationMessages ); From 9775b5eec21d75f791531bf3f1baabddceda1406 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 27 Jan 2020 12:59:24 -0600 Subject: [PATCH 58/67] MFTF deprecation notice attributes - add verification test --- .../verification/Resources/DeprecatedTest.txt | 34 +++++++++++++++++++ .../ActionGroup/DeprecatedActionGroup.xml | 13 +++++++ .../TestModule/Data/DeprecatedData.xml | 14 ++++++++ .../TestModule/Page/DeprecatedPage.xml | 14 ++++++++ .../TestModule/Section/DeprecatedSection.xml | 14 ++++++++ .../TestModule/Test/DeprecatedTest.xml | 15 ++++++++ .../verification/Tests/DeprecatedTest.php | 22 ++++++++++++ 7 files changed, 126 insertions(+) create mode 100644 dev/tests/verification/Resources/DeprecatedTest.txt create mode 100644 dev/tests/verification/TestModule/ActionGroup/DeprecatedActionGroup.xml create mode 100644 dev/tests/verification/TestModule/Data/DeprecatedData.xml create mode 100644 dev/tests/verification/TestModule/Page/DeprecatedPage.xml create mode 100644 dev/tests/verification/TestModule/Section/DeprecatedSection.xml create mode 100644 dev/tests/verification/TestModule/Test/DeprecatedTest.xml create mode 100644 dev/tests/verification/Tests/DeprecatedTest.php diff --git a/dev/tests/verification/Resources/DeprecatedTest.txt b/dev/tests/verification/Resources/DeprecatedTest.txt new file mode 100644 index 000000000..845d13912 --- /dev/null +++ b/dev/tests/verification/Resources/DeprecatedTest.txt @@ -0,0 +1,34 @@ +<?php +namespace Magento\AcceptanceTest\_default\Backend; + +use Magento\FunctionalTestingFramework\AcceptanceTester; +use \Codeception\Util\Locator; +use Yandex\Allure\Adapter\Annotation\Features; +use Yandex\Allure\Adapter\Annotation\Stories; +use Yandex\Allure\Adapter\Annotation\Title; +use Yandex\Allure\Adapter\Annotation\Description; +use Yandex\Allure\Adapter\Annotation\Parameter; +use Yandex\Allure\Adapter\Annotation\Severity; +use Yandex\Allure\Adapter\Model\SeverityLevel; +use Yandex\Allure\Adapter\Annotation\TestCaseId; + +/** + * @Description("<h3 class='y-label y-label_status_broken'>Deprecated Notice(s):</h3><ul><li>Test is deprecated</li><li>DEPRECATED ACTION GROUP in Test: DeprecatedActionGroup Deprecated action group</li><li>DEPRECATED SECTION in Test: {{DeprecatedSection.deprecatedElement}} Deprecated section</li><li>DEPRECATED ELEMENT in Test: {{DeprecatedSection.deprecatedElement}} Deprecated element</li><li>DEPRECATED DATA ENTITY in Test: {{DeprecatedData.field}} Data entity deprecated</li><li>DEPRECATED PAGE in Test: {{DeprecatedPage.url}} Deprecated page</li></ul><h3>Test files</h3>verification/TestModule/Test/DeprecatedTest.xml<br>") + */ +class DeprecatedTestCest +{ + /** + * @Features({"TestModule"}) + * @Parameter(name = "AcceptanceTester", value="$I") + * @param AcceptanceTester $I + * @return void + * @throws \Exception + */ + public function DeprecatedTest(AcceptanceTester $I) + { + $I->comment("Entering Action Group [deprecatedActionGroup] DeprecatedActionGroup"); + $I->see("deprecated", "#element"); // stepKey: deprecatedSeeDeprecatedActionGroup + $I->comment("Exiting Action Group [deprecatedActionGroup] DeprecatedActionGroup"); + $I->amOnPage("/test.html"); // stepKey: amOnPage + } +} diff --git a/dev/tests/verification/TestModule/ActionGroup/DeprecatedActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/DeprecatedActionGroup.xml new file mode 100644 index 000000000..8f0341c09 --- /dev/null +++ b/dev/tests/verification/TestModule/ActionGroup/DeprecatedActionGroup.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> + <actionGroup name="DeprecatedActionGroup" deprecated="Deprecated action group"> + <see stepKey="deprecatedSee" userInput="{{DeprecatedData.field}}" selector="{{DeprecatedSection.deprecatedElement}}" /> + </actionGroup> +</actionGroups> diff --git a/dev/tests/verification/TestModule/Data/DeprecatedData.xml b/dev/tests/verification/TestModule/Data/DeprecatedData.xml new file mode 100644 index 000000000..060752419 --- /dev/null +++ b/dev/tests/verification/TestModule/Data/DeprecatedData.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="DeprecatedData" deprecated="Data entity deprecated"> + <data key="field">deprecated</data> + </entity> +</entities> diff --git a/dev/tests/verification/TestModule/Page/DeprecatedPage.xml b/dev/tests/verification/TestModule/Page/DeprecatedPage.xml new file mode 100644 index 000000000..316b8b1d7 --- /dev/null +++ b/dev/tests/verification/TestModule/Page/DeprecatedPage.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd"> + <page name="DeprecatedPage" url="/test.html" area="storefront" module="UnknownVendor_TestModule" deprecated="Deprecated page"> + <section name="SampleSection"/> + </page> +</pages> diff --git a/dev/tests/verification/TestModule/Section/DeprecatedSection.xml b/dev/tests/verification/TestModule/Section/DeprecatedSection.xml new file mode 100644 index 000000000..a9ed20d98 --- /dev/null +++ b/dev/tests/verification/TestModule/Section/DeprecatedSection.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> + <section name="DeprecatedSection" deprecated="Deprecated section"> + <element name="deprecatedElement" type="button" selector="#element" deprecated="Deprecated element"/> + </section> +</sections> diff --git a/dev/tests/verification/TestModule/Test/DeprecatedTest.xml b/dev/tests/verification/TestModule/Test/DeprecatedTest.xml new file mode 100644 index 000000000..cc5ae4994 --- /dev/null +++ b/dev/tests/verification/TestModule/Test/DeprecatedTest.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + <test name="DeprecatedTest" deprecated="Test is deprecated"> + <actionGroup ref="DeprecatedActionGroup" stepKey="deprecatedActionGroup" /> + <amOnPage url="{{DeprecatedPage.url}}" stepKey="amOnPage" /> + </test> +</tests> diff --git a/dev/tests/verification/Tests/DeprecatedTest.php b/dev/tests/verification/Tests/DeprecatedTest.php new file mode 100644 index 000000000..dbbe78ea9 --- /dev/null +++ b/dev/tests/verification/Tests/DeprecatedTest.php @@ -0,0 +1,22 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace tests\verification\Tests; + +use tests\util\MftfTestCase; + +class DeprecatedTest extends MftfTestCase +{ + /** + * Tests flat generation of a deprecated test which uses deprecated entities. + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testDeprecatedTestEntitiesGeneration() + { + $this->generateAndCompareTest('DeprecatedTest'); + } +} From 28fe7572e30fe0f48a08587f2325d85edc4fa835 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Mon, 27 Jan 2020 13:47:45 -0600 Subject: [PATCH 59/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments added exception catch for incorrect action group definition --- docs/commands/mftf.md | 7 +++++-- .../StaticCheck/ActionGroupArgumentsCheck.php | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/commands/mftf.md b/docs/commands/mftf.md index 83c48507e..b2c36dae4 100644 --- a/docs/commands/mftf.md +++ b/docs/commands/mftf.md @@ -494,12 +494,15 @@ vendor/bin/mftf static-checks testDependencies ```bash vendor/bin/mftf static-checks actionGroupArguments ``` +```bash +vendor/bin/mftf static-checks testDependencies actionGroupArguments +``` #### Existing static checks * Test Dependency: Checks that test dependencies do not violate Magento module's composer dependencies. -* Unused Arguments: Checks that action groups do not have unused arguments. - +* Action Group Unused Arguments: Checks that action groups do not have unused arguments. + ### `upgrade:tests` Applies all the MFTF major version upgrade scripts to test components in the given path (`test.xml`, `data.xml`, etc). diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php index 6c5c34203..2b25fcf65 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php @@ -7,6 +7,7 @@ namespace Magento\FunctionalTestingFramework\StaticCheck; use Magento\FunctionalTestingFramework\Config\MftfApplicationConfig; +use Magento\FunctionalTestingFramework\Exceptions\XmlException; use Magento\FunctionalTestingFramework\Test\Handlers\ActionGroupObjectHandler; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; use Symfony\Component\Console\Input\InputInterface; @@ -138,9 +139,10 @@ private function findUnusedArguments($actionGroupXml) preg_match_all(self::ACTIONGROUP_ARGUMENT_REGEX_PATTERN, $actionGroupXml, $arguments); preg_match(self::ACTIONGROUP_NAME_REGEX_PATTERN, $actionGroupXml, $actionGroupName); - - $actionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroupName[1]); - + try { + $actionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroupName[1]); + } catch (XmlException $e){ + } foreach ($arguments[1] as $argument) { //pattern to match all argument references $patterns = [ From 27ca94d76491ff14f4562461a6a30e6d12717a66 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 27 Jan 2020 13:52:57 -0600 Subject: [PATCH 60/67] MFTF deprecation notice attributes - added 1 more verification test - reduce cli output of deprecated entities --- .../Resources/DeprecatedEntitiesTest.txt | 34 +++++++++++++++++++ .../Test/DeprecatedEntitiesTest.xml | 15 ++++++++ .../verification/Tests/DeprecatedTest.php | 11 ++++++ .../Config/Reader/Filesystem.php | 3 +- .../Test/Objects/ActionObject.php | 3 +- .../Util/ActionGroupAnnotationExtractor.php | 3 +- .../Test/Util/AnnotationExtractor.php | 3 +- .../Util/Logger/MftfLogger.php | 20 ++++++----- 8 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 dev/tests/verification/Resources/DeprecatedEntitiesTest.txt create mode 100644 dev/tests/verification/TestModule/Test/DeprecatedEntitiesTest.xml diff --git a/dev/tests/verification/Resources/DeprecatedEntitiesTest.txt b/dev/tests/verification/Resources/DeprecatedEntitiesTest.txt new file mode 100644 index 000000000..489cb66ea --- /dev/null +++ b/dev/tests/verification/Resources/DeprecatedEntitiesTest.txt @@ -0,0 +1,34 @@ +<?php +namespace Magento\AcceptanceTest\_default\Backend; + +use Magento\FunctionalTestingFramework\AcceptanceTester; +use \Codeception\Util\Locator; +use Yandex\Allure\Adapter\Annotation\Features; +use Yandex\Allure\Adapter\Annotation\Stories; +use Yandex\Allure\Adapter\Annotation\Title; +use Yandex\Allure\Adapter\Annotation\Description; +use Yandex\Allure\Adapter\Annotation\Parameter; +use Yandex\Allure\Adapter\Annotation\Severity; +use Yandex\Allure\Adapter\Model\SeverityLevel; +use Yandex\Allure\Adapter\Annotation\TestCaseId; + +/** + * @Description("<h3 class='y-label y-label_status_broken'>Deprecated Notice(s):</h3><ul><li>DEPRECATED ACTION GROUP in Test: DeprecatedActionGroup Deprecated action group</li><li>DEPRECATED SECTION in Test: {{DeprecatedSection.deprecatedElement}} Deprecated section</li><li>DEPRECATED ELEMENT in Test: {{DeprecatedSection.deprecatedElement}} Deprecated element</li><li>DEPRECATED DATA ENTITY in Test: {{DeprecatedData.field}} Data entity deprecated</li><li>DEPRECATED PAGE in Test: {{DeprecatedPage.url}} Deprecated page</li></ul><h3>Test files</h3>verification/TestModule/Test/DeprecatedEntitiesTest.xml<br>") + */ +class DeprecatedEntitiesTestCest +{ + /** + * @Features({"TestModule"}) + * @Parameter(name = "AcceptanceTester", value="$I") + * @param AcceptanceTester $I + * @return void + * @throws \Exception + */ + public function DeprecatedEntitiesTest(AcceptanceTester $I) + { + $I->comment("Entering Action Group [deprecatedActionGroup] DeprecatedActionGroup"); + $I->see("deprecated", "#element"); // stepKey: deprecatedSeeDeprecatedActionGroup + $I->comment("Exiting Action Group [deprecatedActionGroup] DeprecatedActionGroup"); + $I->amOnPage("/test.html"); // stepKey: amOnPage + } +} diff --git a/dev/tests/verification/TestModule/Test/DeprecatedEntitiesTest.xml b/dev/tests/verification/TestModule/Test/DeprecatedEntitiesTest.xml new file mode 100644 index 000000000..733a34e80 --- /dev/null +++ b/dev/tests/verification/TestModule/Test/DeprecatedEntitiesTest.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + <test name="DeprecatedEntitiesTest"> + <actionGroup ref="DeprecatedActionGroup" stepKey="deprecatedActionGroup" /> + <amOnPage url="{{DeprecatedPage.url}}" stepKey="amOnPage" /> + </test> +</tests> diff --git a/dev/tests/verification/Tests/DeprecatedTest.php b/dev/tests/verification/Tests/DeprecatedTest.php index dbbe78ea9..78e3326b9 100644 --- a/dev/tests/verification/Tests/DeprecatedTest.php +++ b/dev/tests/verification/Tests/DeprecatedTest.php @@ -19,4 +19,15 @@ public function testDeprecatedTestEntitiesGeneration() { $this->generateAndCompareTest('DeprecatedTest'); } + + /** + * Tests flat generation of a test which uses deprecated entities. + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testDeprecatedEntitiesOnlyGeneration() + { + $this->generateAndCompareTest('DeprecatedEntitiesTest'); + } } diff --git a/src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php b/src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php index 2f2cb8ad3..db96b010c 100644 --- a/src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php +++ b/src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php @@ -235,7 +235,8 @@ protected function validateSchema($configMerger, $filename = null) $error = str_replace(PHP_EOL, "", $error); LoggingUtil::getInstance()->getLogger(Filesystem::class)->criticalFailure( "Schema validation error ", - ($filename ? [ "file"=> $filename, "error" => $error]: ["error" => $error]) + ($filename ? [ "file"=> $filename, "error" => $error]: ["error" => $error]), + true ); } throw new \Exception("Schema validation errors found in xml file(s)" . $filename); diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index 44bc8726f..45b5db69d 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -314,7 +314,8 @@ public function trimAssertionAttributes() if ($appConfig->getPhase() == MftfApplicationConfig::GENERATION_PHASE && $appConfig->verboseEnabled()) { LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation( "use of one line Assertion actions will be deprecated in MFTF 3.0.0, please use nested syntax", - ["action" => $this->type, "stepKey" => $this->stepKey] + ["action" => $this->type, "stepKey" => $this->stepKey], + true ); } return; diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupAnnotationExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupAnnotationExtractor.php index 44b004105..9d3a9877e 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupAnnotationExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupAnnotationExtractor.php @@ -64,7 +64,8 @@ private function validateMissingAnnotations($annotationObjects, $filename) $message = "Action Group File {$filename} is missing required annotations."; LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation( $message, - ["actionGroup" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)] + ["actionGroup" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)], + true ); } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php index d30ed351e..1859f3195 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/AnnotationExtractor.php @@ -164,7 +164,8 @@ private function validateMissingAnnotations($annotationObjects, $filename) $message = "Test {$filename} is missing required annotations."; LoggingUtil::getInstance()->getLogger(ActionObject::class)->deprecation( $message, - ["testName" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)] + ["testName" => $filename, "missingAnnotations" => implode(", ", $missingAnnotations)], + true ); } } diff --git a/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php b/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php index 0a52f6b6b..7306aab67 100644 --- a/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php +++ b/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php @@ -15,15 +15,17 @@ class MftfLogger extends Logger /** * Prints a deprecation warning, as well as adds a log at the WARNING level. * - * @param string $message The log message. - * @param array $context The log context. + * @param string $message The log message. + * @param array $context The log context. + * @param bool $verbose * @return void + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException */ - public function deprecation($message, array $context = []) + public function deprecation($message, array $context = [], $verbose = false) { $message = "DEPRECATION: " . $message; // Suppress print during unit testing - if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) { + if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE && $verbose) { print ($message . json_encode($context) . "\n"); } parent::warning($message, $context); @@ -32,15 +34,17 @@ public function deprecation($message, array $context = []) /** * Prints a critical failure, as well as adds a log at the CRITICAL level. * - * @param string $message The log message. - * @param array $context The log context. + * @param string $message The log message. + * @param array $context The log context. + * @param bool $verbose * @return void + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException */ - public function criticalFailure($message, array $context = []) + public function criticalFailure($message, array $context = [], $verbose = false) { $message = "FAILURE: " . $message; // Suppress print during unit testing - if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE) { + if (MftfApplicationConfig::getConfig()->getPhase() !== MftfApplicationConfig::UNIT_TEST_PHASE && $verbose) { print ($message . implode("\n", $context) . "\n"); } parent::critical($message, $context); From 6e9aeca43780844991858d58b7e728a2663b54b3 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 27 Jan 2020 14:04:36 -0600 Subject: [PATCH 61/67] MFTF deprecation notice attributes --- .../Page/Handlers/SectionObjectHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php b/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php index 15c4fdd9e..2736100fd 100644 --- a/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php +++ b/src/Magento/FunctionalTestingFramework/Page/Handlers/SectionObjectHandler.php @@ -100,7 +100,7 @@ private function __construct() $sectionDeprecated = $sectionData[self::OBJ_DEPRECATED] ?? null; if ($sectionDeprecated !== null) { - LoggingUtil::getInstance()->getLogger(ElementObject::class)->deprecation( + LoggingUtil::getInstance()->getLogger(SectionObject::class)->deprecation( $sectionDeprecated, ["sectionName" => $filename, "deprecatedSection" => $sectionDeprecated] ); From a30065ad18d82fae4b9bcda5137076425cd1d1b9 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 27 Jan 2020 14:13:21 -0600 Subject: [PATCH 62/67] MFTF deprecation notice attributes --- .../FunctionalTestingFramework/Util/Logger/MftfLogger.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php b/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php index 7306aab67..9e3510ab7 100644 --- a/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php +++ b/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php @@ -16,8 +16,8 @@ class MftfLogger extends Logger * Prints a deprecation warning, as well as adds a log at the WARNING level. * * @param string $message The log message. - * @param array $context The log context. - * @param bool $verbose + * @param array $context The log context. + * @param bool $verbose * @return void * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException */ @@ -35,8 +35,8 @@ public function deprecation($message, array $context = [], $verbose = false) * Prints a critical failure, as well as adds a log at the CRITICAL level. * * @param string $message The log message. - * @param array $context The log context. - * @param bool $verbose + * @param array $context The log context. + * @param bool $verbose * @return void * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException */ From 64b6bdf6e135f6e19ff744fec6298fd25bde698e Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 27 Jan 2020 14:24:56 -0600 Subject: [PATCH 63/67] MFTF deprecation notice attributes --- .../Util/Logger/MftfLogger.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php b/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php index 9e3510ab7..3983a755a 100644 --- a/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php +++ b/src/Magento/FunctionalTestingFramework/Util/Logger/MftfLogger.php @@ -15,9 +15,9 @@ class MftfLogger extends Logger /** * Prints a deprecation warning, as well as adds a log at the WARNING level. * - * @param string $message The log message. - * @param array $context The log context. - * @param bool $verbose + * @param string $message The log message. + * @param array $context The log context. + * @param boolean $verbose * @return void * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException */ @@ -34,9 +34,9 @@ public function deprecation($message, array $context = [], $verbose = false) /** * Prints a critical failure, as well as adds a log at the CRITICAL level. * - * @param string $message The log message. - * @param array $context The log context. - * @param bool $verbose + * @param string $message The log message. + * @param array $context The log context. + * @param boolean $verbose * @return void * @throws \Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException */ From 1c7c6ced5563b36416e028384bdef909d497a887 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Mon, 27 Jan 2020 14:30:31 -0600 Subject: [PATCH 64/67] MQE-1676: Add a static-check that ensures action groups do not have unused arguments included $$argument.name$$ pattern + fixed unit tests --- .../StaticCheck/ActionGroupArgumentsCheck.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php index 2b25fcf65..32c7661fe 100644 --- a/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php +++ b/src/Magento/FunctionalTestingFramework/StaticCheck/ActionGroupArgumentsCheck.php @@ -27,7 +27,7 @@ class ActionGroupArgumentsCheck implements StaticCheckInterface const ACTIONGROUP_NAME_REGEX_PATTERN = '/<actionGroup name=["\']([^\'"]*)/'; const ERROR_LOG_FILENAME = 'mftf-arguments-checks'; - const ERROR_LOG_MESSAGE = 'MFTF Unused Arguments Check'; + const ERROR_LOG_MESSAGE = 'MFTF Action Group Unused Arguments Check'; /** * Array containing all errors found after running the execute() function. @@ -141,13 +141,13 @@ private function findUnusedArguments($actionGroupXml) preg_match(self::ACTIONGROUP_NAME_REGEX_PATTERN, $actionGroupXml, $actionGroupName); try { $actionGroup = ActionGroupObjectHandler::getInstance()->getObject($actionGroupName[1]); - } catch (XmlException $e){ + } catch (XmlException $e) { } foreach ($arguments[1] as $argument) { //pattern to match all argument references $patterns = [ '(\{{2}' . $argument . '(\.[a-zA-Z0-9_\[\]\(\).,\'\/ ]+)?}{2})', - '([(,\s\']' . $argument . '(\.[a-zA-Z0-9_\[\]]+)?[),\s\'])' + '([(,\s\'$$]' . $argument . '(\.[a-zA-Z0-9_$\[\]]+)?[),\s\'])' ]; // matches entity references if (preg_match($patterns[0], $actionGroupXml)) { From 826674886bd015a6d499ced36fa7037cd439a9b0 Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Thu, 30 Jan 2020 10:04:34 -0600 Subject: [PATCH 65/67] MQE-1969: Updated CHANGELOG.md and bumped MFTF package version --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ composer.json | 2 +- composer.lock | 3 ++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8c4ca9b8..558b3be13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,39 @@ Magento Functional Testing Framework Changelog ================================================ + +2.6.0 +----- + +* Traceability + * MFTF generated cest files are fully compatible for Codeception `dry-run`. +* Modularity + * `mftf generate:tests` and `mftf run:test` commands now accept suite scoped test names in format `[<suitename:>testname]...`. +* Maintainability + * Support `deprecated` syntax for the following test entities: + * Test + * Action Group + * Data + * Page + * Section + * Section Element + * Suite + + See DevDocs for details + * Improved `mftf static-checks` command to allow executing all or specific static checks. + * Added a new static check that checks and reports unused arguments in action groups. +* Customizability + * AWS Secrets Manager is added as an additional credential storage. + * See DevDocs for details + +### Fixes +* Fixed missing before, after, failed steps in cest file when generating tests with `--allow-skipped` option. +* Fixed suites and tests display issue in Allure `Suites` page after `mftf run:group` command. +* `createData` action now shows a meaningful error message at runtime when the entity does not exist. + +### GitHub Issues/Pull requests: +* [#537](https://github.com/magento/magento2-functional-testing-framework/pull/537) -- Refactor of TestGenerator class +* [#538](https://github.com/magento/magento2-functional-testing-framework/pull/538) -- FEATURE: <magentoCron> command to execute Cron Jobs + 2.5.4 ----- [Demo Video](https://www.youtube.com/watch?v=tguvkw1HWKg) diff --git a/composer.json b/composer.json index ca1c02572..e6d081114 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.5.4", + "version": "2.6.0", "license": "AGPL-3.0", "keywords": ["magento", "automation", "functional", "testing"], "config": { diff --git a/composer.lock b/composer.lock index 6bfc30ab9..051ab6441 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": "2325a3a38edb33b24f6e33bd3009fd8a", + "content-hash": "859ddf6506836faaabb056ae7b377c63", "packages": [ { "name": "allure-framework/allure-codeception", @@ -1710,6 +1710,7 @@ "selenium", "webdriver" ], + "abandoned": "php-webdriver/webdriver", "time": "2018-05-16T17:37:13+00:00" }, { From a1adbc1655749a1de114f907ee9f26ae5fd03bf4 Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Thu, 30 Jan 2020 10:29:09 -0600 Subject: [PATCH 66/67] MQE-1969: Updated CHANGELOG.md and bumped MFTF package version --- CHANGELOG.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 558b3be13..5910e8b38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Magento Functional Testing Framework Changelog * Traceability * MFTF generated cest files are fully compatible for Codeception `dry-run`. * Modularity - * `mftf generate:tests` and `mftf run:test` commands now accept suite scoped test names in format `[<suitename:>testname]...`. + * `mftf generate:tests` and `mftf run:test` commands now accept suite scoped test names in format `[suitename:testname]...`. * Maintainability * Support `deprecated` syntax for the following test entities: * Test @@ -17,12 +17,11 @@ Magento Functional Testing Framework Changelog * Section * Section Element * Suite - - See DevDocs for details + * See DevDocs for details * Improved `mftf static-checks` command to allow executing all or specific static checks. * Added a new static check that checks and reports unused arguments in action groups. * Customizability - * AWS Secrets Manager is added as an additional credential storage. + * AWS Secrets Manager has been added as an additional credential storage. * See DevDocs for details ### Fixes From ac9f32c3f13ebd3d1894247f5a735c72ccd77668 Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Thu, 30 Jan 2020 10:32:50 -0600 Subject: [PATCH 67/67] MQE-1969: Updated CHANGELOG.md and bumped MFTF package version --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5910e8b38..fe6bd9822 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,10 @@ Magento Functional Testing Framework Changelog * Test * Action Group * Data + * Metadata * Page * Section * Section Element - * Suite * See DevDocs for details * Improved `mftf static-checks` command to allow executing all or specific static checks. * Added a new static check that checks and reports unused arguments in action groups.