summaryrefslogtreecommitdiffstats
path: root/library/Director/Test/BaseTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/Test/BaseTestCase.php')
-rw-r--r--library/Director/Test/BaseTestCase.php19
1 files changed, 10 insertions, 9 deletions
diff --git a/library/Director/Test/BaseTestCase.php b/library/Director/Test/BaseTestCase.php
index 611805b..f0cf8e5 100644
--- a/library/Director/Test/BaseTestCase.php
+++ b/library/Director/Test/BaseTestCase.php
@@ -10,20 +10,15 @@ use Icinga\Module\Director\Db;
use Icinga\Module\Director\Db\Migrations;
use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Objects\IcingaZone;
-use PHPUnit_Framework_TestCase;
+use Icinga\Test\BaseTestCase as IcingaBaseTestCase;
-abstract class BaseTestCase extends PHPUnit_Framework_TestCase
+abstract class BaseTestCase extends IcingaBaseTestCase
{
private static $app;
/** @var Db */
private static $db;
- public function setUp()
- {
- $this->app();
- }
-
protected function skipForMissingDb()
{
if ($this->hasDb()) {
@@ -69,6 +64,9 @@ abstract class BaseTestCase extends PHPUnit_Framework_TestCase
if (array_key_exists('DIRECTOR_TESTDB_HOST', $_SERVER)) {
$dbConfig->host = $_SERVER['DIRECTOR_TESTDB_HOST'];
}
+ if (array_key_exists('DIRECTOR_TESTDB_PORT', $_SERVER)) {
+ $dbConfig->port = $_SERVER['DIRECTOR_TESTDB_PORT'];
+ }
if (array_key_exists('DIRECTOR_TESTDB_USER', $_SERVER)) {
$dbConfig->username = $_SERVER['DIRECTOR_TESTDB_USER'];
}
@@ -78,11 +76,14 @@ abstract class BaseTestCase extends PHPUnit_Framework_TestCase
self::$db = new Db($dbConfig);
$migrations = new Migrations(self::$db);
$migrations->applyPendingMigrations();
- IcingaZone::create([
+ $zone = IcingaZone::create([
'object_name' => 'director-global',
'object_type' => 'external_object',
'is_global' => 'y'
- ])->store(self::$db);
+ ]);
+ if (! IcingaZone::exists($zone->getId(), self::$db)) {
+ $zone->store(self::$db);
+ }
}
return self::$db;