mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Make running unittests with the icingacli work in package installations
fixes #2787
This commit is contained in:
parent
72b02f7f08
commit
73e24302c0
@ -117,18 +117,22 @@ namespace Icinga\Test {
|
|||||||
*/
|
*/
|
||||||
public static function setupDirectories()
|
public static function setupDirectories()
|
||||||
{
|
{
|
||||||
$baseDir = realpath(__DIR__ . '/../../../');
|
$baseDir = getenv('ICINGAWEB_BASEDIR') ?: realpath(__DIR__ . '/../../../');
|
||||||
|
|
||||||
if ($baseDir === false) {
|
if ($baseDir === false) {
|
||||||
throw new RuntimeException('Application base dir not found');
|
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::$appDir = $baseDir . '/application';
|
||||||
self::$libDir = $baseDir . '/library/Icinga';
|
self::$libDir = $libDir;
|
||||||
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 = $baseDir . '/modules';
|
self::$moduleDir = getenv('ICINGAWEB_MODULES_DIR') ?: $baseDir . '/modules';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +70,10 @@ class PhpCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
chdir(realpath(__DIR__ . '/../..'));
|
chdir(realpath(__DIR__ . '/../..'));
|
||||||
$command = $phpUnit . ' ' . join(' ', array_merge($options, $this->params->getAllStandalone()));
|
$command = $this->getEnvironmentVariables() . $phpUnit . ' ' . join(
|
||||||
|
' ',
|
||||||
|
array_merge($options, $this->params->getAllStandalone())
|
||||||
|
);
|
||||||
if ($this->isVerbose) {
|
if ($this->isVerbose) {
|
||||||
$res = `$command`;
|
$res = `$command`;
|
||||||
foreach (preg_split('/\n/', $res) as $line) {
|
foreach (preg_split('/\n/', $res) as $line) {
|
||||||
@ -173,4 +176,22 @@ class PhpCommand extends Command
|
|||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup some required environment variables
|
||||||
|
*/
|
||||||
|
protected function getEnvironmentVariables()
|
||||||
|
{
|
||||||
|
$vars = array();
|
||||||
|
$vars[] = sprintf('ICINGAWEB_BASEDIR=%s', $this->app->getBaseDir());
|
||||||
|
$vars[] = sprintf('ICINGAWEB_ICINGA_LIB=%s', $this->app->getLibraryDir('Icinga'));
|
||||||
|
|
||||||
|
// Disabled as the bootstrap.php for PHPUnit and class BaseTestCase can't handle multiple paths yet
|
||||||
|
/*$vars[] = sprintf(
|
||||||
|
'ICINGAWEB_MODULES_DIR=%s',
|
||||||
|
implode(PATH_SEPARATOR, $this->app->getModuleManager()->getModuleDirs())
|
||||||
|
);*/
|
||||||
|
|
||||||
|
return join(' ', $vars) . ' ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
$applicationPath = realpath(dirname(__FILE__) . '/../../application/');
|
$basePath = getenv('ICINGAWEB_BASEDIR') ?: realpath(dirname(__FILE__) . '/../..');
|
||||||
$modulePath = realpath(dirname(__FILE__) . '/../../modules/');
|
$applicationPath = $basePath . '/application';
|
||||||
$libraryPath = realpath(dirname(__FILE__) . '/../../library/');
|
$modulePath = getenv('ICINGAWEB_MODULES_DIR') ?: ($basePath . '/modules');
|
||||||
$testLibraryPath = realpath(dirname(__FILE__) . '/library/');
|
$icingaLibPath = getenv('ICINGAWEB_ICINGA_LIB') ?: ($basePath . '/library/Icinga');
|
||||||
$configPath = realpath($libraryPath . '/../config');
|
$libraryPath = $basePath . '/library';
|
||||||
|
$testLibraryPath = realpath(dirname(__FILE__) . '/library');
|
||||||
|
$configPath = $basePath . '/../config';
|
||||||
|
|
||||||
// Is usually done in the application's bootstrap and is used by some of our internals
|
// Is usually done in the application's bootstrap and is used by some of our internals
|
||||||
if (!defined('ICINGAWEB_APPDIR')) {
|
if (!defined('ICINGAWEB_APPDIR')) {
|
||||||
@ -22,11 +24,11 @@ require_once 'Mockery/Loader.php';
|
|||||||
$mockeryLoader = new \Mockery\Loader;
|
$mockeryLoader = new \Mockery\Loader;
|
||||||
$mockeryLoader->register();
|
$mockeryLoader->register();
|
||||||
|
|
||||||
require_once($libraryPath . '/Icinga/Test/ClassLoader.php');
|
require_once($icingaLibPath . '/Test/ClassLoader.php');
|
||||||
|
|
||||||
$loader = new Icinga\Test\ClassLoader();
|
$loader = new Icinga\Test\ClassLoader();
|
||||||
$loader->registerNamespace('Tests', $testLibraryPath);
|
$loader->registerNamespace('Tests', $testLibraryPath);
|
||||||
$loader->registerNamespace('Icinga', $libraryPath . '/Icinga');
|
$loader->registerNamespace('Icinga', $icingaLibPath);
|
||||||
$loader->registerNamespace('Icinga\\Forms', $applicationPath . '/forms');
|
$loader->registerNamespace('Icinga\\Forms', $applicationPath . '/forms');
|
||||||
|
|
||||||
$modules = scandir($modulePath);
|
$modules = scandir($modulePath);
|
||||||
|
@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
namespace Tests\Icinga\Web\Paginator\ScrollingStyle;
|
namespace Tests\Icinga\Web\Paginator\ScrollingStyle;
|
||||||
|
|
||||||
require_once realpath(ICINGA_LIBDIR . '/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorder.php');
|
|
||||||
|
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Zend_Paginator;
|
use Zend_Paginator;
|
||||||
use Icinga\Test\BaseTestCase;
|
use Icinga\Test\BaseTestCase;
|
||||||
|
|
||||||
|
require_once realpath(BaseTestCase::$libDir . '/Web/Paginator/ScrollingStyle/SlidingWithBorder.php');
|
||||||
|
|
||||||
class SlidingwithborderTest extends BaseTestCase
|
class SlidingwithborderTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
public function testGetPages2()
|
public function testGetPages2()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user