Skip to content

Commit

Permalink
Added the ability to configure additional paths for suite
Browse files Browse the repository at this point in the history
  • Loading branch information
olegpro committed Nov 5, 2021
1 parent f8881df commit d1a3156
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
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['paths']) || !is_array($settings['paths'])) {
$settings['paths'] = [];
}

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

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

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

$settings['paths'] = array_values($settings['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 $paths = [];
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->paths = isset($settings['paths']) ? $settings['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 $paths;

public function __construct(array $suiteSettings)
{
$this->path = $suiteSettings['path'];
$this->paths = isset($suiteSettings['paths']) ? $suiteSettings['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->paths
);

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

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

0 comments on commit d1a3156

Please sign in to comment.