tests: simplify bootstrap, enforce PSR-2
This commit is contained in:
parent
2416007b24
commit
8cc99f76d0
|
@ -22,9 +22,13 @@ env:
|
|||
DIRECTOR_TESTDB_USER="director_test"
|
||||
|
||||
before_script:
|
||||
- composer self-update --stable
|
||||
- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
|
||||
- wget https://github.com/Icinga/icingaweb2/archive/v2.4.0.tar.gz
|
||||
- tar xfz v2.4.0.tar.gz
|
||||
- ln -s icingaweb2-2.4.0/library/Icinga
|
||||
- ln -s icingaweb2-2.4.0/library/vendor/Zend
|
||||
- ./test/travis-prepare.sh
|
||||
- composer install
|
||||
|
||||
script:
|
||||
- php phpcs.phar --report-width=auto --report-full --report-gitblame --report-summary -p --standard=PSR2 --extensions=php --encoding=utf-8 -w -s library/Director/ application/ configuration.php run.php test
|
||||
- phpunit --testdox || phpunit --verbose
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
"name": "icingaweb2-director",
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": ">= 4.8",
|
||||
"icinga/icingaweb2": ">= 2.3",
|
||||
"squizlabs/php_codesniffer": ">= 2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Icinga\\Module\\Director\\": "library/Director/"
|
||||
}
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "package",
|
||||
"package": {
|
||||
"name": "icinga/icingaweb2",
|
||||
"version": "2.4.0",
|
||||
"dist": {
|
||||
"url": "https://github.com/Icinga/icingaweb2/archive/v2.4.0.zip",
|
||||
"type": "zip"
|
||||
},
|
||||
"source": {
|
||||
"url": "https://github.com/Icinga/icingaweb2.git",
|
||||
"type": "git",
|
||||
"reference": "master"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Test;
|
||||
|
||||
use Icinga\Application\Cli;
|
||||
|
||||
class Bootstrap
|
||||
{
|
||||
public static function cli($basedir = null)
|
||||
{
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
if ($basedir === null) {
|
||||
$basedir = dirname(dirname(dirname(__DIR__)));
|
||||
}
|
||||
$testsDir = $basedir . '/test';
|
||||
require_once 'Icinga/Application/Cli.php';
|
||||
|
||||
if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) {
|
||||
$configDir = $_SERVER['ICINGAWEB_CONFIGDIR'];
|
||||
} else {
|
||||
$configDir = $testsDir . '/config';
|
||||
}
|
||||
|
||||
Cli::start($testsDir, $configDir)
|
||||
->getModuleManager()
|
||||
->loadModule('director', $basedir);
|
||||
}
|
||||
}
|
|
@ -1,39 +1,9 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Application\Cli;
|
||||
|
||||
## Load Composer environment, if existing
|
||||
call_user_func(function () {
|
||||
$MODULE_HOME = dirname(dirname(__FILE__));
|
||||
$composer_load = $MODULE_HOME . '/vendor/autoload.php';
|
||||
if (file_exists($composer_load)) {
|
||||
require_once $composer_load;
|
||||
|
||||
# include Icinga Web
|
||||
ini_set(
|
||||
'include_path',
|
||||
$MODULE_HOME . '/vendor/icinga/icingaweb2/library'
|
||||
. PATH_SEPARATOR . $MODULE_HOME . '/vendor/icinga/icingaweb2/library/vendor'
|
||||
. PATH_SEPARATOR . ini_get('include_path')
|
||||
);
|
||||
}
|
||||
});
|
||||
use Icinga\Module\Director\Test\Bootstrap;
|
||||
|
||||
call_user_func(function () {
|
||||
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
$testbase = __DIR__;
|
||||
$base = dirname($testbase);
|
||||
|
||||
require_once 'Icinga/Application/Cli.php';
|
||||
|
||||
if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) {
|
||||
$configDir = $_SERVER['ICINGAWEB_CONFIGDIR'];
|
||||
} else {
|
||||
$configDir = $testbase . '/config';
|
||||
}
|
||||
|
||||
Cli::start($testbase, $configDir)
|
||||
->getModuleManager()
|
||||
->loadModule('director', $base);
|
||||
$basedir = dirname(__DIR__);
|
||||
require_once $basedir . '/library/Director/Test/Bootstrap.php';
|
||||
Bootstrap::cli($basedir);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue