Add composer support for testing

This commit is contained in:
Markus Frosch 2016-11-03 09:02:44 +01:00
parent dfb97268ee
commit 10ee7901c8
4 changed files with 54 additions and 1 deletions

8
.gitignore vendored
View File

@ -1 +1,7 @@
.*
## Editors
/.idea/
.*.sw[op]
## PHP / composer
/vendor/
composer.lock

26
composer.json Normal file
View File

@ -0,0 +1,26 @@
{
"name": "icingaweb2-director",
"require-dev": {
"phpunit/phpunit": ">= 5",
"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.3.4",
"dist": {
"url": "https://github.com/Icinga/icingaweb2/archive/v2.3.4.zip",
"type": "zip"
}
}
}
]
}

View File

@ -6,6 +6,7 @@ use Icinga\Application\Icinga;
use Icinga\Application\Config;
use Icinga\Data\ResourceFactory;
use Icinga\Exception\ConfigurationError;
use Icinga\Module\Director\Data\Db\DbConnection;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Db\Migrations;
use Icinga\Module\Director\Objects\IcingaObject;
@ -47,6 +48,10 @@ class BaseTestCase extends PHPUnit_Framework_TestCase
}
}
/**
* @return DbConnection
* @throws ConfigurationError
*/
protected function getDb()
{
if ($this->db === null) {

View File

@ -2,6 +2,22 @@
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')
);
}
});
call_user_func(function() {
error_reporting(E_ALL | E_STRICT);