Skip to content

Commit

Permalink
Add composer support for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyfrosch committed Nov 3, 2016
1 parent dfb9726 commit 10ee790
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
.*
## Editors
/.idea/
.*.sw[op]

## PHP / composer
/vendor/
composer.lock
26 changes: 26 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
]
}
5 changes: 5 additions & 0 deletions library/Director/Test/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand Down Expand Up @@ -47,6 +48,10 @@ protected function getDbResourceName()
}
}

/**
* @return DbConnection
* @throws ConfigurationError
*/
protected function getDb()
{
if ($this->db === null) {
Expand Down
16 changes: 16 additions & 0 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 10ee790

Please sign in to comment.