Skip to content

Commit eb6c943

Browse files
committed
MQE-784: Update parser to read suites in from extensions
- alter Root based file resolver to extend module fileresolver - refactor Module based fileresolver to expose utility method
1 parent 274b2b0 commit eb6c943

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

etc/di.xml

+1-1
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

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

+16-3
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

+17-4
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
}

0 commit comments

Comments
 (0)