Skip to content
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

Added the ability to configure additional paths for suite #6272

Open
wants to merge 1 commit into
base: 4.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Codeception/Configuration.php
Expand Up @@ -359,7 +359,21 @@ public static function suiteSettings($suite, $config)
$settings['path'] = self::$dir . DIRECTORY_SEPARATOR . $config['paths']['tests']
. DIRECTORY_SEPARATOR . $settings['path'] . DIRECTORY_SEPARATOR;

if (!isset($settings['additional_paths']) || !is_array($settings['additional_paths'])) {
$settings['additional_paths'] = [];
}

foreach ($settings['additional_paths'] as $key => $path) {
if (!is_string($path)) {
unset($settings['additional_paths'][$key]);
}

$preparePath = str_replace('/', DIRECTORY_SEPARATOR, $path);

$settings['additional_paths'][$key] = self::$dir . DIRECTORY_SEPARATOR . $preparePath;
}

$settings['additional_paths'] = array_values($settings['additional_paths']);

return $settings;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Codeception/SuiteManager.php
Expand Up @@ -51,6 +51,7 @@ class SuiteManager
protected $tests = [];
protected $debug = false;
protected $path = '';
protected $additionalPaths = [];
protected $printer = null;

protected $env = null;
Expand All @@ -62,6 +63,7 @@ public function __construct(EventDispatcher $dispatcher, $name, array $settings)
$this->dispatcher = $dispatcher;
$this->di = new Di();
$this->path = $settings['path'];
$this->additionalPaths = isset($settings['additional_paths']) ? $settings['additional_paths'] : [];
$this->groupManager = new GroupManager($settings['groups']);
$this->moduleContainer = new ModuleContainer($this->di, $settings);

Expand Down
9 changes: 8 additions & 1 deletion src/Codeception/Test/Loader.php
Expand Up @@ -43,10 +43,12 @@ class Loader
protected $formats = [];
protected $tests = [];
protected $path;
protected $additionalPaths;

public function __construct(array $suiteSettings)
{
$this->path = $suiteSettings['path'];
$this->additionalPaths = isset($suiteSettings['additional_paths']) ? $suiteSettings['additional_paths'] : [];
$this->formats = [
new CeptLoader(),
new CestLoader(),
Expand Down Expand Up @@ -128,7 +130,12 @@ public function loadTests($fileName = null)
return $this->loadTest($fileName);
}

$finder = Finder::create()->files()->sortByName()->in($this->path)->followLinks();
$paths = array_merge(
[$this->path],
$this->additionalPaths
);

$finder = Finder::create()->files()->sortByName()->in($paths)->followLinks();

foreach ($this->formats as $format) {
/** @var $format Loader **/
Expand Down