BaseTestCase: Deprecate directory properties

This commit is contained in:
Johannes Meyer 2023-07-04 16:30:41 +02:00
parent 3f447cb954
commit 531479a92e
1 changed files with 7 additions and 34 deletions

View File

@ -22,6 +22,7 @@ namespace Icinga\Test {
* Path to application/ * Path to application/
* *
* @var string * @var string
* @deprecated Use Icinga::app()->getApplicationDir() instead
*/ */
public static $appDir; public static $appDir;
@ -29,13 +30,15 @@ namespace Icinga\Test {
* Path to library/Icinga * Path to library/Icinga
* *
* @var string * @var string
* @deprecated Use Icinga::app()->getLibraryDir('Icinga') instead
*/ */
public static $libDir; public static $libDir;
/** /**
* Path to etc/ * Path to etc/
* *
* @var * @var string
* @deprecated Use Icinga::app()->getBaseDir('etc') instead
*/ */
public static $etcDir; public static $etcDir;
@ -43,6 +46,7 @@ namespace Icinga\Test {
* Path to test/php/ * Path to test/php/
* *
* @var string * @var string
* @deprecated Use Icinga::app()->getBaseDir('test/php') instead
*/ */
public static $testDir; public static $testDir;
@ -50,6 +54,7 @@ namespace Icinga\Test {
* Path to share/icinga2-web * Path to share/icinga2-web
* *
* @var string * @var string
* @deprecated Unused
*/ */
public static $shareDir; public static $shareDir;
@ -57,6 +62,7 @@ namespace Icinga\Test {
* Path to modules/ * Path to modules/
* *
* @var string * @var string
* @deprecated Use Icinga::app()->getModuleManager()->getModuleDirs() instead
*/ */
public static $moduleDir; public static $moduleDir;
@ -94,38 +100,6 @@ namespace Icinga\Test {
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
} }
/**
* Setup test path environment
*
* @throws RuntimeException
*/
public static function setupDirectories()
{
$baseDir = getenv('ICINGAWEB_BASEDIR') ?: realpath(__DIR__ . '/../../../');
if ($baseDir === false) {
throw new RuntimeException('Application base dir not found');
}
$libDir = getenv('ICINGAWEB_ICINGA_LIB') ?: realpath($baseDir . '/library/Icinga');
if ($libDir === false) {
throw new RuntimeException('Icinga library dir not found');
}
self::$appDir = $baseDir . '/application';
self::$libDir = $libDir;
self::$etcDir = $baseDir . '/etc';
self::$testDir = $baseDir . '/test/php';
self::$shareDir = $baseDir . '/share/icinga2-web';
$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';
}
/** /**
* Setup MVC bootstrapping and ensure that the Icinga-Mock gets reinitialized * Setup MVC bootstrapping and ensure that the Icinga-Mock gets reinitialized
*/ */
@ -347,5 +321,4 @@ namespace Icinga\Test {
} }
BaseTestCase::setupTimezone(); BaseTestCase::setupTimezone();
BaseTestCase::setupDirectories();
} }