Skip to content

Commit 2c38cc6

Browse files
committed
Merge branch 'develop' into resolve-array-data
2 parents d3ad955 + 8d6eadf commit 2c38cc6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1226
-349
lines changed

bin/static-checks

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88
echo "==============================="
99
echo " CODE SNIFFER"
1010
echo "==============================="
11-
vendor/bin/phpcs ./src --standard=./dev/tests/static/Magento
11+
vendor/bin/phpcs ./src --standard=./dev/tests/static/Magento --ignore=src/Magento/FunctionalTestingFramework/Group,src/Magento/FunctionalTestingFramework/AcceptanceTester.php
1212
vendor/bin/phpcs ./dev/tests/unit --standard=./dev/tests/static/Magento
1313
vendor/bin/phpcs ./dev/tests/verification --standard=./dev/tests/static/Magento --ignore=dev/tests/verification/_generated
1414
echo ""
@@ -22,7 +22,7 @@ echo ""
2222
echo "==============================="
2323
echo " MESS DETECTOR"
2424
echo "==============================="
25-
vendor/bin/phpmd ./src text /dev/tests/static/Magento/CodeMessDetector/ruleset.xml --exclude _generated
25+
vendor/bin/phpmd ./src text /dev/tests/static/Magento/CodeMessDetector/ruleset.xml --exclude _generated,src/Magento/FunctionalTestingFramework/Group,src/Magento/FunctionalTestingFramework/AcceptanceTester.php
2626
echo ""
2727

2828
echo "==============================="

bin/static-checks.bat

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
@echo off
77
@echo ===============================PHP CODE SNIFFER REPORT===============================
8-
call vendor\bin\phpcs .\src --standard=.\dev\tests\static\Magento
8+
call vendor\bin\phpcs .\src --standard=.\dev\tests\static\Magento --ignore=src\Magento\FunctionalTestingFramework\Group,src\Magento\FunctionalTestingFramework\AcceptanceTester.php
99
call vendor\bin\phpcs .\dev\tests\unit --standard=.\dev\tests\static\Magento
1010
call vendor\bin\phpcs .\dev\tests\verification --standard=.\dev\tests\static\Magento --ignore=dev\tests\verification\_generated
1111

1212
@echo ===============================COPY PASTE DETECTOR REPORT===============================
1313
call vendor\bin\phpcpd .\src
1414

1515
@echo "===============================PHP MESS DETECTOR REPORT===============================
16-
vendor\bin\phpmd .\src text \dev\tests\static\Magento\CodeMessDetector\ruleset.xml --exclude _generated
16+
vendor\bin\phpmd .\src text \dev\tests\static\Magento\CodeMessDetector\ruleset.xml --exclude _generated,src\Magento\FunctionalTestingFramework\Group,src\Magento\FunctionalTestingFramework\AcceptanceTester.php
1717

1818
@echo ===============================MAGENTO COPYRIGHT REPORT===============================
1919
echo msgbox "INFO:Copyright check currently not run as part of .bat implementation" > "%temp%\popup.vbs"

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+
}
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/unit/Magento/FunctionalTestFramework/Util/Sorter/ParallelGroupSorterTest.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ public function testSortWithSuites()
7676

7777
AspectMock::double(TestObjectHandler::class, ['getInstance' => $mockHandler])->make();
7878

79-
// mock a suite object
80-
$mockSuite = AspectMock::double(SuiteObject::class, [
81-
'getBeforeHook' => null,
82-
'getAfterHook' => null,
83-
'getName' => 'mockSuite1'
84-
])->make();
85-
$mockSuiteHandler = AspectMock::double(SuiteObjectHandler::class, ['getObject' => $mockSuite])->make();
86-
AspectMock::double(SuiteObjectHandler::class, ['getInstance' => $mockSuiteHandler]);
87-
8879
// create test to size array
8980
$sampleTestArray = [
9081
'test1' => 100,
@@ -96,8 +87,7 @@ public function testSortWithSuites()
9687

9788
// create mock suite references
9889
$sampleSuiteArray = [
99-
'mockTest1' => ['mockSuite1'],
100-
'mockTest2' => ['mockSuite1']
90+
'mockSuite1' => ['mockTest1', 'mockTest2']
10191
];
10292

10393
// perform sort
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use Magento\FunctionalTestingFramework\DataGenerator\Handlers\DataObjectHandler;
6+
use Magento\FunctionalTestingFramework\DataGenerator\Persist\DataPersistenceHandler;
7+
use Magento\FunctionalTestingFramework\DataGenerator\Objects\EntityDataObject;
8+
use \Codeception\Util\Locator;
9+
use Yandex\Allure\Adapter\Annotation\Features;
10+
use Yandex\Allure\Adapter\Annotation\Stories;
11+
use Yandex\Allure\Adapter\Annotation\Title;
12+
use Yandex\Allure\Adapter\Annotation\Description;
13+
use Yandex\Allure\Adapter\Annotation\Parameter;
14+
use Yandex\Allure\Adapter\Annotation\Severity;
15+
use Yandex\Allure\Adapter\Model\SeverityLevel;
16+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
17+
18+
/**
19+
*/
20+
class ActionGroupUsingNestedArgumentCest
21+
{
22+
/**
23+
* @Parameter(name = "AcceptanceTester", value="$I")
24+
* @param AcceptanceTester $I
25+
* @return void
26+
* @throws \Exception
27+
*/
28+
public function ActionGroupUsingNestedArgument(AcceptanceTester $I)
29+
{
30+
$grabProductsActionGroup = $I->grabMultiple("selector");
31+
$I->assertCount(99, $grabProductsActionGroup);
32+
}
33+
}

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/BasicActionGroup.xml

+11
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,15 @@
4848
</arguments>
4949
<see selector="{{SampleSection.oneParamElement(someArgument)}}" userInput="{{someArgument}}" stepKey="see1" />
5050
</actionGroup>
51+
52+
<actionGroup name="actionGroupWithNestedArgument">
53+
<arguments>
54+
<argument name="count" defaultValue="10" type="string"/>
55+
</arguments>
56+
<grabMultiple selector="selector" stepKey="grabProducts"/>
57+
<assertCount stepKey="assertCount">
58+
<expectedResult type="int">{{count}}</expectedResult>
59+
<actualResult type="variable">grabProducts</actualResult>
60+
</assertCount>
61+
</actionGroup>
5162
</actionGroups>

0 commit comments

Comments
 (0)