Skip to content

MQE-784: Update parser to read suites in from extensions #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
<item name="/suites/suite/exclude/(group|test|module)" xsi:type="string">name</item>
</argument>
<argument name="fileName" xsi:type="string">*.xml</argument>
<argument name="defaultScope" xsi:type="string">_suite</argument>
<argument name="defaultScope" xsi:type="string">Suite</argument>
</arguments>
</virtualType>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Module implements FileResolverInterface
*
* @var ModuleResolver
*/
private $moduleResolver;
protected $moduleResolver;

/**
* Module constructor.
Expand All @@ -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 = [];
Expand All @@ -48,7 +62,6 @@ public function get($filename, $scope)
$paths = array_merge($paths, glob($path));
}

$iterator = new File($paths);
return $iterator;
return $paths;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,33 @@
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
* @return array|\Iterator,\Countable
*/
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;
}
}