mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
Merge pull request #4986 from Icinga/enhance-module-test-compatibility
Enhance module test compatibility
This commit is contained in:
commit
04c9edeccc
@ -133,7 +133,14 @@ namespace Icinga\Test {
|
|||||||
self::$etcDir = $baseDir . '/etc';
|
self::$etcDir = $baseDir . '/etc';
|
||||||
self::$testDir = $baseDir . '/test/php';
|
self::$testDir = $baseDir . '/test/php';
|
||||||
self::$shareDir = $baseDir . '/share/icinga2-web';
|
self::$shareDir = $baseDir . '/share/icinga2-web';
|
||||||
self::$moduleDir = getenv('ICINGAWEB_MODULES_DIR') ?: $baseDir . '/modules';
|
|
||||||
|
$modulesDir = getenv('ICINGAWEB_MODULES_DIR');
|
||||||
|
if ($modulesDir && strpos($modulesDir, ':') !== false) {
|
||||||
|
// Only use the env variable if it contains a single path
|
||||||
|
$modulesDir = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$moduleDir = $modulesDir ?: $baseDir . '/modules';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,15 +71,14 @@ if ($modulePaths) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! $modulePaths) {
|
if (! $modulePaths) {
|
||||||
$modulePaths = array_flip(scandir($modulePath));
|
$modulePaths = [];
|
||||||
unset($modulePaths['.']);
|
foreach (preg_split('/:/', $modulePath, -1, PREG_SPLIT_NO_EMPTY) as $path) {
|
||||||
unset($modulePaths['..']);
|
$candidates = array_flip(scandir($path));
|
||||||
$modulePaths = array_keys($modulePaths);
|
unset($candidates['.'], $candidates['..']);
|
||||||
|
foreach ($candidates as $candidate => $_) {
|
||||||
foreach ($modulePaths as &$path) {
|
$modulePaths[] = "$path/$candidate";
|
||||||
$path = "$modulePath/$path";
|
}
|
||||||
}
|
}
|
||||||
unset($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($modulePaths as $path) {
|
foreach ($modulePaths as $path) {
|
||||||
@ -92,9 +91,9 @@ foreach ($modulePaths as $path) {
|
|||||||
$loader->registerNamespace($moduleNamespace, $moduleLibraryPath);
|
$loader->registerNamespace($moduleNamespace, $moduleLibraryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$moduleTestPath = "$path/test/php";
|
$moduleTestPath = "$path/test/php/Lib";
|
||||||
if (is_dir($moduleTestPath)) {
|
if (is_dir($moduleTestPath)) {
|
||||||
$loader->registerNamespace('Tests\\' . $moduleNamespace, $moduleTestPath);
|
$loader->registerNamespace('Tests\\' . $moduleNamespace . '\\Lib', $moduleTestPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$moduleFormPath = "$path/application/forms";
|
$moduleFormPath = "$path/application/forms";
|
||||||
@ -112,13 +111,6 @@ set_include_path(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (! class_exists('Mockery')) {
|
|
||||||
require_once 'Mockery/Loader.php';
|
|
||||||
|
|
||||||
$mockeryLoader = new \Mockery\Loader;
|
|
||||||
$mockeryLoader->register();
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once 'Zend/Loader/Autoloader.php';
|
require_once 'Zend/Loader/Autoloader.php';
|
||||||
\Zend_Loader_Autoloader::getInstance();
|
\Zend_Loader_Autoloader::getInstance();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user