diff --git a/etc/di.xml b/etc/di.xml index dfcfeafe7..e52c58b31 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -366,7 +366,7 @@ name *.xml - _suite + Suite diff --git a/src/Magento/FunctionalTestingFramework/Config/FileResolver/Module.php b/src/Magento/FunctionalTestingFramework/Config/FileResolver/Module.php index c949aa961..7cff19c87 100644 --- a/src/Magento/FunctionalTestingFramework/Config/FileResolver/Module.php +++ b/src/Magento/FunctionalTestingFramework/Config/FileResolver/Module.php @@ -20,7 +20,7 @@ class Module implements FileResolverInterface * * @var ModuleResolver */ - private $moduleResolver; + protected $moduleResolver; /** * Module constructor. @@ -40,6 +40,20 @@ public function __construct(ModuleResolver $moduleResolver = null) * @return array|\Iterator,\Countable */ public function get($filename, $scope) + { + $iterator = new File($this->getPaths($filename, $scope)); + return $iterator; + } + + /** + * Function which takes a string representing filename and a scope represnting directory scope to glob for matched + * patterns against. Returns the file matching the patterns given by the module resolver. + * + * @param string $filename + * @param string $scope + * @return array + */ + protected function getPaths($filename, $scope) { $modulesPath = $this->moduleResolver->getModulesPath(); $paths = []; @@ -48,7 +62,6 @@ public function get($filename, $scope) $paths = array_merge($paths, glob($path)); } - $iterator = new File($paths); - return $iterator; + return $paths; } } diff --git a/src/Magento/FunctionalTestingFramework/Config/FileResolver/Root.php b/src/Magento/FunctionalTestingFramework/Config/FileResolver/Root.php index e728fa418..93e74a82c 100644 --- a/src/Magento/FunctionalTestingFramework/Config/FileResolver/Root.php +++ b/src/Magento/FunctionalTestingFramework/Config/FileResolver/Root.php @@ -9,11 +9,13 @@ use Magento\FunctionalTestingFramework\Config\FileResolverInterface; use Magento\FunctionalTestingFramework\Util\Iterator\File; -class Root implements FileResolverInterface +class Root extends Module { + const ROOT_SUITE_DIR = "_suite"; /** - * Retrieve the list of configuration files with given name that relate to specified scope at the tests level + * Retrieve the list of configuration files with given name that relate to specified scope at the root level as well + * as any extension based suite configuration. * * @param string $filename * @param string $scope @@ -21,8 +23,19 @@ class Root implements FileResolverInterface */ public function get($filename, $scope) { - $paths = glob(dirname(TESTS_BP) . DIRECTORY_SEPARATOR . $scope . DIRECTORY_SEPARATOR . $filename); + // first pick up the root level test suite dir + $paths = glob( + dirname(TESTS_BP) . DIRECTORY_SEPARATOR . self::ROOT_SUITE_DIR + . DIRECTORY_SEPARATOR . $filename + ); - return new File($paths); + // then merge this path into the module based paths + // Since we are sharing this code with Module based resolution we will unncessarily glob against modules in the + // dev/tests dir tree, however as we plan to migrate to app/code this will be a temporary unneeded check. + $paths = array_merge($paths, $this->getPaths($filename, $scope)); + + // create and return the iterator for these file paths + $iterator = new File($paths); + return $iterator; } }