From 77ffd1a8f6ea513a24e52fb3c0ac09175f92ad28 Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Mon, 22 Jan 2018 08:48:19 -0600 Subject: [PATCH 01/14] MQE-498: Ability to pass simple values into an action group - Fixed check for isPersisted, added trim to variableName to be able to replace into 'string' parameters. --- .../Test/Objects/ActionGroupObject.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index 19f666bc5..de607de77 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -199,14 +199,14 @@ private function replaceAttributeArgumentInVariable( // Check if arguments has a mapping for the given variableName if ($variableName === false) { - $variableName = $variable; + $variableName = trim($variable, "'"); } if (!array_key_exists($variableName, $arguments)) { return $attributeValue; } - $isPersisted = strstr($arguments[$variableName], '$'); + $isPersisted = preg_match('/\$[\w.]+\$/', $arguments[$variableName]); if ($isPersisted) { return $this->replacePersistedArgument( $arguments[$variableName], From 554ed5bbd5939df840ab39d32cb9a390d191eda1 Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Mon, 22 Jan 2018 10:26:53 -0600 Subject: [PATCH 02/14] MQE-498: Ability to pass simple values into an action group - Fixed case of sending in $data.key$ as simple data. --- .../Test/Objects/ActionGroupObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index de607de77..02478fbde 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -245,7 +245,7 @@ private function replacePersistedArgument($replacement, $attributeValue, $fullVa // parameter replacements require changing of (arg.field) to ($arg.field$) if ($isParameter) { - $fullReplacement = str_replace($variable, trim($replacement, '$'), $fullVariable); + $fullReplacement = str_replace($variable, trim($replacement, '$'), trim($fullVariable, "'")); $newAttributeValue = str_replace($fullVariable, $scope . $fullReplacement . $scope, $newAttributeValue); } else { $newAttributeValue = str_replace('{{', $scope, str_replace('}}', $scope, $newAttributeValue)); From 747e47ff3e222e0cdf0cf2ce11d0835a0409bc0b Mon Sep 17 00:00:00 2001 From: KevinBKozan Date: Thu, 25 Jan 2018 10:52:19 -0600 Subject: [PATCH 03/14] MQE-498: Ability to pass simple values into an action group - verification test updates - Added simpleData array to actionGroupObject --- ...WithSimpleDataUsageFromDefaultArgument.txt | 35 +++++++++++++++++++ ...pWithSimpleDataUsageFromPassedArgument.txt | 35 +++++++++++++++++++ .../ActionGroup/BasicActionGroup.xml | 8 +++++ .../TestModule/Test/ActionGroupTest.xml | 28 +++++++++++++++ .../Tests/ActionGroupGenerationTest.php | 22 ++++++++++++ .../Test/Objects/ActionGroupObject.php | 17 ++++++++- .../Test/Util/ActionGroupObjectExtractor.php | 15 +++++--- .../Test/etc/actionGroupSchema.xsd | 1 + 8 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt create mode 100644 dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt new file mode 100644 index 000000000..89fea2d46 --- /dev/null +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt @@ -0,0 +1,35 @@ +see("stringLiteral", "class.stringLiteral"); + $I->see("stringLiteral", "#element .stringLiteral"); + } +} diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt new file mode 100644 index 000000000..0e98ac21b --- /dev/null +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt @@ -0,0 +1,35 @@ +see("overrideString", "class.overrideString"); + $I->see("overrideString", "#element .overrideString"); + } +} diff --git a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml index a06ac7967..83e2dca2c 100644 --- a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml @@ -34,4 +34,12 @@ + + + + + + + + diff --git a/dev/tests/verification/TestModule/Test/ActionGroupTest.xml b/dev/tests/verification/TestModule/Test/ActionGroupTest.xml index adba9622e..05aeef572 100644 --- a/dev/tests/verification/TestModule/Test/ActionGroupTest.xml +++ b/dev/tests/verification/TestModule/Test/ActionGroupTest.xml @@ -63,4 +63,32 @@ + + + + + + </annotations> + + <actionGroup ref="actionGroupWithSimpleDataUsage" stepKey="actionGroup1"> + <argument name="someArgument" value="overrideString"/> + </actionGroup> + + <actionGroup ref="actionGroupWithSimpleDataUsage" stepKey="actionGroup2"> + <argument name="someArgument" value="simpleData.firstname"/> + </actionGroup> + + <actionGroup ref="actionGroupWithSimpleDataUsage" stepKey="actionGroup3"> + <argument name="someArgument" value="$persisted.data$"/> + </actionGroup> + </test> + + <test name="ActionGroupWithSimpleDataUsageFromDefaultArgument"> + <annotations> + <severity value="SEVERE"/> + <title value="Action Group With Simple Data Usage From Default Argument"/> + </annotations> + + <actionGroup ref="actionGroupWithSimpleDataUsage" stepKey="actionGroup"/> + </test> </tests> diff --git a/dev/tests/verification/Tests/ActionGroupGenerationTest.php b/dev/tests/verification/Tests/ActionGroupGenerationTest.php index e25ac6c87..c71cfe505 100644 --- a/dev/tests/verification/Tests/ActionGroupGenerationTest.php +++ b/dev/tests/verification/Tests/ActionGroupGenerationTest.php @@ -96,4 +96,26 @@ public function testActionGroupWithMultipleParameterSelectorsFromDefaultArgument { $this->validateGenerateAndContents('ActionGroupWithMultipleParameterSelectorsFromDefaultArgument'); } + + /** + * Test generation of a test referencing an action group with simple passed data. + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testActionGroupWithSimpleDataUsageFromPassedArgument() + { + $this->validateGenerateAndContents('ActionGroupWithSimpleDataUsageFromPassedArgument'); + } + + /** + * Test generation of a test referencing an action group with default data. + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testActionGroupWithSimpleDataUsageFromDefaultArgument() + { + $this->validateGenerateAndContents('ActionGroupWithSimpleDataUsageFromDefaultArgument'); + } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index 02478fbde..e823c5173 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -41,6 +41,12 @@ class ActionGroupObject */ private $arguments; + /** + * An array used to store the default simple arguments if the user does not specify any + * @var + */ + private $simpleArguments; + /** * ActionGroupObject constructor. * @@ -48,7 +54,7 @@ class ActionGroupObject * @param string $arguments * @param array $actions */ - public function __construct($name, $arguments, $actions) + public function __construct($name, $arguments, $simpleArguments, $actions) { $this->varAttributes = array_merge( ActionObject::SELECTOR_ENABLED_ATTRIBUTES, @@ -57,6 +63,7 @@ public function __construct($name, $arguments, $actions) $this->varAttributes[] = ActionObject::ACTION_ATTRIBUTE_URL; $this->name = $name; $this->arguments = $arguments; + $this->simpleArguments = $simpleArguments; $this->parsedActions = $actions; } @@ -206,6 +213,14 @@ private function replaceAttributeArgumentInVariable( return $attributeValue; } + /// TODO: CHECK IF ARGUMENT IS SIMPLE OR NOT. + /// + /// If simple determine if it's xml.data, $persisted.Data$, or stringLiteral + /// + /// If not simple, Do regular replacement + /// + + $isPersisted = preg_match('/\$[\w.]+\$/', $arguments[$variableName]); if ($isPersisted) { return $this->replacePersistedArgument( diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php index 4f2b78174..e90967eae 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php @@ -15,6 +15,7 @@ class ActionGroupObjectExtractor extends BaseObjectExtractor { const DEFAULT_VALUE = 'defaultValue'; const ACTION_GROUP_ARGUMENTS = 'arguments'; + const ACTION_GROUP_SIMPLE_DATA = 'simpleData'; /** * Action Object Extractor for converting actions into objects @@ -40,6 +41,7 @@ public function __construct() public function extractActionGroup($actionGroupData) { $arguments = []; + $simpleArguments = []; $actionData = $this->stripDescriptorTags( $actionGroupData, @@ -51,12 +53,14 @@ public function extractActionGroup($actionGroupData) $actions = $this->actionObjectExtractor->extractActions($actionData); if (array_key_exists(self::ACTION_GROUP_ARGUMENTS, $actionGroupData)) { - $arguments = $this->extractArguments($actionGroupData[self::ACTION_GROUP_ARGUMENTS]); + $arguments = $this->extractArguments($actionGroupData[self::ACTION_GROUP_ARGUMENTS], false); + $simpleArguments = $this->extractArguments($actionGroupData[self::ACTION_GROUP_ARGUMENTS], true); } return new ActionGroupObject( $actionGroupData[self::NAME], $arguments, + $simpleArguments, $actions ); } @@ -66,9 +70,10 @@ public function extractActionGroup($actionGroupData) * by argument name. * * @param array $arguments + * @param bool $simpleData * @return array */ - private function extractArguments($arguments) + private function extractArguments($arguments, $simpleData) { $parsedArguments = []; $argData = $this->stripDescriptorTags( @@ -77,9 +82,11 @@ private function extractArguments($arguments) ); foreach ($argData as $argName => $argValue) { - $parsedArguments[$argName] = $argValue[self::DEFAULT_VALUE] ?? null; + $simpleArgument = $argValue[self::ACTION_GROUP_SIMPLE_DATA] ?? false; + if ($simpleArgument == $simpleData) { + $parsedArguments[$argName] = $argValue[self::DEFAULT_VALUE] ?? null; + } } - return $parsedArguments; } } diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd index 09b8a14a9..dc190347a 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd @@ -24,6 +24,7 @@ <xs:complexType> <xs:attribute type="xs:string" name="name" use="required"/> <xs:attribute type="xs:string" name="defaultValue"/> + <xs:attribute type="xs:boolean" name="simpleData" default="false"/> </xs:complexType> </xs:element> </xs:sequence> From 9fa48d824b7ec5c9eadec0e6c64127ac46fb79ab Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Fri, 2 Feb 2018 09:53:25 -0600 Subject: [PATCH 04/14] MQE-498: Ability to pass simple values into an action group - Added check for simpleArgument matching, and different resolution strategy for them. - Verification and Unit test updates with more usecases --- .../Test/Objects/ActionGroupObjectTest.php | 70 ++++++++++++++++- .../unit/Util/ActionGroupObjectBuilder.php | 22 +++++- ...pWithSimpleDataUsageFromPassedArgument.txt | 4 + .../Test/Objects/ActionGroupObject.php | 77 ++++++++++++++++--- 4 files changed, 160 insertions(+), 13 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php index f9fc3346c..dfb5e2e9f 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php @@ -53,6 +53,14 @@ public function testGetStepsWithCustomArgs() $steps = $actionGroupUnderTest->getSteps(['arg1' => 'data2'], self::ACTION_GROUP_MERGE_KEY); $this->assertOnMergeKeyAndActionValue($steps, ['userInput' => 'testValue2']); + + // Simple Data + $actionGroupUnderTest = (new ActionGroupObjectBuilder()) + ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{simple}}'])]) + ->build(); + + $steps = $actionGroupUnderTest->getSteps(['simple' => 'data2.field2'], self::ACTION_GROUP_MERGE_KEY); + $this->assertOnMergeKeyAndActionValue($steps, ['userInput' => 'testValue2']); } /** @@ -66,6 +74,14 @@ public function testGetStepsWithPersistedArgs() $steps = $actionGroupUnderTest->getSteps(['arg1' => '$data3$'], self::ACTION_GROUP_MERGE_KEY); $this->assertOnMergeKeyAndActionValue($steps, ['userInput' => '$data3.field2$']); + + // Simple Data + $actionGroupUnderTest = (new ActionGroupObjectBuilder()) + ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{simple}}'])]) + ->build(); + + $steps = $actionGroupUnderTest->getSteps(['simple' => '$data3.field2$'], self::ACTION_GROUP_MERGE_KEY); + $this->assertOnMergeKeyAndActionValue($steps, ['userInput' => '$data3.field2$']); } /** @@ -111,6 +127,12 @@ public function testGetStepsWithNoArgs() */ public function testGetStepsWithParameterizedArg() { + // Mock Entity Object Handler + $this->setEntityObjectHandlerReturn(function ($entityName) { + if ($entityName == "data2") { + return (new EntityDataObjectBuilder())->withDataFields(['field2' => 'testValue2'])->build(); + } + }); // mock the section object handler response $element = new ElementObject("element1", "textArea", ".selector {{var1}}", null, null, true); $section = new SectionObject("testSection", ["element1" => $element]); @@ -120,14 +142,58 @@ public function testGetStepsWithParameterizedArg() $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects( - [new ActionObject('action1', 'testAction', ['selector' => '{{section1.element1(arg1.field1)}}'])] + [new ActionObject('action1', 'testAction', ['selector' => '{{section1.element1(arg1.field2)}}'])] ) ->build(); - $steps = $actionGroupUnderTest->getSteps(['arg1' => '$someData$'], self::ACTION_GROUP_MERGE_KEY); + // XML Data + $steps = $actionGroupUnderTest->getSteps(['arg1' => 'data2'], self::ACTION_GROUP_MERGE_KEY); + $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector testValue2']); + + // Persisted Data + $steps = $actionGroupUnderTest->getSteps(['arg1' => '$data2$'], self::ACTION_GROUP_MERGE_KEY); + $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector $data2.field2$']); + } + + /** + * Tests a parameterized section reference in an action group resolved with user simpleArgs. + */ + public function testGetStepsWithParameterizedSimpleArg() + { + // Mock Entity Object Handler + $this->setEntityObjectHandlerReturn(function ($entityName) { + if ($entityName == "data2") { + return (new EntityDataObjectBuilder())->withDataFields(['field2' => 'testValue2'])->build(); + } + }); + // mock the section object handler response + $element = new ElementObject("element1", "textArea", ".selector {{var1}}", null, null, true); + $section = new SectionObject("testSection", ["element1" => $element]); + // bypass the private constructor + $sectionInstance = AspectMock::double(SectionObjectHandler::class, ['getObject' => $section])->make(); + AspectMock::double(SectionObjectHandler::class, ['getInstance' => $sectionInstance]); + + $actionGroupUnderTest = (new ActionGroupObjectBuilder()) + ->withActionObjects( + [new ActionObject('action1', 'testAction', ['selector' => '{{section1.element1(simple)}}'])] + ) + ->build(); + + // String Literal + $steps = $actionGroupUnderTest->getSteps(['simple' => 'stringLiteral'], self::ACTION_GROUP_MERGE_KEY); + $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector stringLiteral']); + + // XML Data + $steps = $actionGroupUnderTest->getSteps(['simple' => 'data2.field2'], self::ACTION_GROUP_MERGE_KEY); + $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector testValue2']); + + // Persisted Data + $steps = $actionGroupUnderTest->getSteps(['simple' => '$someData.field1$'], self::ACTION_GROUP_MERGE_KEY); $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector $someData.field1$']); + } + /** * Tests a data reference in an action group resolved with a persisted reference used in another function. */ diff --git a/dev/tests/unit/Util/ActionGroupObjectBuilder.php b/dev/tests/unit/Util/ActionGroupObjectBuilder.php index aa2346e0b..e1e7a74c5 100644 --- a/dev/tests/unit/Util/ActionGroupObjectBuilder.php +++ b/dev/tests/unit/Util/ActionGroupObjectBuilder.php @@ -28,12 +28,19 @@ class ActionGroupObjectBuilder private $actionObjects = []; /** - * Action Group Object Builder default arguments. + * Action Group Object Builder default entity arguments. * * @var array */ private $arguments = ['arg1' => 'data1']; + /** + * Action Group Object Builder default simple arguments. + * + * @var array + */ + private $simpleArguments = ['simple' => 'data1']; + /** * Setter for the Action Group Object name * @@ -58,6 +65,18 @@ public function withArguments($args) return $this; } + /** + * Setter for the Action Group Object simpleArguments + * + * @param array $args + * @return ActionGroupObjectBuilder + */ + public function withSimpleArguments($args) + { + $this->simpleArguments = $args; + return $this; + } + /** * Setter for the Action Group Object action objects * @@ -90,6 +109,7 @@ public function build() return new ActionGroupObject( $this->name, $this->arguments, + $this->simpleArguments, $this->actionObjects ); } diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt index 0e98ac21b..526d10dcf 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt @@ -31,5 +31,9 @@ class ActionGroupWithSimpleDataUsageFromPassedArgumentCest { $I->see("overrideString", "class.overrideString"); $I->see("overrideString", "#element .overrideString"); + $I->see("John", "class.John"); + $I->see("John", "#element .John"); + $I->see($persisted->getCreatedDataByName('data'), "class." . $persisted->getCreatedDataByName('data')); + $I->see($persisted->getCreatedDataByName('data'), "#element ." . $persisted->getCreatedDataByName('data')); } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index e823c5173..9ba39e8d6 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -43,7 +43,7 @@ class ActionGroupObject /** * An array used to store the default simple arguments if the user does not specify any - * @var + * @var array */ private $simpleArguments; @@ -51,7 +51,8 @@ class ActionGroupObject * ActionGroupObject constructor. * * @param string $name - * @param string $arguments + * @param array $arguments + * @param array $simpleArguments * @param array $actions */ public function __construct($name, $arguments, $simpleArguments, $actions) @@ -78,7 +79,7 @@ public function __construct($name, $arguments, $simpleArguments, $actions) public function getSteps($arguments, $actionReferenceKey) { $mergeUtil = new ActionMergeUtil($this->name, "ActionGroup"); - $args = $this->arguments; + $args = array_merge($this->arguments, $this->simpleArguments); $emptyArguments = array_keys($args, null, true); if (!empty($emptyArguments) && $arguments !== null) { $diff = array_diff($emptyArguments, array_keys($arguments)); @@ -213,13 +214,14 @@ private function replaceAttributeArgumentInVariable( return $attributeValue; } - /// TODO: CHECK IF ARGUMENT IS SIMPLE OR NOT. - /// - /// If simple determine if it's xml.data, $persisted.Data$, or stringLiteral - /// - /// If not simple, Do regular replacement - /// - + if (array_key_exists($variableName, $this->simpleArguments)) { + return $this->replaceSimpleArgument( + $arguments[$variableName], + $variableName, + $attributeValue, + $isInnerArgument + ); + } $isPersisted = preg_match('/\$[\w.]+\$/', $arguments[$variableName]); if ($isPersisted) { @@ -236,6 +238,61 @@ private function replaceAttributeArgumentInVariable( return preg_replace("/(?<![\w]){$variableName}(?![(\w])/", $arguments[$variableName], $attributeValue); } + /** + * Resolves simple arguments depending on type passed in, and returns the appropriate format for simple replacement. + * Takes in boolean to determine if the replacement is being done with an inner argument (as in if it's a parameter) + * + * Example Type Non Inner Inner + * {{XML.DATA}}: {{XML.DATA}} XML.DATA + * $TEST.DATA$: $TEST.DATA$ $TEST.DATA$ + * stringLiteral stringLiteral 'stringLiteral' + * + * @param string $argument + * @param boolean $isInnerArgument + * @return string + */ + private function resolveSimpleArgument($argument, $isInnerArgument) + { + if (preg_match('/\$[\w]+\.[\w]+\$/', $argument)) { + //$persisted.data$ or $$persisted.data$$, notation not different if in parameter + return $argument; + + } elseif (preg_match('/[\w]+\.[\w]+/', $argument)) { + //xml.data + if ($isInnerArgument) { + return $argument; + } else { + return "{{" . $argument . "}}"; + } + } else { + //stringLiteral + if ($isInnerArgument) { + return "'" . $argument . "'"; + } else { + return $argument; + } + } + } + + /** + * Replaces any arguments that were declared as simpleData="true". + * Takes in isInnerArgument to determine what kind of replacement to expect: {{data}} vs section.element(data) + * @param string $argument + * @param string $variableName + * @param string $attributeValue + * @param boolean $isInnerArgument + * @return string + */ + private function replaceSimpleArgument($argument, $variableName, $attributeValue, $isInnerArgument) + { + $argumentValue = $this->resolveSimpleArgument($argument, $isInnerArgument); + if ($isInnerArgument) { + return preg_replace("/(?<![\w]){$variableName}(?![(\w])/", $argumentValue, $attributeValue); + } else { + return preg_replace("/{{(?<![\w]){$variableName}(?![(\w])}}/", $argumentValue, $attributeValue); + } + } + /** * Replaces args with replacements given, behavior is specific to persisted arguments. * @param string $replacement From 51611400f0b08e6d821439769069da004ae146da Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Wed, 7 Feb 2018 13:54:23 -0600 Subject: [PATCH 05/14] MQE-498: Ability to pass simple values into an action group - simpledata -> data enum. - no longer two different $argument arrays, only one but a new one with name=>type mapping. --- .../Test/Objects/ActionGroupObjectTest.php | 6 +++ .../unit/Util/ActionGroupObjectBuilder.php | 10 ++--- .../ActionGroup/BasicActionGroup.xml | 2 +- .../Test/Objects/ActionGroupObject.php | 20 +++++----- .../Test/Util/ActionGroupObjectExtractor.php | 38 +++++++++++++------ .../Test/etc/actionGroupSchema.xsd | 11 +++++- 6 files changed, 60 insertions(+), 27 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php index dfb5e2e9f..ac86a2d0f 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php @@ -49,6 +49,7 @@ public function testGetStepsWithCustomArgs() $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{arg1.field2}}'])]) + ->withArgumentTypes(['arg1' => 'entity']) ->build(); $steps = $actionGroupUnderTest->getSteps(['arg1' => 'data2'], self::ACTION_GROUP_MERGE_KEY); @@ -57,6 +58,7 @@ public function testGetStepsWithCustomArgs() // Simple Data $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{simple}}'])]) + ->withArgumentTypes(['simple' => 'string']) ->build(); $steps = $actionGroupUnderTest->getSteps(['simple' => 'data2.field2'], self::ACTION_GROUP_MERGE_KEY); @@ -70,6 +72,7 @@ public function testGetStepsWithPersistedArgs() { $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{arg1.field2}}'])]) + ->withArgumentTypes(['arg1' => 'entity']) ->build(); $steps = $actionGroupUnderTest->getSteps(['arg1' => '$data3$'], self::ACTION_GROUP_MERGE_KEY); @@ -78,6 +81,7 @@ public function testGetStepsWithPersistedArgs() // Simple Data $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{simple}}'])]) + ->withArgumentTypes(['simple' => 'string']) ->build(); $steps = $actionGroupUnderTest->getSteps(['simple' => '$data3.field2$'], self::ACTION_GROUP_MERGE_KEY); @@ -144,6 +148,7 @@ public function testGetStepsWithParameterizedArg() ->withActionObjects( [new ActionObject('action1', 'testAction', ['selector' => '{{section1.element1(arg1.field2)}}'])] ) + ->withArgumentTypes(['arg1' => 'entity']) ->build(); // XML Data @@ -177,6 +182,7 @@ public function testGetStepsWithParameterizedSimpleArg() ->withActionObjects( [new ActionObject('action1', 'testAction', ['selector' => '{{section1.element1(simple)}}'])] ) + ->withArgumentTypes(['simple' => 'string']) ->build(); // String Literal diff --git a/dev/tests/unit/Util/ActionGroupObjectBuilder.php b/dev/tests/unit/Util/ActionGroupObjectBuilder.php index e1e7a74c5..666d8bbb2 100644 --- a/dev/tests/unit/Util/ActionGroupObjectBuilder.php +++ b/dev/tests/unit/Util/ActionGroupObjectBuilder.php @@ -39,7 +39,7 @@ class ActionGroupObjectBuilder * * @var array */ - private $simpleArguments = ['simple' => 'data1']; + private $argumentTypes = ['arg1' => 'entity']; /** * Setter for the Action Group Object name @@ -66,14 +66,14 @@ public function withArguments($args) } /** - * Setter for the Action Group Object simpleArguments + * Setter for the Action Group Object $argumentTypes * * @param array $args * @return ActionGroupObjectBuilder */ - public function withSimpleArguments($args) + public function withArgumentTypes($args) { - $this->simpleArguments = $args; + $this->argumentTypes = $args; return $this; } @@ -109,7 +109,7 @@ public function build() return new ActionGroupObject( $this->name, $this->arguments, - $this->simpleArguments, + $this->argumentTypes, $this->actionObjects ); } diff --git a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml index 83e2dca2c..92678693e 100644 --- a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml @@ -37,7 +37,7 @@ <actionGroup name="actionGroupWithSimpleDataUsage"> <arguments> - <argument name="someArgument" simpleData="true" defaultValue="stringLiteral"/> + <argument name="someArgument" data="string" defaultValue="stringLiteral"/> </arguments> <see stepKey="see1" selector="class.{{someArgument}}" userInput="{{someArgument}}"/> <see selector="{{SampleSection.oneParamElement(someArgument)}}" userInput="{{someArgument}}" stepKey="see2" /> diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index 9ba39e8d6..a3cab1944 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -7,6 +7,7 @@ namespace Magento\FunctionalTestingFramework\Test\Objects; use Magento\FunctionalTestingFramework\Exceptions\TestReferenceException; +use Magento\FunctionalTestingFramework\Test\Util\ActionGroupObjectExtractor; use Magento\FunctionalTestingFramework\Test\Util\ActionMergeUtil; /** @@ -35,27 +36,28 @@ class ActionGroupObject private $parsedActions = []; /** - * An array used to store the default entities if the user does not specify any + * An array used to store argument names to values * * @var array */ private $arguments; /** - * An array used to store the default simple arguments if the user does not specify any + * An array used to map argument names to types + * * @var array */ - private $simpleArguments; + private $argumentTypes; /** * ActionGroupObject constructor. * * @param string $name * @param array $arguments - * @param array $simpleArguments + * @param array $argumentTypes * @param array $actions */ - public function __construct($name, $arguments, $simpleArguments, $actions) + public function __construct($name, $arguments, $argumentTypes, $actions) { $this->varAttributes = array_merge( ActionObject::SELECTOR_ENABLED_ATTRIBUTES, @@ -64,7 +66,7 @@ public function __construct($name, $arguments, $simpleArguments, $actions) $this->varAttributes[] = ActionObject::ACTION_ATTRIBUTE_URL; $this->name = $name; $this->arguments = $arguments; - $this->simpleArguments = $simpleArguments; + $this->argumentTypes = $argumentTypes; $this->parsedActions = $actions; } @@ -79,7 +81,7 @@ public function __construct($name, $arguments, $simpleArguments, $actions) public function getSteps($arguments, $actionReferenceKey) { $mergeUtil = new ActionMergeUtil($this->name, "ActionGroup"); - $args = array_merge($this->arguments, $this->simpleArguments); + $args = $this->arguments; $emptyArguments = array_keys($args, null, true); if (!empty($emptyArguments) && $arguments !== null) { $diff = array_diff($emptyArguments, array_keys($arguments)); @@ -214,7 +216,8 @@ private function replaceAttributeArgumentInVariable( return $attributeValue; } - if (array_key_exists($variableName, $this->simpleArguments)) { + $argumentType = $this->argumentTypes[$variableName]; + if (in_array($argumentType, ActionGroupObjectExtractor::ACTION_GROUP_SIMPLE_DATA_TYPES)) { return $this->replaceSimpleArgument( $arguments[$variableName], $variableName, @@ -256,7 +259,6 @@ private function resolveSimpleArgument($argument, $isInnerArgument) if (preg_match('/\$[\w]+\.[\w]+\$/', $argument)) { //$persisted.data$ or $$persisted.data$$, notation not different if in parameter return $argument; - } elseif (preg_match('/[\w]+\.[\w]+/', $argument)) { //xml.data if ($isInnerArgument) { diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php index e90967eae..d1653e2bd 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php @@ -15,7 +15,9 @@ class ActionGroupObjectExtractor extends BaseObjectExtractor { const DEFAULT_VALUE = 'defaultValue'; const ACTION_GROUP_ARGUMENTS = 'arguments'; - const ACTION_GROUP_SIMPLE_DATA = 'simpleData'; + const ACTION_GROUP_DATA = 'data'; + const ACTION_GROUP_DATA_ENTITY = 'entity'; + const ACTION_GROUP_SIMPLE_DATA_TYPES = ['string', 'int', 'float', 'boolean']; /** * Action Object Extractor for converting actions into objects @@ -41,7 +43,7 @@ public function __construct() public function extractActionGroup($actionGroupData) { $arguments = []; - $simpleArguments = []; + $argumentMap = []; $actionData = $this->stripDescriptorTags( $actionGroupData, @@ -53,27 +55,44 @@ public function extractActionGroup($actionGroupData) $actions = $this->actionObjectExtractor->extractActions($actionData); if (array_key_exists(self::ACTION_GROUP_ARGUMENTS, $actionGroupData)) { - $arguments = $this->extractArguments($actionGroupData[self::ACTION_GROUP_ARGUMENTS], false); - $simpleArguments = $this->extractArguments($actionGroupData[self::ACTION_GROUP_ARGUMENTS], true); + $arguments = $this->extractArguments($actionGroupData[self::ACTION_GROUP_ARGUMENTS]); + $argumentMap = $this->extractArgumentTypeMap($actionGroupData[self::ACTION_GROUP_ARGUMENTS]); } return new ActionGroupObject( $actionGroupData[self::NAME], $arguments, - $simpleArguments, + $argumentMap, $actions ); } + /** + * Extracts argName => dataType mapping. + * @param array $arguments + * @return array + */ + private function extractArgumentTypeMap($arguments) + { + $parsedTypeMap = []; + $argData = $this->stripDescriptorTags( + $arguments, + self::NODE_NAME + ); + foreach ($argData as $argName => $argValue) { + $parsedTypeMap[$argName] = $argValue[self::ACTION_GROUP_DATA] ?? self::ACTION_GROUP_DATA_ENTITY; + } + return $parsedTypeMap; + } + /** * Method which extract argument declarations from an action group and returns an array of default values indexed * by argument name. * * @param array $arguments - * @param bool $simpleData * @return array */ - private function extractArguments($arguments, $simpleData) + private function extractArguments($arguments) { $parsedArguments = []; $argData = $this->stripDescriptorTags( @@ -82,10 +101,7 @@ private function extractArguments($arguments, $simpleData) ); foreach ($argData as $argName => $argValue) { - $simpleArgument = $argValue[self::ACTION_GROUP_SIMPLE_DATA] ?? false; - if ($simpleArgument == $simpleData) { - $parsedArguments[$argName] = $argValue[self::DEFAULT_VALUE] ?? null; - } + $parsedArguments[$argName] = $argValue[self::DEFAULT_VALUE] ?? null; } return $parsedArguments; } diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd index dc190347a..7cfd7f231 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd @@ -24,7 +24,7 @@ <xs:complexType> <xs:attribute type="xs:string" name="name" use="required"/> <xs:attribute type="xs:string" name="defaultValue"/> - <xs:attribute type="xs:boolean" name="simpleData" default="false"/> + <xs:attribute type="dataTypeEnum" name="data" default="entity"/> </xs:complexType> </xs:element> </xs:sequence> @@ -33,4 +33,13 @@ </xs:choice> <xs:attribute type="xs:string" name="name" use="required"/> </xs:complexType> + <xs:simpleType name="dataTypeEnum" final="restriction"> + <xs:restriction base="xs:string"> + <xs:enumeration value="int"/> + <xs:enumeration value="float"/> + <xs:enumeration value="boolean"/> + <xs:enumeration value="string"/> + <xs:enumeration value="entity"/> + </xs:restriction> + </xs:simpleType> </xs:schema> From b170f5b5504f601c6d5f0cc9ad36d409e682ae16 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Thu, 8 Feb 2018 11:33:54 -0600 Subject: [PATCH 06/14] MQE-498: Ability to pass simple values into an action group - Refactor to use arguments as ArgumentObjects. --- .../Test/Objects/ActionGroupObjectTest.php | 19 ++- .../unit/Util/ActionGroupObjectBuilder.php | 22 +-- .../Test/Objects/ActionGroupObject.php | 139 ++++++++++-------- .../Test/Objects/ArgumentObject.php | 136 +++++++++++++++++ .../Test/Util/ActionGroupObjectExtractor.php | 31 +--- 5 files changed, 234 insertions(+), 113 deletions(-) create mode 100644 src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php index ac86a2d0f..c68ebfadd 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php @@ -14,6 +14,7 @@ use Magento\FunctionalTestingFramework\Page\Objects\SectionObject; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; use Magento\FunctionalTestingFramework\Test\Objects\ActionObject; +use Magento\FunctionalTestingFramework\Test\Objects\ArgumentObject; use PHPUnit\Framework\TestCase; use tests\unit\Util\ActionGroupObjectBuilder; use tests\unit\Util\EntityDataObjectBuilder; @@ -49,7 +50,7 @@ public function testGetStepsWithCustomArgs() $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{arg1.field2}}'])]) - ->withArgumentTypes(['arg1' => 'entity']) + ->withArguments([new ArgumentObject('arg1', null, 'entity')]) ->build(); $steps = $actionGroupUnderTest->getSteps(['arg1' => 'data2'], self::ACTION_GROUP_MERGE_KEY); @@ -58,7 +59,7 @@ public function testGetStepsWithCustomArgs() // Simple Data $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{simple}}'])]) - ->withArgumentTypes(['simple' => 'string']) + ->withArguments([new ArgumentObject('simple', null, 'string')]) ->build(); $steps = $actionGroupUnderTest->getSteps(['simple' => 'data2.field2'], self::ACTION_GROUP_MERGE_KEY); @@ -72,7 +73,7 @@ public function testGetStepsWithPersistedArgs() { $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{arg1.field2}}'])]) - ->withArgumentTypes(['arg1' => 'entity']) + ->withArguments([new ArgumentObject('arg1', null, 'entity')]) ->build(); $steps = $actionGroupUnderTest->getSteps(['arg1' => '$data3$'], self::ACTION_GROUP_MERGE_KEY); @@ -81,7 +82,7 @@ public function testGetStepsWithPersistedArgs() // Simple Data $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{simple}}'])]) - ->withArgumentTypes(['simple' => 'string']) + ->withArguments([new ArgumentObject('simple', null, 'string')]) ->build(); $steps = $actionGroupUnderTest->getSteps(['simple' => '$data3.field2$'], self::ACTION_GROUP_MERGE_KEY); @@ -101,6 +102,7 @@ public function testGetStepsWithNoFieldArg() $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{arg1}}'])]) + ->withArguments([new ArgumentObject('arg1', null, 'entity')]) ->build(); $steps = $actionGroupUnderTest->getSteps(['arg1' => 'data2.field2'], self::ACTION_GROUP_MERGE_KEY); @@ -148,7 +150,7 @@ public function testGetStepsWithParameterizedArg() ->withActionObjects( [new ActionObject('action1', 'testAction', ['selector' => '{{section1.element1(arg1.field2)}}'])] ) - ->withArgumentTypes(['arg1' => 'entity']) + ->withArguments([new ArgumentObject('arg1', null, 'entity')]) ->build(); // XML Data @@ -182,7 +184,7 @@ public function testGetStepsWithParameterizedSimpleArg() ->withActionObjects( [new ActionObject('action1', 'testAction', ['selector' => '{{section1.element1(simple)}}'])] ) - ->withArgumentTypes(['simple' => 'string']) + ->withArguments([new ArgumentObject('simple', null, 'string')]) ->build(); // String Literal @@ -207,6 +209,7 @@ public function testGetStepsWithOuterScopePersistence() { $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{arg1.field1}}'])]) + ->withArguments([new ArgumentObject('arg1', null, 'entity')]) ->build(); $steps = $actionGroupUnderTest->getSteps(['arg1' => '$$someData$$'], self::ACTION_GROUP_MERGE_KEY); @@ -219,7 +222,7 @@ public function testGetStepsWithOuterScopePersistence() public function testExceptionOnMissingActions() { $actionGroupUnderTest = (new ActionGroupObjectBuilder()) - ->withArguments(['arg1' => null]) + ->withArguments([new ArgumentObject('arg1', null, 'entity')]) ->build(); $this->expectException(TestReferenceException::class); @@ -233,7 +236,7 @@ public function testExceptionOnMissingActions() public function testExceptionOnMissingArguments() { $actionGroupUnderTest = (new ActionGroupObjectBuilder()) - ->withArguments(['arg1' => null]) + ->withArguments([new ArgumentObject('arg1', null, 'entity')]) ->build(); $this->expectException(TestReferenceException::class); diff --git a/dev/tests/unit/Util/ActionGroupObjectBuilder.php b/dev/tests/unit/Util/ActionGroupObjectBuilder.php index 666d8bbb2..4844776d5 100644 --- a/dev/tests/unit/Util/ActionGroupObjectBuilder.php +++ b/dev/tests/unit/Util/ActionGroupObjectBuilder.php @@ -32,14 +32,7 @@ class ActionGroupObjectBuilder * * @var array */ - private $arguments = ['arg1' => 'data1']; - - /** - * Action Group Object Builder default simple arguments. - * - * @var array - */ - private $argumentTypes = ['arg1' => 'entity']; + private $arguments = []; /** * Setter for the Action Group Object name @@ -65,18 +58,6 @@ public function withArguments($args) return $this; } - /** - * Setter for the Action Group Object $argumentTypes - * - * @param array $args - * @return ActionGroupObjectBuilder - */ - public function withArgumentTypes($args) - { - $this->argumentTypes = $args; - return $this; - } - /** * Setter for the Action Group Object action objects * @@ -109,7 +90,6 @@ public function build() return new ActionGroupObject( $this->name, $this->arguments, - $this->argumentTypes, $this->actionObjects ); } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index a3cab1944..e19d62031 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -42,22 +42,14 @@ class ActionGroupObject */ private $arguments; - /** - * An array used to map argument names to types - * - * @var array - */ - private $argumentTypes; - /** * ActionGroupObject constructor. * * @param string $name - * @param array $arguments - * @param array $argumentTypes + * @param ArgumentObject[] $arguments * @param array $actions */ - public function __construct($name, $arguments, $argumentTypes, $actions) + public function __construct($name, $arguments, $actions) { $this->varAttributes = array_merge( ActionObject::SELECTOR_ENABLED_ATTRIBUTES, @@ -66,7 +58,6 @@ public function __construct($name, $arguments, $argumentTypes, $actions) $this->varAttributes[] = ActionObject::ACTION_ATTRIBUTE_URL; $this->name = $name; $this->arguments = $arguments; - $this->argumentTypes = $argumentTypes; $this->parsedActions = $actions; } @@ -82,7 +73,7 @@ public function getSteps($arguments, $actionReferenceKey) { $mergeUtil = new ActionMergeUtil($this->name, "ActionGroup"); $args = $this->arguments; - $emptyArguments = array_keys($args, null, true); + $emptyArguments = $this->findEmptyDefaultArguments(); if (!empty($emptyArguments) && $arguments !== null) { $diff = array_diff($emptyArguments, array_keys($arguments)); if (!empty($diff)) { @@ -93,13 +84,53 @@ public function getSteps($arguments, $actionReferenceKey) $error = 'Not enough arguments given for actionGroup "' . $this->name . '"'; throw new TestReferenceException($error); } - if ($arguments) { - $args = array_merge($args, $arguments); - } + $args = $this->overrideDefaultArguments($arguments); return $mergeUtil->resolveActionSteps($this->getResolvedActionsWithArgs($args, $actionReferenceKey), true); } + /** + * Finds and returns named list of $this->arguments that have no defaultValue + * @return array + */ + private function findEmptyDefaultArguments() + { + $emptyDefaultArguments = []; + foreach ($this->arguments as $argumentObj) { + if ($argumentObj->getValue() === null) { + $emptyDefaultArguments[] = $argumentObj->getName(); + } + } + return $emptyDefaultArguments; + } + + /** + * Iterates through given $arguments and overrides ActionGroup's argument values, if any are found. + * @param array $arguments + * @return ArgumentObject[] + */ + private function overrideDefaultArguments($arguments) + { + if ($arguments === null) { + return $this->arguments; + } + $newArgumentList = []; + + // Clone $this->arguments to not override default argument definitions + foreach ($this->arguments as $argumentObj) { + $newArgumentList[] = clone $argumentObj; + } + + foreach ($arguments as $argumentName => $argumentValue) { + $matchedArgument = $this->findArgumentByName($argumentName, $newArgumentList); + if (isset($matchedArgument)) { + $matchedArgument->overrideValue($argumentValue); + } + } + + return $newArgumentList; + } + /** * Function which takes a set of arguments to be appended to an action objects fields returns resulting * action objects with proper argument.field references. @@ -212,24 +243,24 @@ private function replaceAttributeArgumentInVariable( $variableName = trim($variable, "'"); } - if (!array_key_exists($variableName, $arguments)) { + $matchedArgument = $this->findArgumentByName($variableName, $arguments); + if ($matchedArgument === null) { return $attributeValue; } - $argumentType = $this->argumentTypes[$variableName]; - if (in_array($argumentType, ActionGroupObjectExtractor::ACTION_GROUP_SIMPLE_DATA_TYPES)) { + if (in_array($matchedArgument->getDataType(), ArgumentObject::ARGUMENT_SIMPLE_DATA_TYPES)) { return $this->replaceSimpleArgument( - $arguments[$variableName], + $matchedArgument->getResolvedValue($isInnerArgument), $variableName, $attributeValue, $isInnerArgument ); } - $isPersisted = preg_match('/\$[\w.]+\$/', $arguments[$variableName]); + $isPersisted = preg_match('/\$[\w.]+\$/', $matchedArgument->getResolvedValue($isInnerArgument)); if ($isPersisted) { return $this->replacePersistedArgument( - $arguments[$variableName], + $matchedArgument->getResolvedValue($isInnerArgument), $attributeValue, $variable, $variableName, @@ -238,56 +269,24 @@ private function replaceAttributeArgumentInVariable( } //replace argument ONLY when there is no letters attached before after (ex. category.name vs categoryTreeButton) - return preg_replace("/(?<![\w]){$variableName}(?![(\w])/", $arguments[$variableName], $attributeValue); - } - - /** - * Resolves simple arguments depending on type passed in, and returns the appropriate format for simple replacement. - * Takes in boolean to determine if the replacement is being done with an inner argument (as in if it's a parameter) - * - * Example Type Non Inner Inner - * {{XML.DATA}}: {{XML.DATA}} XML.DATA - * $TEST.DATA$: $TEST.DATA$ $TEST.DATA$ - * stringLiteral stringLiteral 'stringLiteral' - * - * @param string $argument - * @param boolean $isInnerArgument - * @return string - */ - private function resolveSimpleArgument($argument, $isInnerArgument) - { - if (preg_match('/\$[\w]+\.[\w]+\$/', $argument)) { - //$persisted.data$ or $$persisted.data$$, notation not different if in parameter - return $argument; - } elseif (preg_match('/[\w]+\.[\w]+/', $argument)) { - //xml.data - if ($isInnerArgument) { - return $argument; - } else { - return "{{" . $argument . "}}"; - } - } else { - //stringLiteral - if ($isInnerArgument) { - return "'" . $argument . "'"; - } else { - return $argument; - } - } + return preg_replace( + "/(?<![\w]){$variableName}(?![(\w])/", + $matchedArgument->getResolvedValue($isInnerArgument), + $attributeValue + ); } /** * Replaces any arguments that were declared as simpleData="true". * Takes in isInnerArgument to determine what kind of replacement to expect: {{data}} vs section.element(data) - * @param string $argument + * @param string $argumentValue * @param string $variableName * @param string $attributeValue * @param boolean $isInnerArgument * @return string */ - private function replaceSimpleArgument($argument, $variableName, $attributeValue, $isInnerArgument) + private function replaceSimpleArgument($argumentValue, $variableName, $attributeValue, $isInnerArgument) { - $argumentValue = $this->resolveSimpleArgument($argument, $isInnerArgument); if ($isInnerArgument) { return preg_replace("/(?<![\w]){$variableName}(?![(\w])/", $argumentValue, $attributeValue); } else { @@ -328,4 +327,24 @@ private function replacePersistedArgument($replacement, $attributeValue, $fullVa return $newAttributeValue; } + + /** + * Searches through ActionGroupObject's arguments and returns first argument wi + * @param string $name + * @param array $argumentList + * @return ArgumentObject|null + */ + private function findArgumentByName($name, $argumentList) + { + $matchedArgument = array_filter( + $argumentList, + function ($e) use ($name) { + return $e->getName() == $name; + } + ); + if (isset($matchedArgument[0])) { + return $matchedArgument[0]; + } + return null; + } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php new file mode 100644 index 000000000..c32255170 --- /dev/null +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php @@ -0,0 +1,136 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\FunctionalTestingFramework\Test\Objects; + +/** + * Class ArgumentObject + */ +class ArgumentObject +{ + const ARGUMENT_NAME = 'name'; + const ARGUMENT_DEFAULT_VALUE = 'defaultValue'; + const ARGUMENT_DATA_TYPE = 'data'; + const ARGUMENT_DATA_ENTITY = 'entity'; + const ARGUMENT_DATA_STRING = 'string'; + const ARGUMENT_SIMPLE_DATA_TYPES = ['string', 'int', 'float', 'boolean']; + + /** + * Name of the argument. + * @var string + */ + public $name; + + /** + * Value of the argument. DefaultValue on argument creation + * @var string + */ + private $value; + + /** + * Data type of the argument. + * @var string + */ + private $dataType; + + /** + * ArgumentObject constructor. + * @param string $name + * @param string $value + * @param string $dataType + */ + public function __construct($name, $value, $dataType) + { + $this->name = $name; + $this->value = $value; + $this->dataType = $dataType; + } + + /** + * Function to return string property name. + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Function to return string property value. + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Function to return string property dataType. + * @return string + */ + public function getDataType() + { + return $this->dataType; + } + + /** + * Override's private string property value. + * @param string $value + * @return void + */ + public function overrideValue($value) + { + $this->value = $value; + } + + /** + * Returns the resolved value that the argument needs to have, depending on scope of where argument is referenced. + * @param boolean $isInnerArgument + * @return string + */ + public function getResolvedValue($isInnerArgument) + { + if ($this->dataType === ArgumentObject::ARGUMENT_DATA_ENTITY) { + return $this->value; + } else { + return $this->resolveSimpleValueTypes($isInnerArgument); + } + } + + /** + * Resolves simple arguments depending on type, and returns the appropriate format for simple replacement. + * Takes in boolean to determine if the replacement is being done with an inner argument (as in if it's a parameter) + * + * Example Type Non Inner Inner + * {{XML.DATA}}: {{XML.DATA}} XML.DATA + * $TEST.DATA$: $TEST.DATA$ $TEST.DATA$ + * stringLiteral stringLiteral 'stringLiteral' + * + * @param boolean $isInnerArgument + * @return string + */ + private function resolveSimpleValueTypes($isInnerArgument) + { + if (preg_match('/\$[\w]+\.[\w]+\$/', $this->value)) { + //$persisted.data$ or $$persisted.data$$, notation not different if in parameter + return $this->value; + } elseif (preg_match('/[\w]+\.[\w]+/', $this->value)) { + //xml.data + if ($isInnerArgument) { + return $this->value; + } else { + return "{{" . $this->value . "}}"; + } + } else { + //stringLiteral + if ($isInnerArgument) { + return "'" . $this->value . "'"; + } else { + return $this->value; + } + } + } +} diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php index d1653e2bd..11a31b12d 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php @@ -6,7 +6,9 @@ namespace Magento\FunctionalTestingFramework\Test\Util; +use Magento\FunctionalTestingFramework\Data\Argument\Interpreter\Argument; use Magento\FunctionalTestingFramework\Test\Objects\ActionGroupObject; +use Magento\FunctionalTestingFramework\Test\Objects\ArgumentObject; /** * Class ActionGroupObjectExtractor @@ -15,9 +17,6 @@ class ActionGroupObjectExtractor extends BaseObjectExtractor { const DEFAULT_VALUE = 'defaultValue'; const ACTION_GROUP_ARGUMENTS = 'arguments'; - const ACTION_GROUP_DATA = 'data'; - const ACTION_GROUP_DATA_ENTITY = 'entity'; - const ACTION_GROUP_SIMPLE_DATA_TYPES = ['string', 'int', 'float', 'boolean']; /** * Action Object Extractor for converting actions into objects @@ -56,35 +55,15 @@ public function extractActionGroup($actionGroupData) if (array_key_exists(self::ACTION_GROUP_ARGUMENTS, $actionGroupData)) { $arguments = $this->extractArguments($actionGroupData[self::ACTION_GROUP_ARGUMENTS]); - $argumentMap = $this->extractArgumentTypeMap($actionGroupData[self::ACTION_GROUP_ARGUMENTS]); } return new ActionGroupObject( $actionGroupData[self::NAME], $arguments, - $argumentMap, $actions ); } - /** - * Extracts argName => dataType mapping. - * @param array $arguments - * @return array - */ - private function extractArgumentTypeMap($arguments) - { - $parsedTypeMap = []; - $argData = $this->stripDescriptorTags( - $arguments, - self::NODE_NAME - ); - foreach ($argData as $argName => $argValue) { - $parsedTypeMap[$argName] = $argValue[self::ACTION_GROUP_DATA] ?? self::ACTION_GROUP_DATA_ENTITY; - } - return $parsedTypeMap; - } - /** * Method which extract argument declarations from an action group and returns an array of default values indexed * by argument name. @@ -101,7 +80,11 @@ private function extractArguments($arguments) ); foreach ($argData as $argName => $argValue) { - $parsedArguments[$argName] = $argValue[self::DEFAULT_VALUE] ?? null; + $parsedArguments[] = new ArgumentObject( + $argValue[ArgumentObject::ARGUMENT_NAME], + $argValue[ArgumentObject::ARGUMENT_DEFAULT_VALUE] ?? null, + $argValue[ArgumentObject::ARGUMENT_DATA_TYPE] ?? ArgumentObject::ARGUMENT_DATA_ENTITY + ); } return $parsedArguments; } From 0247cca8cc6677de80eecf727b7cf26b2f3a70a5 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Thu, 8 Feb 2018 15:24:00 -0600 Subject: [PATCH 07/14] MQE-498: Ability to pass simple values into an action group - PHPMD and CS fixes. --- .../Test/Objects/ActionGroupObjectTest.php | 2 -- .../Test/Util/ActionGroupObjectExtractor.php | 1 - 2 files changed, 3 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php index c68ebfadd..b4f85411a 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php @@ -198,10 +198,8 @@ public function testGetStepsWithParameterizedSimpleArg() // Persisted Data $steps = $actionGroupUnderTest->getSteps(['simple' => '$someData.field1$'], self::ACTION_GROUP_MERGE_KEY); $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector $someData.field1$']); - } - /** * Tests a data reference in an action group resolved with a persisted reference used in another function. */ diff --git a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php index 11a31b12d..a49246d44 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php +++ b/src/Magento/FunctionalTestingFramework/Test/Util/ActionGroupObjectExtractor.php @@ -42,7 +42,6 @@ public function __construct() public function extractActionGroup($actionGroupData) { $arguments = []; - $argumentMap = []; $actionData = $this->stripDescriptorTags( $actionGroupData, From a08f9881f099e07a9ed2eb5032c66da7ca961067 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Thu, 15 Feb 2018 09:45:54 -0600 Subject: [PATCH 08/14] MQE-498: Ability to pass simple values into an action group - CR Refactoring. --- .../ActionGroup/BasicActionGroup.xml | 2 +- .../Test/Objects/ActionGroupObject.php | 71 ++++++++++--------- .../Test/Objects/ArgumentObject.php | 8 +-- .../Test/etc/actionGroupSchema.xsd | 2 +- 4 files changed, 44 insertions(+), 39 deletions(-) diff --git a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml index 92678693e..702879a9a 100644 --- a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml @@ -37,7 +37,7 @@ <actionGroup name="actionGroupWithSimpleDataUsage"> <arguments> - <argument name="someArgument" data="string" defaultValue="stringLiteral"/> + <argument name="someArgument" type="string" defaultValue="stringLiteral"/> </arguments> <see stepKey="see1" selector="class.{{someArgument}}" userInput="{{someArgument}}"/> <see selector="{{SampleSection.oneParamElement(someArgument)}}" userInput="{{someArgument}}" stepKey="see2" /> diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index e19d62031..fe929e8af 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -72,36 +72,10 @@ public function __construct($name, $arguments, $actions) public function getSteps($arguments, $actionReferenceKey) { $mergeUtil = new ActionMergeUtil($this->name, "ActionGroup"); - $args = $this->arguments; - $emptyArguments = $this->findEmptyDefaultArguments(); - if (!empty($emptyArguments) && $arguments !== null) { - $diff = array_diff($emptyArguments, array_keys($arguments)); - if (!empty($diff)) { - $error = 'Argument(s) missed (' . implode(", ", $diff) . ') for actionGroup "' . $this->name . '"'; - throw new TestReferenceException($error); - } - } elseif (!empty($emptyArguments)) { - $error = 'Not enough arguments given for actionGroup "' . $this->name . '"'; - throw new TestReferenceException($error); - } - $args = $this->overrideDefaultArguments($arguments); - return $mergeUtil->resolveActionSteps($this->getResolvedActionsWithArgs($args, $actionReferenceKey), true); - } + $args = $this->resolveArguments($arguments); - /** - * Finds and returns named list of $this->arguments that have no defaultValue - * @return array - */ - private function findEmptyDefaultArguments() - { - $emptyDefaultArguments = []; - foreach ($this->arguments as $argumentObj) { - if ($argumentObj->getValue() === null) { - $emptyDefaultArguments[] = $argumentObj->getName(); - } - } - return $emptyDefaultArguments; + return $mergeUtil->resolveActionSteps($this->getResolvedActionsWithArgs($args, $actionReferenceKey), true); } /** @@ -109,16 +83,24 @@ private function findEmptyDefaultArguments() * @param array $arguments * @return ArgumentObject[] */ - private function overrideDefaultArguments($arguments) + private function resolveArguments($arguments) { - if ($arguments === null) { - return $this->arguments; - } $newArgumentList = []; + $emptyArguments = []; // Clone $this->arguments to not override default argument definitions foreach ($this->arguments as $argumentObj) { $newArgumentList[] = clone $argumentObj; + + if ($argumentObj->getValue() === null) { + $emptyArguments[] = $argumentObj->getName(); + } + } + + $this->validateEmptyArguments($emptyArguments, $arguments); + + if ($arguments === null) { + return $this->arguments; } foreach ($arguments as $argumentName => $argumentValue) { @@ -131,6 +113,29 @@ private function overrideDefaultArguments($arguments) return $newArgumentList; } + /** + * Takes a list of all Default Arguments that have no Default Value, and compares them to test invocation arguments + * If there are arguments with no default value and no test invocation value given, resolution is impossible. + * + * @param array $emptyArguments + * @param array $arguments + * @throws TestReferenceException + * @return void + */ + private function validateEmptyArguments($emptyArguments, $arguments) + { + if (!empty($emptyArguments) && $arguments !== null) { + $diff = array_diff($emptyArguments, array_keys($arguments)); + if (!empty($diff)) { + $error = 'Argument(s) missed (' . implode(", ", $diff) . ') for actionGroup "' . $this->name . '"'; + throw new TestReferenceException($error); + } + } elseif (!empty($emptyArguments)) { + $error = 'Not enough arguments given for actionGroup "' . $this->name . '"'; + throw new TestReferenceException($error); + } + } + /** * Function which takes a set of arguments to be appended to an action objects fields returns resulting * action objects with proper argument.field references. @@ -248,7 +253,7 @@ private function replaceAttributeArgumentInVariable( return $attributeValue; } - if (in_array($matchedArgument->getDataType(), ArgumentObject::ARGUMENT_SIMPLE_DATA_TYPES)) { + if (in_array($matchedArgument->getDataType(), ArgumentObject::ARGUMENT_PRIMITIVE_DATA_TYPES)) { return $this->replaceSimpleArgument( $matchedArgument->getResolvedValue($isInnerArgument), $variableName, diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php index c32255170..46abf149a 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php @@ -13,10 +13,10 @@ class ArgumentObject { const ARGUMENT_NAME = 'name'; const ARGUMENT_DEFAULT_VALUE = 'defaultValue'; - const ARGUMENT_DATA_TYPE = 'data'; + const ARGUMENT_DATA_TYPE = 'type'; const ARGUMENT_DATA_ENTITY = 'entity'; const ARGUMENT_DATA_STRING = 'string'; - const ARGUMENT_SIMPLE_DATA_TYPES = ['string', 'int', 'float', 'boolean']; + const ARGUMENT_PRIMITIVE_DATA_TYPES = ['string', 'int', 'float', 'boolean']; /** * Name of the argument. @@ -96,7 +96,7 @@ public function getResolvedValue($isInnerArgument) if ($this->dataType === ArgumentObject::ARGUMENT_DATA_ENTITY) { return $this->value; } else { - return $this->resolveSimpleValueTypes($isInnerArgument); + return $this->resolvePrimitiveValueTypes($isInnerArgument); } } @@ -112,7 +112,7 @@ public function getResolvedValue($isInnerArgument) * @param boolean $isInnerArgument * @return string */ - private function resolveSimpleValueTypes($isInnerArgument) + private function resolvePrimitiveValueTypes($isInnerArgument) { if (preg_match('/\$[\w]+\.[\w]+\$/', $this->value)) { //$persisted.data$ or $$persisted.data$$, notation not different if in parameter diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd index 7cfd7f231..92a376399 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd @@ -24,7 +24,7 @@ <xs:complexType> <xs:attribute type="xs:string" name="name" use="required"/> <xs:attribute type="xs:string" name="defaultValue"/> - <xs:attribute type="dataTypeEnum" name="data" default="entity"/> + <xs:attribute type="dataTypeEnum" name="type" default="entity"/> </xs:complexType> </xs:element> </xs:sequence> From 2fc7779da21ee59bea9fad4a1b47f4b99a0226a4 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Fri, 16 Feb 2018 14:52:27 -0600 Subject: [PATCH 09/14] MQE-498: Ability to pass simple values into an action group - removed secondary loop, only looping through arguments once now. --- .../Test/Objects/ActionGroupObject.php | 20 +++++++++---------- .../Test/Objects/ArgumentObject.php | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index fe929e8af..48ef3e6d6 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -88,12 +88,17 @@ private function resolveArguments($arguments) $newArgumentList = []; $emptyArguments = []; - // Clone $this->arguments to not override default argument definitions foreach ($this->arguments as $argumentObj) { - $newArgumentList[] = clone $argumentObj; - - if ($argumentObj->getValue() === null) { + if ($arguments !== null && array_key_exists($argumentObj->getName(), $arguments)) { + $newArgumentList[] = new ArgumentObject( + $argumentObj->getName(), + $arguments[$argumentObj->getName()], + $argumentObj->getDataType() + ); + } elseif ($argumentObj->getValue() === null) { $emptyArguments[] = $argumentObj->getName(); + } else { + $newArgumentList[] = $argumentObj; } } @@ -103,13 +108,6 @@ private function resolveArguments($arguments) return $this->arguments; } - foreach ($arguments as $argumentName => $argumentValue) { - $matchedArgument = $this->findArgumentByName($argumentName, $newArgumentList); - if (isset($matchedArgument)) { - $matchedArgument->overrideValue($argumentValue); - } - } - return $newArgumentList; } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php index 46abf149a..a9eb397a2 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php @@ -22,7 +22,7 @@ class ArgumentObject * Name of the argument. * @var string */ - public $name; + private $name; /** * Value of the argument. DefaultValue on argument creation From 9fa6b1ee4c93dbb3cbae93aee8d60ef2e5acbac7 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Tue, 20 Feb 2018 11:26:16 -0600 Subject: [PATCH 10/14] MQE-498: Ability to pass simple values into an action group - More CR Fixes, removal of empty argument method. --- .../Test/Objects/ActionGroupObjectTest.php | 4 +- .../Test/Objects/ActionGroupObject.php | 38 ++++--------------- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php index b4f85411a..733c1563d 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php @@ -224,7 +224,7 @@ public function testExceptionOnMissingActions() ->build(); $this->expectException(TestReferenceException::class); - $this->expectExceptionMessageRegExp('/Argument\(s\) missed .* for actionGroup/'); + $this->expectExceptionMessageRegExp('/Arguments missed .* for actionGroup/'); $actionGroupUnderTest->getSteps(['arg2' => 'data1'], self::ACTION_GROUP_MERGE_KEY); } @@ -238,7 +238,7 @@ public function testExceptionOnMissingArguments() ->build(); $this->expectException(TestReferenceException::class); - $this->expectExceptionMessageRegExp('/Not enough arguments given for actionGroup .*/'); + $this->expectExceptionMessageRegExp('/Arguments missed .* for actionGroup/'); $actionGroupUnderTest->getSteps(null, self::ACTION_GROUP_MERGE_KEY); } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index 48ef3e6d6..701b66025 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -85,12 +85,12 @@ public function getSteps($arguments, $actionReferenceKey) */ private function resolveArguments($arguments) { - $newArgumentList = []; + $resolvedArgumentList = []; $emptyArguments = []; foreach ($this->arguments as $argumentObj) { if ($arguments !== null && array_key_exists($argumentObj->getName(), $arguments)) { - $newArgumentList[] = new ArgumentObject( + $resolvedArgumentList[] = new ArgumentObject( $argumentObj->getName(), $arguments[$argumentObj->getName()], $argumentObj->getDataType() @@ -98,40 +98,16 @@ private function resolveArguments($arguments) } elseif ($argumentObj->getValue() === null) { $emptyArguments[] = $argumentObj->getName(); } else { - $newArgumentList[] = $argumentObj; + $resolvedArgumentList[] = $argumentObj; } } - $this->validateEmptyArguments($emptyArguments, $arguments); - - if ($arguments === null) { - return $this->arguments; - } - - return $newArgumentList; - } - - /** - * Takes a list of all Default Arguments that have no Default Value, and compares them to test invocation arguments - * If there are arguments with no default value and no test invocation value given, resolution is impossible. - * - * @param array $emptyArguments - * @param array $arguments - * @throws TestReferenceException - * @return void - */ - private function validateEmptyArguments($emptyArguments, $arguments) - { - if (!empty($emptyArguments) && $arguments !== null) { - $diff = array_diff($emptyArguments, array_keys($arguments)); - if (!empty($diff)) { - $error = 'Argument(s) missed (' . implode(", ", $diff) . ') for actionGroup "' . $this->name . '"'; - throw new TestReferenceException($error); - } - } elseif (!empty($emptyArguments)) { - $error = 'Not enough arguments given for actionGroup "' . $this->name . '"'; + if (!empty($emptyArguments)) { + $error = 'Arguments missed (' . implode(", ", $emptyArguments) . ') for actionGroup "' . $this->name . '"'; throw new TestReferenceException($error); } + + return $resolvedArgumentList; } /** From 594c41fd7e6fd7ebc5604607a57039f1728257a2 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Fri, 23 Feb 2018 10:14:10 -0600 Subject: [PATCH 11/14] MQE-498: Ability to pass simple values into an action group - Removed types, now only string. --- .../Test/Objects/ActionGroupObject.php | 6 +++--- .../Test/Objects/ArgumentObject.php | 7 +++---- .../Test/etc/actionGroupSchema.xsd | 3 --- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index 701b66025..599c6f2a8 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -227,7 +227,7 @@ private function replaceAttributeArgumentInVariable( return $attributeValue; } - if (in_array($matchedArgument->getDataType(), ArgumentObject::ARGUMENT_PRIMITIVE_DATA_TYPES)) { + if ($matchedArgument->getDataType() === ArgumentObject::ARGUMENT_DATA_STRING) { return $this->replaceSimpleArgument( $matchedArgument->getResolvedValue($isInnerArgument), $variableName, @@ -321,8 +321,8 @@ function ($e) use ($name) { return $e->getName() == $name; } ); - if (isset($matchedArgument[0])) { - return $matchedArgument[0]; + if (isset(array_values($matchedArgument)[0])) { + return array_values($matchedArgument)[0]; } return null; } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php index a9eb397a2..6f37f20be 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php @@ -16,7 +16,6 @@ class ArgumentObject const ARGUMENT_DATA_TYPE = 'type'; const ARGUMENT_DATA_ENTITY = 'entity'; const ARGUMENT_DATA_STRING = 'string'; - const ARGUMENT_PRIMITIVE_DATA_TYPES = ['string', 'int', 'float', 'boolean']; /** * Name of the argument. @@ -96,12 +95,12 @@ public function getResolvedValue($isInnerArgument) if ($this->dataType === ArgumentObject::ARGUMENT_DATA_ENTITY) { return $this->value; } else { - return $this->resolvePrimitiveValueTypes($isInnerArgument); + return $this->resolveStringArgument($isInnerArgument); } } /** - * Resolves simple arguments depending on type, and returns the appropriate format for simple replacement. + * Resolves simple string arguments and returns the appropriate format for simple replacement. * Takes in boolean to determine if the replacement is being done with an inner argument (as in if it's a parameter) * * Example Type Non Inner Inner @@ -112,7 +111,7 @@ public function getResolvedValue($isInnerArgument) * @param boolean $isInnerArgument * @return string */ - private function resolvePrimitiveValueTypes($isInnerArgument) + private function resolveStringArgument($isInnerArgument) { if (preg_match('/\$[\w]+\.[\w]+\$/', $this->value)) { //$persisted.data$ or $$persisted.data$$, notation not different if in parameter diff --git a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd index 92a376399..e51e3bbee 100644 --- a/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd +++ b/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd @@ -35,9 +35,6 @@ </xs:complexType> <xs:simpleType name="dataTypeEnum" final="restriction"> <xs:restriction base="xs:string"> - <xs:enumeration value="int"/> - <xs:enumeration value="float"/> - <xs:enumeration value="boolean"/> <xs:enumeration value="string"/> <xs:enumeration value="entity"/> </xs:restriction> From e1677e1d95c0443fcc6f8e4e7e04c06241510a53 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Fri, 23 Feb 2018 14:05:15 -0600 Subject: [PATCH 12/14] MQE-498: Ability to pass simple values into an action group - type=string will now ALWAYS return literally what was put into it. No xml.data resolution. - type=entity will now ALWAYS try to resolve the data passed in. --- .../Test/Objects/ActionGroupObjectTest.php | 19 +++++++--- ...WithSimpleDataUsageFromDefaultArgument.txt | 1 - ...pWithSimpleDataUsageFromPassedArgument.txt | 10 +++-- .../ActionGroup/BasicActionGroup.xml | 12 ++++-- .../TestModule/Test/ActionGroupTest.xml | 27 +++++++++---- .../Test/Objects/ActionGroupObject.php | 3 +- .../Test/Objects/ArgumentObject.php | 38 +++++++++++-------- 7 files changed, 73 insertions(+), 37 deletions(-) diff --git a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php index 733c1563d..bf5eb92e2 100644 --- a/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php +++ b/dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionGroupObjectTest.php @@ -56,14 +56,23 @@ public function testGetStepsWithCustomArgs() $steps = $actionGroupUnderTest->getSteps(['arg1' => 'data2'], self::ACTION_GROUP_MERGE_KEY); $this->assertOnMergeKeyAndActionValue($steps, ['userInput' => 'testValue2']); - // Simple Data + // entity.field as argument + $actionGroupUnderTest = (new ActionGroupObjectBuilder()) + ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{arg1}}'])]) + ->withArguments([new ArgumentObject('arg1', null, 'entity')]) + ->build(); + + $steps = $actionGroupUnderTest->getSteps(['arg1' => 'data2.field2'], self::ACTION_GROUP_MERGE_KEY); + $this->assertOnMergeKeyAndActionValue($steps, ['userInput' => 'testValue2']); + + // String Data $actionGroupUnderTest = (new ActionGroupObjectBuilder()) ->withActionObjects([new ActionObject('action1', 'testAction', ['userInput' => '{{simple}}'])]) ->withArguments([new ArgumentObject('simple', null, 'string')]) ->build(); - $steps = $actionGroupUnderTest->getSteps(['simple' => 'data2.field2'], self::ACTION_GROUP_MERGE_KEY); - $this->assertOnMergeKeyAndActionValue($steps, ['userInput' => 'testValue2']); + $steps = $actionGroupUnderTest->getSteps(['simple' => 'override'], self::ACTION_GROUP_MERGE_KEY); + $this->assertOnMergeKeyAndActionValue($steps, ['userInput' => 'override']); } /** @@ -191,9 +200,9 @@ public function testGetStepsWithParameterizedSimpleArg() $steps = $actionGroupUnderTest->getSteps(['simple' => 'stringLiteral'], self::ACTION_GROUP_MERGE_KEY); $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector stringLiteral']); - // XML Data + // String Literal w/ data-like structure $steps = $actionGroupUnderTest->getSteps(['simple' => 'data2.field2'], self::ACTION_GROUP_MERGE_KEY); - $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector testValue2']); + $this->assertOnMergeKeyAndActionValue($steps, ['selector' => '.selector data2.field2']); // Persisted Data $steps = $actionGroupUnderTest->getSteps(['simple' => '$someData.field1$'], self::ACTION_GROUP_MERGE_KEY); diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt index 89fea2d46..fa22d66cb 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt @@ -29,7 +29,6 @@ class ActionGroupWithSimpleDataUsageFromDefaultArgumentCest */ public function ActionGroupWithSimpleDataUsageFromDefaultArgument(AcceptanceTester $I) { - $I->see("stringLiteral", "class.stringLiteral"); $I->see("stringLiteral", "#element .stringLiteral"); } } diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt index 526d10dcf..0abbd4265 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt @@ -29,11 +29,13 @@ class ActionGroupWithSimpleDataUsageFromPassedArgumentCest */ public function ActionGroupWithSimpleDataUsageFromPassedArgument(AcceptanceTester $I) { - $I->see("overrideString", "class.overrideString"); $I->see("overrideString", "#element .overrideString"); - $I->see("John", "class.John"); - $I->see("John", "#element .John"); - $I->see($persisted->getCreatedDataByName('data'), "class." . $persisted->getCreatedDataByName('data')); + $I->see("1", "#element .1"); + $I->see("1.5", "#element .1.5"); + $I->see("true", "#element .true"); + $I->see("simpleData.firstname", "#element .simpleData.firstname"); $I->see($persisted->getCreatedDataByName('data'), "#element ." . $persisted->getCreatedDataByName('data')); + $I->see("John", "#element .John"); + $I->see($simpleData->getCreatedDataByName('firstname'), "#element ." . $simpleData->getCreatedDataByName('firstname')); } } diff --git a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml index 702879a9a..1fec39772 100644 --- a/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml +++ b/dev/tests/verification/TestModule/ActionGroup/BasicActionGroup.xml @@ -35,11 +35,17 @@ <see selector="{{SampleSection.threeParamElement(someArgument.firstname, someArgument.lastname, 'test')}}" userInput="{{someArgument.lastname}}" stepKey="seeLastName" /> </actionGroup> - <actionGroup name="actionGroupWithSimpleDataUsage"> + <actionGroup name="actionGroupWithStringUsage"> <arguments> <argument name="someArgument" type="string" defaultValue="stringLiteral"/> </arguments> - <see stepKey="see1" selector="class.{{someArgument}}" userInput="{{someArgument}}"/> - <see selector="{{SampleSection.oneParamElement(someArgument)}}" userInput="{{someArgument}}" stepKey="see2" /> + <see selector="{{SampleSection.oneParamElement(someArgument)}}" userInput="{{someArgument}}" stepKey="see1" /> + </actionGroup> + + <actionGroup name="actionGroupWithEntityUsage"> + <arguments> + <argument name="someArgument" type="entity" defaultValue="stringLiteral"/> + </arguments> + <see selector="{{SampleSection.oneParamElement(someArgument)}}" userInput="{{someArgument}}" stepKey="see1" /> </actionGroup> </actionGroups> diff --git a/dev/tests/verification/TestModule/Test/ActionGroupTest.xml b/dev/tests/verification/TestModule/Test/ActionGroupTest.xml index 05aeef572..45af32d2d 100644 --- a/dev/tests/verification/TestModule/Test/ActionGroupTest.xml +++ b/dev/tests/verification/TestModule/Test/ActionGroupTest.xml @@ -70,17 +70,31 @@ <title value="Action Group With Simple Data Usage From Passed Argument"/> </annotations> - <actionGroup ref="actionGroupWithSimpleDataUsage" stepKey="actionGroup1"> + <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup1"> <argument name="someArgument" value="overrideString"/> </actionGroup> - - <actionGroup ref="actionGroupWithSimpleDataUsage" stepKey="actionGroup2"> + <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup11"> + <argument name="someArgument" value="1"/> + </actionGroup> + <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup12"> + <argument name="someArgument" value="1.5"/> + </actionGroup> + <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup13"> + <argument name="someArgument" value="true"/> + </actionGroup> + <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup2"> <argument name="someArgument" value="simpleData.firstname"/> </actionGroup> - - <actionGroup ref="actionGroupWithSimpleDataUsage" stepKey="actionGroup3"> + <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup3"> <argument name="someArgument" value="$persisted.data$"/> </actionGroup> + + <actionGroup ref="actionGroupWithEntityUsage" stepKey="actionGroup4"> + <argument name="someArgument" value="simpleData.firstname"/> + </actionGroup> + <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup5"> + <argument name="someArgument" value="$simpleData.firstname$"/> + </actionGroup> </test> <test name="ActionGroupWithSimpleDataUsageFromDefaultArgument"> @@ -88,7 +102,6 @@ <severity value="SEVERE"/> <title value="Action Group With Simple Data Usage From Default Argument"/> </annotations> - - <actionGroup ref="actionGroupWithSimpleDataUsage" stepKey="actionGroup"/> + <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup"/> </test> </tests> diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index 599c6f2a8..e997c0294 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -269,7 +269,8 @@ private function replaceSimpleArgument($argumentValue, $variableName, $attribute if ($isInnerArgument) { return preg_replace("/(?<![\w]){$variableName}(?![(\w])/", $argumentValue, $attributeValue); } else { - return preg_replace("/{{(?<![\w]){$variableName}(?![(\w])}}/", $argumentValue, $attributeValue); +// return preg_replace("/{{(?<![\w]){$variableName}(?![(\w])}}/", $argumentValue, $attributeValue); + return str_replace("{{{$variableName}}}", $argumentValue, $attributeValue); } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php index 6f37f20be..4f3dfd4eb 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php @@ -113,23 +113,29 @@ public function getResolvedValue($isInnerArgument) */ private function resolveStringArgument($isInnerArgument) { - if (preg_match('/\$[\w]+\.[\w]+\$/', $this->value)) { - //$persisted.data$ or $$persisted.data$$, notation not different if in parameter - return $this->value; - } elseif (preg_match('/[\w]+\.[\w]+/', $this->value)) { - //xml.data - if ($isInnerArgument) { - return $this->value; - } else { - return "{{" . $this->value . "}}"; - } +// if (preg_match('/\$[\w]+\.[\w]+\$/', $this->value)) { +// //$persisted.data$ or $$persisted.data$$, notation not different if in parameter +// return $this->value; +// } elseif (preg_match('/[\w]+\.[\w]+/', $this->value)) { +// //xml.data +// if ($isInnerArgument) { +// return $this->value; +// } else { +// return "{{" . $this->value . "}}"; +// } +// } else { +// //stringLiteral +// if ($isInnerArgument) { +// return "'" . $this->value . "'"; +// } else { +// return $this->value; +// } +// } + //stringLiteral + if ($isInnerArgument) { + return "'" . $this->value . "'"; } else { - //stringLiteral - if ($isInnerArgument) { - return "'" . $this->value . "'"; - } else { - return $this->value; - } + return $this->value; } } } From 7d5a2c5355bd518f09620963f543fea913bb2412 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Fri, 23 Feb 2018 14:06:21 -0600 Subject: [PATCH 13/14] MQE-498: Ability to pass simple values into an action group - missed commented out lines. --- .../Test/Objects/ActionGroupObject.php | 1 - .../Test/Objects/ArgumentObject.php | 19 ------------------- 2 files changed, 20 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php index e997c0294..e2413cc23 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionGroupObject.php @@ -269,7 +269,6 @@ private function replaceSimpleArgument($argumentValue, $variableName, $attribute if ($isInnerArgument) { return preg_replace("/(?<![\w]){$variableName}(?![(\w])/", $argumentValue, $attributeValue); } else { -// return preg_replace("/{{(?<![\w]){$variableName}(?![(\w])}}/", $argumentValue, $attributeValue); return str_replace("{{{$variableName}}}", $argumentValue, $attributeValue); } } diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php index 4f3dfd4eb..c829e66b3 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ArgumentObject.php @@ -113,25 +113,6 @@ public function getResolvedValue($isInnerArgument) */ private function resolveStringArgument($isInnerArgument) { -// if (preg_match('/\$[\w]+\.[\w]+\$/', $this->value)) { -// //$persisted.data$ or $$persisted.data$$, notation not different if in parameter -// return $this->value; -// } elseif (preg_match('/[\w]+\.[\w]+/', $this->value)) { -// //xml.data -// if ($isInnerArgument) { -// return $this->value; -// } else { -// return "{{" . $this->value . "}}"; -// } -// } else { -// //stringLiteral -// if ($isInnerArgument) { -// return "'" . $this->value . "'"; -// } else { -// return $this->value; -// } -// } - //stringLiteral if ($isInnerArgument) { return "'" . $this->value . "'"; } else { From 49b66c59749f521cd708816d148e503aa53651e7 Mon Sep 17 00:00:00 2001 From: KevinBKozan <kkozan@magento.com> Date: Mon, 26 Feb 2018 11:45:55 -0600 Subject: [PATCH 14/14] MQE-498: Ability to pass simple values into an action group - Verification Test Fixes. --- .../ActionGroupWithSimpleDataUsageFromDefaultArgument.txt | 2 +- .../ActionGroupWithSimpleDataUsageFromPassedArgument.txt | 2 +- dev/tests/verification/TestModule/Test/ActionGroupTest.xml | 4 ++-- dev/tests/verification/Tests/ActionGroupGenerationTest.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt index fa22d66cb..37c9977ed 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt @@ -21,7 +21,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; class ActionGroupWithSimpleDataUsageFromDefaultArgumentCest { /** - * @Severity(level = SeverityLevel::SEVERE) + * @Severity(level = SeverityLevel::CRITICAL) * @Parameter(name = "AcceptanceTester", value="$I") * @param AcceptanceTester $I * @return void diff --git a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt index 0abbd4265..4c8e14cf9 100644 --- a/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt +++ b/dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt @@ -21,7 +21,7 @@ use Yandex\Allure\Adapter\Annotation\TestCaseId; class ActionGroupWithSimpleDataUsageFromPassedArgumentCest { /** - * @Severity(level = SeverityLevel::SEVERE) + * @Severity(level = SeverityLevel::CRITICAL) * @Parameter(name = "AcceptanceTester", value="$I") * @param AcceptanceTester $I * @return void diff --git a/dev/tests/verification/TestModule/Test/ActionGroupTest.xml b/dev/tests/verification/TestModule/Test/ActionGroupTest.xml index 818c64883..1918852f1 100644 --- a/dev/tests/verification/TestModule/Test/ActionGroupTest.xml +++ b/dev/tests/verification/TestModule/Test/ActionGroupTest.xml @@ -66,7 +66,7 @@ <test name="ActionGroupWithSimpleDataUsageFromPassedArgument"> <annotations> - <severity value="SEVERE"/> + <severity value="CRITICAL"/> <title value="Action Group With Simple Data Usage From Passed Argument"/> </annotations> @@ -99,7 +99,7 @@ <test name="ActionGroupWithSimpleDataUsageFromDefaultArgument"> <annotations> - <severity value="SEVERE"/> + <severity value="CRITICAL"/> <title value="Action Group With Simple Data Usage From Default Argument"/> </annotations> <actionGroup ref="actionGroupWithStringUsage" stepKey="actionGroup"/> diff --git a/dev/tests/verification/Tests/ActionGroupGenerationTest.php b/dev/tests/verification/Tests/ActionGroupGenerationTest.php index 5c62edf9a..3af62eb77 100644 --- a/dev/tests/verification/Tests/ActionGroupGenerationTest.php +++ b/dev/tests/verification/Tests/ActionGroupGenerationTest.php @@ -83,7 +83,7 @@ public function testActionGroupWithMultipleParameterSelectorsFromDefaultArgument */ public function testActionGroupWithSimpleDataUsageFromPassedArgument() { - $this->validateGenerateAndContents('ActionGroupWithSimpleDataUsageFromPassedArgument'); + $this->generateAndCompareTest('ActionGroupWithSimpleDataUsageFromPassedArgument'); } /** @@ -94,6 +94,6 @@ public function testActionGroupWithSimpleDataUsageFromPassedArgument() */ public function testActionGroupWithSimpleDataUsageFromDefaultArgument() { - $this->validateGenerateAndContents('ActionGroupWithSimpleDataUsageFromDefaultArgument'); + $this->generateAndCompareTest('ActionGroupWithSimpleDataUsageFromDefaultArgument'); } }