mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-26 11:19:14 +02:00
After moving StatusDat to monitoring/Backends and changing the inheritance to Library/Icinga/Data, a few changes must be reflected in the tests: - Move tests to monitoring module - Change $this->backend references in StatusDat Queries to $this->ds - Added LibraryLoader to ease requiring of libaries (to be discussed) refs #4417 refs #4179
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
namespace Test\Icinga;
|
|
|
|
abstract class LibraryLoader {
|
|
|
|
public static function getBasePath()
|
|
{
|
|
$path = realpath(dirname(__FILE__));
|
|
while (!preg_match('/.*test$/', $path) && $path != '/') {
|
|
$path = realpath($path.'/../');
|
|
}
|
|
return realpath($path.'/../');
|
|
}
|
|
|
|
public static function getLibraryPath()
|
|
{
|
|
return realpath(self::getBasePath().'/library/Icinga/');
|
|
}
|
|
|
|
public static function getModulePath($module = '')
|
|
{
|
|
return realpath(self::getBasePath().'/module/'.$module);
|
|
}
|
|
|
|
/**
|
|
* Require all php files in the folder $folder
|
|
*
|
|
* @param $folder The path to the folder containing PHP files
|
|
*/
|
|
public static function loadFolder($folder, $recursive = true)
|
|
{
|
|
$files = scandir($folder);
|
|
foreach ($files as $file) {
|
|
if ($recursive && is_dir(realpath($folder."/".$file))) {
|
|
self::loadFolder(realpath($folder."/".$file));
|
|
}
|
|
if (!preg_match('/php$/', $file)) {
|
|
continue;
|
|
}
|
|
require_once(realpath($folder.'/'.$file));
|
|
}
|
|
}
|
|
|
|
abstract public static function requireLibrary();
|
|
|
|
} |