Skip to content

Commit 9967e23

Browse files
authored
Merge branch 'develop' into MQE-905
2 parents c623651 + e2b88bf commit 9967e23

File tree

23 files changed

+616
-201
lines changed

23 files changed

+616
-201
lines changed

bin/static-checks

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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/unit/Magento/FunctionalTestFramework/Util/Sorter/ParallelGroupSorterTest.php

Lines changed: 1 addition & 11 deletions
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
Lines changed: 33 additions & 0 deletions
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/TestModule/ActionGroup/BasicActionGroup.xml

Lines changed: 11 additions & 0 deletions
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>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,10 @@
114114
<test name="ActionGroupWithStepKeyReferences">
115115
<actionGroup ref="FunctionActionGroupWithStepKeyReferences" stepKey="actionGroup"/>
116116
</test>
117+
118+
<test name="ActionGroupUsingNestedArgument">
119+
<actionGroup ref="actionGroupWithNestedArgument" stepKey="actionGroup">
120+
<argument name="count" value="99"/>
121+
</actionGroup>
122+
</test>
117123
</tests>

dev/tests/verification/Tests/ActionGroupGenerationTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,15 @@ public function testActionGroupWithStepKeyReferences()
107107
{
108108
$this->generateAndCompareTest('ActionGroupWithStepKeyReferences');
109109
}
110+
111+
/**
112+
* Test generation of a test referencing an action group that uses stepKey references (grabFrom/CreateData)
113+
*
114+
* @throws \Exception
115+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
116+
*/
117+
public function testActionGroupWithNestedArgument()
118+
{
119+
$this->generateAndCompareTest('ActionGroupUsingNestedArgument');
120+
}
110121
}

etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@
366366
<item name="/suites/suite/exclude/(group|test|module)" xsi:type="string">name</item>
367367
</argument>
368368
<argument name="fileName" xsi:type="string">*.xml</argument>
369-
<argument name="defaultScope" xsi:type="string">_suite</argument>
369+
<argument name="defaultScope" xsi:type="string">Suite</argument>
370370
</arguments>
371371
</virtualType>
372372

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\FunctionalTestingFramework\Allure\Adapter;
7+
8+
use Magento\FunctionalTestingFramework\Data\Argument\Interpreter\NullType;
9+
use Yandex\Allure\Adapter\AllureAdapter;
10+
use Codeception\Event\SuiteEvent;
11+
12+
/**
13+
* Class MagentoAllureAdapter
14+
*
15+
* Extends AllureAdapter to provide further information for allure reports
16+
*
17+
* @package Magento\FunctionalTestingFramework\Allure
18+
*/
19+
20+
class MagentoAllureAdapter extends AllureAdapter
21+
{
22+
/**
23+
* Array of group values passed to test runner command
24+
*
25+
* @return String
26+
*/
27+
private function getGroup()
28+
{
29+
if ($this->options['groups'] != null) {
30+
return $this->options['groups'][0];
31+
}
32+
return null;
33+
}
34+
35+
/**
36+
* Override of parent method to set suitename as suitename and group name concatenated
37+
*
38+
* @param SuiteEvent $suiteEvent
39+
* @return void
40+
*/
41+
public function suiteBefore(SuiteEvent $suiteEvent)
42+
{
43+
$changeSuiteEvent = $suiteEvent;
44+
45+
if ($this->getGroup() != null) {
46+
$suite = $suiteEvent->getSuite();
47+
$suiteName = ($suite->getName()) . "\\" . $this->getGroup();
48+
49+
call_user_func(\Closure::bind(
50+
function () use ($suite, $suiteName) {
51+
$suite->name = $suiteName;
52+
},
53+
null,
54+
$suite
55+
));
56+
57+
//change suiteEvent
58+
$changeSuiteEvent = new SuiteEvent(
59+
$suiteEvent->getSuite(),
60+
$suiteEvent->getResult(),
61+
$suiteEvent->getSettings()
62+
);
63+
}
64+
// call parent function
65+
parent::suiteBefore($changeSuiteEvent);
66+
}
67+
}

src/Magento/FunctionalTestingFramework/Config/FileResolver/Module.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Module implements FileResolverInterface
2020
*
2121
* @var ModuleResolver
2222
*/
23-
private $moduleResolver;
23+
protected $moduleResolver;
2424

2525
/**
2626
* Module constructor.
@@ -40,6 +40,20 @@ public function __construct(ModuleResolver $moduleResolver = null)
4040
* @return array|\Iterator,\Countable
4141
*/
4242
public function get($filename, $scope)
43+
{
44+
$iterator = new File($this->getPaths($filename, $scope));
45+
return $iterator;
46+
}
47+
48+
/**
49+
* Function which takes a string representing filename and a scope represnting directory scope to glob for matched
50+
* patterns against. Returns the file matching the patterns given by the module resolver.
51+
*
52+
* @param string $filename
53+
* @param string $scope
54+
* @return array
55+
*/
56+
protected function getPaths($filename, $scope)
4357
{
4458
$modulesPath = $this->moduleResolver->getModulesPath();
4559
$paths = [];
@@ -48,7 +62,6 @@ public function get($filename, $scope)
4862
$paths = array_merge($paths, glob($path));
4963
}
5064

51-
$iterator = new File($paths);
52-
return $iterator;
65+
return $paths;
5366
}
5467
}

src/Magento/FunctionalTestingFramework/Config/FileResolver/Root.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,33 @@
99
use Magento\FunctionalTestingFramework\Config\FileResolverInterface;
1010
use Magento\FunctionalTestingFramework\Util\Iterator\File;
1111

12-
class Root implements FileResolverInterface
12+
class Root extends Module
1313
{
14+
const ROOT_SUITE_DIR = "_suite";
1415

1516
/**
16-
* Retrieve the list of configuration files with given name that relate to specified scope at the tests level
17+
* Retrieve the list of configuration files with given name that relate to specified scope at the root level as well
18+
* as any extension based suite configuration.
1719
*
1820
* @param string $filename
1921
* @param string $scope
2022
* @return array|\Iterator,\Countable
2123
*/
2224
public function get($filename, $scope)
2325
{
24-
$paths = glob(dirname(TESTS_BP) . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . $filename);
26+
// first pick up the root level test suite dir
27+
$paths = glob(
28+
dirname(TESTS_BP) . DIRECTORY_SEPARATOR . self::ROOT_SUITE_DIR
29+
. DIRECTORY_SEPARATOR . $filename
30+
);
2531

26-
return new File($paths);
32+
// then merge this path into the module based paths
33+
// Since we are sharing this code with Module based resolution we will unncessarily glob against modules in the
34+
// dev/tests dir tree, however as we plan to migrate to app/code this will be a temporary unneeded check.
35+
$paths = array_merge($paths, $this->getPaths($filename, $scope));
36+
37+
// create and return the iterator for these file paths
38+
$iterator = new File($paths);
39+
return $iterator;
2740
}
2841
}

src/Magento/FunctionalTestingFramework/Suite/Handlers/SuiteObjectHandler.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@ public function getAllObjects()
7878
return $this->suiteObjects;
7979
}
8080

81+
/**
82+
* Function which return all tests referenced by suites.
83+
*
84+
* @return array
85+
*/
86+
public function getAllTestReferences()
87+
{
88+
$testsReferencedInSuites = [];
89+
$suites = $this->getAllObjects();
90+
91+
foreach ($suites as $suite) {
92+
/** @var SuiteObject $suite */
93+
$test_keys = array_keys($suite->getTests());
94+
$testToSuiteName = array_fill_keys($test_keys, [$suite->getName()]);
95+
$testsReferencedInSuites = array_merge_recursive($testsReferencedInSuites, $testToSuiteName);
96+
}
97+
98+
return $testsReferencedInSuites;
99+
}
100+
81101
/**
82102
* Method to parse all suite data xml into objects.
83103
*

0 commit comments

Comments
 (0)