summaryrefslogtreecommitdiffstats
path: root/library/Director/Test
diff options
context:
space:
mode:
Diffstat (limited to 'library/Director/Test')
-rw-r--r--library/Director/Test/BaseTestCase.php19
-rw-r--r--library/Director/Test/IcingaObjectTestCase.php4
-rw-r--r--library/Director/Test/SyncTest.php6
-rw-r--r--library/Director/Test/TestSuiteLint.php2
-rw-r--r--library/Director/Test/TestSuiteUnit.php4
5 files changed, 22 insertions, 13 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;
diff --git a/library/Director/Test/IcingaObjectTestCase.php b/library/Director/Test/IcingaObjectTestCase.php
index a37fced..5d0dde3 100644
--- a/library/Director/Test/IcingaObjectTestCase.php
+++ b/library/Director/Test/IcingaObjectTestCase.php
@@ -76,7 +76,7 @@ abstract class IcingaObjectTestCase extends BaseTestCase
/**
* @inheritdoc
*/
- public function tearDown()
+ public function tearDown(): void
{
if ($this->hasDb()) {
/** @var IcingaObject $object */
@@ -88,5 +88,7 @@ abstract class IcingaObjectTestCase extends BaseTestCase
$this->subject->delete();
}
}
+
+ parent::tearDown();
}
}
diff --git a/library/Director/Test/SyncTest.php b/library/Director/Test/SyncTest.php
index 7614ff9..d118eea 100644
--- a/library/Director/Test/SyncTest.php
+++ b/library/Director/Test/SyncTest.php
@@ -29,8 +29,9 @@ abstract class SyncTest extends BaseTestCase
/** @var Sync */
protected $sync;
- public function setUp()
+ public function setUp(): void
{
+ parent::setUp();
$this->source = ImportSource::create(array(
'source_name' => 'testimport',
'provider_class' => 'Icinga\\Module\\Director\\Test\\ImportSourceDummy',
@@ -49,7 +50,7 @@ abstract class SyncTest extends BaseTestCase
$this->sync = new Sync($this->rule);
}
- public function tearDown()
+ public function tearDown(): void
{
// properties should be deleted automatically
if ($this->rule !== null && $this->rule->hasBeenLoadedFromDb()) {
@@ -75,6 +76,7 @@ abstract class SyncTest extends BaseTestCase
// make sure cache is clean for other tests
PrefetchCache::forget();
DbObject::clearAllPrefetchCaches();
+ parent::tearDown();
}
/**
diff --git a/library/Director/Test/TestSuiteLint.php b/library/Director/Test/TestSuiteLint.php
index 41941eb..0010c28 100644
--- a/library/Director/Test/TestSuiteLint.php
+++ b/library/Director/Test/TestSuiteLint.php
@@ -10,6 +10,8 @@ class TestSuiteLint extends TestSuite
protected $failed;
+ protected $result = [];
+
public function run()
{
$this->checked = $this->failed = array();
diff --git a/library/Director/Test/TestSuiteUnit.php b/library/Director/Test/TestSuiteUnit.php
index 8156eba..93dc692 100644
--- a/library/Director/Test/TestSuiteUnit.php
+++ b/library/Director/Test/TestSuiteUnit.php
@@ -4,6 +4,8 @@ namespace Icinga\Module\Director\Test;
abstract class TestSuiteUnit
{
+ private $testdoxFile;
+
public function run()
{
}
@@ -15,7 +17,7 @@ abstract class TestSuiteUnit
public function __destruct()
{
if ($this->testdoxFile && file_exists($this->testdoxFile)) {
- unlink($this->testDoxfile);
+ unlink($this->testdoxFile);
}
}