Skip to content

Commit 703b520

Browse files
authored
Merge branch 'develop' into MQE-896
2 parents 44c15f7 + ebbe2d1 commit 703b520

30 files changed

+730
-149
lines changed

dev/tests/_bootstrap.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
'includePaths' => [PROJECT_ROOT . '/src']
1717
]);
1818

19-
// force php to generate
20-
$GLOBALS['FORCE_PHP_GENERATE'] = true;
19+
// set mftf appplication context
20+
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::create(
21+
true,
22+
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::GENERATION_PHASE,
23+
true
24+
);
2125

2226
// Load needed framework env params
2327
$TEST_ENVS = [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Tests\unit\Magento\FunctionalTestFramework\Test\Config;
7+
8+
use Magento\FunctionalTestingFramework\Exceptions\Collector\ExceptionCollector;
9+
use Magento\FunctionalTestingFramework\Test\Config\ActionGroupDom;
10+
use PHPUnit\Framework\TestCase;
11+
12+
class ActionGroupDomTest extends TestCase
13+
{
14+
/**
15+
* Test Action Group duplicate step key validation
16+
*/
17+
public function testActionGroupDomStepKeyValidation()
18+
{
19+
$sampleXml = "<actionGroups>
20+
<actionGroup name=\"actionGroupWithoutArguments\">
21+
<wait time=\"1\" stepKey=\"waitForNothing\" />
22+
<wait time=\"2\" stepKey=\"waitForNothing\" />
23+
</actionGroup>
24+
</actionGroups>";
25+
26+
$exceptionCollector = new ExceptionCollector();
27+
$actionDom = new ActionGroupDom($sampleXml, 'dupeStepKeyActionGroup.xml', $exceptionCollector);
28+
29+
$this->expectException(\Exception::class);
30+
$exceptionCollector->throwException();
31+
}
32+
}

dev/tests/unit/Magento/FunctionalTestFramework/Test/Objects/ActionObjectTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,36 @@ public function testResolveDataInUserInput()
255255
$this->assertEquals($expected, $actionObject->getCustomActionAttributes());
256256
}
257257

258+
/**
259+
* {{EntityDataObject.values}} should be replaced with ["value1","value2"]
260+
*/
261+
public function testResolveArrayData()
262+
{
263+
// Set up mocks
264+
$actionObject = new ActionObject('merge123', 'fillField', [
265+
'selector' => '#selector',
266+
'userInput' => '{{EntityDataObject.values}}'
267+
]);
268+
$entityDataObject = new EntityDataObject('EntityDataObject', 'test', [
269+
'values' => [
270+
'value1',
271+
'value2',
272+
'"My" Value'
273+
]
274+
], [], '', '');
275+
$this->mockDataHandlerWithData($entityDataObject);
276+
277+
// Call the method under test
278+
$actionObject->resolveReferences();
279+
280+
// Verify
281+
$expected = [
282+
'selector' => '#selector',
283+
'userInput' => '["value1","value2","\"My\" Value"]'
284+
];
285+
$this->assertEquals($expected, $actionObject->getCustomActionAttributes());
286+
}
287+
258288
/**
259289
* Action object should throw an exception if a reference to a parameterized selector has too few given args.
260290
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;
7+
8+
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
9+
use Magento\FunctionalTestingFramework\Test\Util\ActionObjectExtractor;
10+
use PHPUnit\Framework\TestCase;
11+
12+
class ActionObjectExtractorTest extends TestCase
13+
{
14+
/** @var ActionObjectExtractor */
15+
private $testActionObjectExtractor;
16+
17+
/**
18+
* Setup method
19+
*/
20+
public function setUp()
21+
{
22+
$this->testActionObjectExtractor = new ActionObjectExtractor();
23+
}
24+
25+
/**
26+
* Tests basic action object extraction with a valid parser array.
27+
*/
28+
public function testBasicActionObjectExtration()
29+
{
30+
$actionObjects = $this->testActionObjectExtractor->extractActions($this->createBasicActionObjectArray());
31+
$this->assertCount(1, $actionObjects);
32+
33+
/** @var ActionObject $firstElement */
34+
$firstElement = array_values($actionObjects)[0];
35+
$this->assertEquals('testAction1', $firstElement->getStepKey());
36+
$this->assertCount(1, $firstElement->getCustomActionAttributes());
37+
}
38+
39+
/**
40+
* Tests an invalid merge order reference (i.e. a step referencing itself).
41+
*/
42+
public function testInvalidMergeOrderReference()
43+
{
44+
$invalidArray = $this->createBasicActionObjectArray('invalidTestAction1', 'invalidTestAction1');
45+
46+
$this->expectException('\Magento\FunctionalTestingFramework\Exceptions\TestReferenceException');
47+
$expectedExceptionMessage = "Invalid ordering configuration in test TestWithSelfReferencingStepKey with step" .
48+
" key(s):\n\tinvalidTestAction1\n";
49+
$this->expectExceptionMessage($expectedExceptionMessage);
50+
51+
$this->testActionObjectExtractor->extractActions($invalidArray, 'TestWithSelfReferencingStepKey');
52+
}
53+
54+
/**
55+
* Validates a warning is printed to the console when multiple actions reference the same actions for merging.
56+
*/
57+
public function testAmbiguousMergeOrderRefernece()
58+
{
59+
$ambiguousArray = $this->createBasicActionObjectArray('testAction1');
60+
$ambiguousArray = array_merge(
61+
$ambiguousArray,
62+
$this->createBasicActionObjectArray('testAction2', 'testAction1')
63+
);
64+
65+
$ambiguousArray = array_merge(
66+
$ambiguousArray,
67+
$this->createBasicActionObjectArray('testAction3', null, 'testAction1')
68+
);
69+
70+
$outputString = "multiple actions referencing step key testAction1 in test AmbiguousRefTest:\n" .
71+
"\ttestAction2\n" .
72+
"\ttestAction3\n";
73+
74+
$this->expectOutputString($outputString);
75+
$this->testActionObjectExtractor->extractActions($ambiguousArray, 'AmbiguousRefTest');
76+
}
77+
78+
/**
79+
* Utility function to return mock parser output for testing extraction into ActionObjects.
80+
*
81+
* @param string $stepKey
82+
* @param string $before
83+
* @param string $after
84+
* @return array
85+
*/
86+
private function createBasicActionObjectArray($stepKey = 'testAction1', $before = null, $after = null)
87+
{
88+
$baseArray = [
89+
$stepKey => [
90+
"nodeName" => "sampleAction",
91+
"stepKey" => $stepKey,
92+
"someAttribute" => "someAttributeValue"
93+
]
94+
];
95+
96+
if ($before) {
97+
$baseArray[$stepKey] = array_merge($baseArray[$stepKey], ['before' => $before]);
98+
}
99+
100+
if ($after) {
101+
$baseArray[$stepKey] = array_merge($baseArray[$stepKey], ['after' => $after]);
102+
}
103+
104+
return $baseArray;
105+
}
106+
}

dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ class ActionGroupWithPassedArgumentAndStringSelectorParamCest
2929
*/
3030
public function ActionGroupWithPassedArgumentAndStringSelectorParam(AcceptanceTester $I)
3131
{
32-
$I->see("John".msq("UniquePerson"), "#element .test1");
32+
$I->see("John" . msq("UniquePerson"), "#element .test1");
3333
}
3434
}

dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ class ActionGroupWithSingleParameterSelectorFromPassedArgumentCest
2929
*/
3030
public function ActionGroupWithSingleParameterSelectorFromPassedArgument(AcceptanceTester $I)
3131
{
32-
$I->see("Doe", "#element .John".msq("UniquePerson"));
32+
$I->see("Doe", "#element .John" . msq("UniquePerson"));
3333
}
3434
}

dev/tests/verification/Resources/DataReplacementTest.txt

+16-14
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,22 @@ class DataReplacementTestCest
3333
$I->conditionalClick("Doe", "#John", true);
3434
$I->amOnUrl("John.html");
3535
$I->searchAndMultiSelectOption("#selector", ["John", "Doe"]);
36-
$I->fillField("#selector", "StringBefore ".msq("uniqueData")."John StringAfter");
37-
$I->fillField("#".msq("uniqueData")."John", "input");
38-
$I->dragAndDrop("#".msq("uniqueData")."John", msq("uniqueData")."John");
39-
$I->conditionalClick(msq("uniqueData")."John", "#".msq("uniqueData")."John", true);
40-
$I->amOnUrl(msq("uniqueData")."John.html");
41-
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData")."John", "Doe"]);
42-
$I->fillField("#selector", "StringBefore Doe".msq("uniqueData")." StringAfter");
43-
$I->fillField("#Doe".msq("uniqueData"), "input");
44-
$I->dragAndDrop("#Doe".msq("uniqueData"), "Doe".msq("uniqueData"));
45-
$I->conditionalClick("Doe".msq("uniqueData"), "#Doe".msq("uniqueData"), true);
46-
$I->amOnUrl("Doe".msq("uniqueData").".html");
47-
$I->searchAndMultiSelectOption("#selector", ["John", "Doe".msq("uniqueData")]);
48-
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData")."John", "Doe".msq("uniqueData")]);
49-
$I->selectMultipleOptions("#Doe".msq("uniqueData"), "#element", [msq("uniqueData")."John", "Doe".msq("uniqueData")]);
36+
$I->fillField("#selector", "StringBefore " . msq("uniqueData") . "John StringAfter");
37+
$I->fillField("#" . msq("uniqueData") . "John", "input");
38+
$I->dragAndDrop("#" . msq("uniqueData") . "John", msq("uniqueData") . "John");
39+
$I->conditionalClick(msq("uniqueData") . "John", "#" . msq("uniqueData") . "John", true);
40+
$I->amOnUrl(msq("uniqueData") . "John.html");
41+
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData") . "John", "Doe"]);
42+
$I->click("#" . msq("uniqueData") . "John#" . msq("uniqueData") . "John");
43+
$I->click("#Doe" . msq("uniqueData") . "#Doe" . msq("uniqueData"));
44+
$I->fillField("#selector", "StringBefore Doe" . msq("uniqueData") . " StringAfter");
45+
$I->fillField("#Doe" . msq("uniqueData"), "input");
46+
$I->dragAndDrop("#Doe" . msq("uniqueData"), "Doe" . msq("uniqueData"));
47+
$I->conditionalClick("Doe" . msq("uniqueData"), "#Doe" . msq("uniqueData"), true);
48+
$I->amOnUrl("Doe" . msq("uniqueData") . ".html");
49+
$I->searchAndMultiSelectOption("#selector", ["John", "Doe" . msq("uniqueData")]);
50+
$I->searchAndMultiSelectOption("#selector", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]);
51+
$I->selectMultipleOptions("#Doe" . msq("uniqueData"), "#element", [msq("uniqueData") . "John", "Doe" . msq("uniqueData")]);
5052
$I->fillField(".selector", "0");
5153
}
5254
}

dev/tests/verification/Resources/ParameterArrayTest.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ class ParameterArrayTestCest
3232
$simpleDataKey = new DataPersistenceHandler($simpleParamData, []);
3333
$simpleDataKey->createEntity();
3434
$I->searchAndMultiSelectOption("#selector", ["name"]);
35-
$I->searchAndMultiSelectOption("#selector", [msq("simpleParamData")."prename"]);
36-
$I->searchAndMultiSelectOption("#selector", ["postname".msq("simpleParamData")]);
35+
$I->searchAndMultiSelectOption("#selector", [msq("simpleParamData") . "prename"]);
36+
$I->searchAndMultiSelectOption("#selector", ["postname" . msq("simpleParamData")]);
3737
$I->searchAndMultiSelectOption("#selector", [$simpleDataKey->getCreatedDataByName('name')]);
3838
$I->searchAndMultiSelectOption("#selector", ["name", $simpleDataKey->getCreatedDataByName('name')]);
3939
$I->searchAndMultiSelectOption("#selector", ['someKey' => $simpleDataKey->getCreatedDataByName('name')]);
4040
$I->searchAndMultiSelectOption("#selector", ['someKey' => "name"]);
41-
$I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData")."prename"]);
42-
$I->searchAndMultiSelectOption("#selector", ['someKey' => "postname".msq("simpleParamData")]);
41+
$I->searchAndMultiSelectOption("#selector", ['someKey' => msq("simpleParamData") . "prename"]);
42+
$I->searchAndMultiSelectOption("#selector", ['someKey' => "postname" . msq("simpleParamData")]);
4343
$I->unselectOption("#selector", ['foo']);
4444
$I->unselectOption("#selector", ['foo', 'bar']);
4545
$I->unselectOption("#selector", ["name"]);
46-
$I->unselectOption("#selector", [msq("simpleParamData")."prename"]);
47-
$I->unselectOption("#selector", ["postname".msq("simpleParamData")]);
46+
$I->unselectOption("#selector", [msq("simpleParamData") . "prename"]);
47+
$I->unselectOption("#selector", ["postname" . msq("simpleParamData")]);
4848
$I->unselectOption("#selector", [$simpleDataKey->getCreatedDataByName('name')]);
4949
$I->unselectOption("#selector", ["name", $simpleDataKey->getCreatedDataByName('name')]);
5050
}

dev/tests/verification/Resources/PersistedReplacementTest.txt

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class PersistedReplacementTestCest
5050
$createdData->createEntity();
5151
$I->fillField("#selector", "StringBefore " . $createdData->getCreatedDataByName('firstname') . " StringAfter");
5252
$I->fillField("#" . $createdData->getCreatedDataByName('firstname'), "input");
53+
$I->fillField("#" . getenv("MAGENTO_BASE_URL") . "#" . $createdData->getCreatedDataByName('firstname'), "input");
5354
$I->dragAndDrop("#" . $createdData->getCreatedDataByName('firstname'), $createdData->getCreatedDataByName('lastname'));
5455
$I->conditionalClick($createdData->getCreatedDataByName('lastname'), "#" . $createdData->getCreatedDataByName('firstname'), true);
5556
$I->amOnUrl($createdData->getCreatedDataByName('firstname') . ".html");

dev/tests/verification/Resources/SectionReplacementTest.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ class SectionReplacementTestCest
3838
$I->click("#John .Doe");
3939
$I->click("#John-Doe .Tiberius");
4040
$I->click("#John-Doe .John [Tiberius]");
41-
$I->click("#element .".msq("uniqueData")."John");
42-
$I->click("#".msq("uniqueData")."John .stringLiteral2");
43-
$I->click("#".msq("uniqueData")."John-stringLiteral2 .stringLiteral3");
44-
$I->click("#".msq("uniqueData")."John-stringLiteral2 .");
45-
$I->click("#element .Doe".msq("uniqueData"));
46-
$I->click("#Doe".msq("uniqueData")." .stringLiteral2");
47-
$I->click("#Doe".msq("uniqueData")."-stringLiteral2 .stringLiteral3");
48-
$I->click("#Doe".msq("uniqueData")."-stringLiteral2 .Doe");
41+
$I->click("#element ." . msq("uniqueData") . "John");
42+
$I->click("#" . msq("uniqueData") . "John .stringLiteral2");
43+
$I->click("#" . msq("uniqueData") . "John-stringLiteral2 .stringLiteral3");
44+
$I->click("#" . msq("uniqueData") . "John-stringLiteral2 ." . msq("uniqueData") . "John [stringLiteral3]");
45+
$I->click("#element .Doe" . msq("uniqueData"));
46+
$I->click("#Doe" . msq("uniqueData") . " .stringLiteral2");
47+
$I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .stringLiteral3");
48+
$I->click("#Doe" . msq("uniqueData") . "-stringLiteral2 .Doe" . msq("uniqueData") . " [stringLiteral3]");
4949
$I->amGoingTo("create entity that has the stepKey: createdData");
5050
$simpleData = DataObjectHandler::getInstance()->getObject("simpleData");
5151
$createdData = new DataPersistenceHandler($simpleData, []);
@@ -60,7 +60,7 @@ class SectionReplacementTestCest
6060
$I->click("#John-Doe .John [Tiberius]");
6161
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .John");
6262
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .{$data}");
63-
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .".msq("uniqueData")."John");
64-
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .Doe".msq("uniqueData"));
63+
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " ." . msq("uniqueData") . "John");
64+
$I->click("#stringLiteral1-" . $createdData->getCreatedDataByName('firstname') . " .Doe" . msq("uniqueData"));
6565
}
6666
}

dev/tests/verification/TestModule/ActionGroup/XmlDuplicateActionGroup.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<amOnSubdomain stepKey="aosd2" url="1"/>
1717
<amOnUrl stepKey="aou1" url="1"/>
1818
<amOnUrl stepKey="aou2" url="1"/>
19-
<appendField selector="1" stepKey="ap1"/>
20-
<appendField selector="1" stepKey="ap2"/>
19+
<appendField selector="1" stepKey="apf1"/>
20+
<appendField selector="1" stepKey="apf2"/>
2121
<attachFile selector="1" stepKey="atf1"/>
2222
<attachFile selector="1" stepKey="atf2"/>
2323
<cancelPopup stepKey="cp1"/>
@@ -164,8 +164,8 @@
164164
<seeInField stepKey="seeinfield12"/>
165165
<seeInFormFields selector="2" parameterArray="[1]" stepKey="seeinformfields1"/>
166166
<seeInFormFields selector="2" parameterArray="[1]" stepKey="seeinformfields12"/>
167-
<seeInPageSource html="1" stepKey="seeinsource1"/>
168-
<seeInPageSource html="1" stepKey="seeinsource12"/>
167+
<seeInPageSource html="1" stepKey="seeinpgsource1"/>
168+
<seeInPageSource html="1" stepKey="seeinpgsource12"/>
169169
<seeInPopup stepKey="seeinpopup1"/>
170170
<seeInPopup stepKey="seeinpopup12"/>
171171
<seeInSource html="1" stepKey="seeinsource1"/>

dev/tests/verification/TestModule/Test/DataReplacementTest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<conditionalClick stepKey="dependentSelectorReplaceMSQPrefix" dependentSelector="#{{uniqueData.firstname}}" selector="{{uniqueData.firstname}}" visible="true"/>
2323
<amOnUrl stepKey="urlReplaceMSQPrefix" url="{{uniqueData.firstname}}.html"/>
2424
<searchAndMultiSelectOption stepKey="parameterArrayReplacementMSQPrefix" selector="#selector" parameterArray="[{{uniqueData.firstname}}, {{simpleData.lastname}}]"/>
25+
<click stepKey="selectorReplaceDupedMSQPrefix" selector="#{{uniqueData.firstname}}#{{uniqueData.firstname}}"/>
26+
<click stepKey="selectorReplaceDupedMSQSuffix" selector="#{{uniqueData.lastname}}#{{uniqueData.lastname}}"/>
2527

2628
<fillField stepKey="inputReplaceMSQSuffix" selector="#selector" userInput="StringBefore {{uniqueData.lastname}} StringAfter"/>
2729
<fillField stepKey="selectorReplaceMSQSuffix" selector="#{{uniqueData.lastname}}" userInput="input"/>

dev/tests/verification/TestModule/Test/PersistedReplacementTest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
<fillField stepKey="inputReplace" selector="#selector" userInput="StringBefore $createdData.firstname$ StringAfter"/>
1818
<fillField stepKey="selectorReplace" selector="#$createdData.firstname$" userInput="input"/>
19+
<fillField stepKey="selectorReplace2" selector="#{{_ENV.MAGENTO_BASE_URL}}#$createdData.firstname$" userInput="input"/>
1920
<dragAndDrop stepKey="selector12Replace" selector1="#$createdData.firstname$" selector2="$createdData.lastname$"/>
2021
<conditionalClick stepKey="dependentSelectorReplace" dependentSelector="#$createdData.firstname$" selector="$createdData.lastname$" visible="true"/>
2122
<amOnUrl stepKey="urlReplace" url="$createdData.firstname$.html"/>

etc/di.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,12 @@
286286
</arguments>
287287
</virtualType>
288288

289-
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\ActionGroupData" type="Magento\FunctionalTestingFramework\Config\Reader\Filesystem">
289+
<virtualType name="Magento\FunctionalTestingFramework\Config\Reader\ActionGroupData" type="Magento\FunctionalTestingFramework\Test\Config\Reader\Filesystem">
290290
<arguments>
291291
<argument name="fileResolver" xsi:type="object">Magento\FunctionalTestingFramework\Config\FileResolver\Module</argument>
292292
<argument name="converter" xsi:type="object">Magento\FunctionalTestingFramework\Config\ActionGroupDataConverter</argument>
293293
<argument name="schemaLocator" xsi:type="object">Magento\FunctionalTestingFramework\Config\SchemaLocator\ActionGroup</argument>
294+
<argument name="domDocumentClass" xsi:type="string">Magento\FunctionalTestingFramework\Test\Config\ActionGroupDom</argument>
294295
<argument name="idAttributes" xsi:type="array">
295296
<item name="/actionGroups/actionGroup" xsi:type="string">name</item>
296297
<item name="/actionGroups/actionGroup/arguments/argument" xsi:type="string">name</item>

0 commit comments

Comments
 (0)