summaryrefslogtreecommitdiffstats
path: root/test/php/library/Director/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'test/php/library/Director/Objects')
-rw-r--r--test/php/library/Director/Objects/HostGroupMembershipResolverTest.php7
-rw-r--r--test/php/library/Director/Objects/IcingaCommandTest.php4
-rw-r--r--test/php/library/Director/Objects/IcingaHostTest.php91
-rw-r--r--test/php/library/Director/Objects/IcingaNotificationTest.php4
-rw-r--r--test/php/library/Director/Objects/IcingaServiceSetTest.php13
-rw-r--r--test/php/library/Director/Objects/IcingaServiceTest.php15
-rw-r--r--test/php/library/Director/Objects/IcingaTemplateResolverTest.php4
-rw-r--r--test/php/library/Director/Objects/IcingaTimePeriodTest.php4
8 files changed, 79 insertions, 63 deletions
diff --git a/test/php/library/Director/Objects/HostGroupMembershipResolverTest.php b/test/php/library/Director/Objects/HostGroupMembershipResolverTest.php
index cf2fb36..df4b24c 100644
--- a/test/php/library/Director/Objects/HostGroupMembershipResolverTest.php
+++ b/test/php/library/Director/Objects/HostGroupMembershipResolverTest.php
@@ -15,8 +15,9 @@ class HostGroupMembershipResolverTest extends BaseTestCase
const PREFIX = '__groupmembership';
const TYPE = 'host';
- public function setUp()
+ public function setUp(): void
{
+ parent::setUp();
IcingaTemplateRepository::clear();
}
@@ -32,12 +33,12 @@ class HostGroupMembershipResolverTest extends BaseTestCase
$db->delete('icinga_' . self::TYPE, $where);
}
- public static function setUpBeforeClass()
+ public static function setUpBeforeClass(): void
{
static::cleanArtifacts();
}
- public static function tearDownAfterClass()
+ public static function tearDownAfterClass(): void
{
static::cleanArtifacts();
}
diff --git a/test/php/library/Director/Objects/IcingaCommandTest.php b/test/php/library/Director/Objects/IcingaCommandTest.php
index 8e564d8..e3c9d89 100644
--- a/test/php/library/Director/Objects/IcingaCommandTest.php
+++ b/test/php/library/Director/Objects/IcingaCommandTest.php
@@ -206,11 +206,13 @@ class IcingaCommandTest extends BaseTestCase
return file_get_contents(__DIR__ . '/rendered/' . $name . '.out');
}
- public function tearDown()
+ public function tearDown(): void
{
$db = $this->getDb();
if (IcingaCommand::exists($this->testCommandName, $db)) {
IcingaCommand::load($this->testCommandName, $db)->delete();
}
+
+ parent::tearDown();
}
}
diff --git a/test/php/library/Director/Objects/IcingaHostTest.php b/test/php/library/Director/Objects/IcingaHostTest.php
index b4902bf..f8ec222 100644
--- a/test/php/library/Director/Objects/IcingaHostTest.php
+++ b/test/php/library/Director/Objects/IcingaHostTest.php
@@ -2,6 +2,7 @@
namespace Tests\Icinga\Module\Director\Objects;
+use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Data\PropertiesFilter\ArrayCustomVariablesFilter;
use Icinga\Module\Director\Data\PropertiesFilter\CustomVariablesFilter;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
@@ -255,14 +256,14 @@ class IcingaHostTest extends BaseTestCase
$zone->delete();
}
- /**
- * @expectedException \RuntimeException
- */
public function testFailsToStoreWithMissingLazyRelations()
{
if ($this->skipForMissingDb()) {
return;
}
+
+ $this->expectException(\RuntimeException::class);
+
$db = $this->getDb();
$host = $this->host();
$host->zone = '___TEST___zone';
@@ -336,15 +337,14 @@ class IcingaHostTest extends BaseTestCase
);
}
- /**
- * @expectedException \RuntimeException
- */
public function testFailsToStoreWithInvalidUnresolvedDependencies()
{
if ($this->skipForMissingDb()) {
return;
}
+ $this->expectException(\RuntimeException::class);
+
$host = $this->host();
$host->zone = 'invalid';
$host->store($this->getDb());
@@ -396,10 +396,16 @@ class IcingaHostTest extends BaseTestCase
$host->object_type = 'template';
$host->zone_id = null;
+ $zone = $this->newObject('zone', '___TEST___zone2');
+ $zone->store($db);
+
$config = new IcingaConfig($db);
$host->renderToConfig($config);
$this->assertEquals(
- array('zones.d/director-global/host_templates.conf'),
+ [
+ 'zones.d/___TEST___zone/host_templates.conf',
+ 'zones.d/___TEST___zone2/host_templates.conf',
+ ],
$config->getFileNames()
);
}
@@ -474,15 +480,14 @@ class IcingaHostTest extends BaseTestCase
$b->delete();
}
- /**
- * @expectedException \Icinga\Exception\NotFoundError
- */
public function testWhetherInvalidApiKeyThrows404()
{
if ($this->skipForMissingDb()) {
return;
}
+ $this->expectException(NotFoundError::class);
+
$db = $this->getDb();
IcingaHost::loadWithApiKey('No___such___key', $db);
}
@@ -694,36 +699,36 @@ class IcingaHostTest extends BaseTestCase
protected function getDefaultHostProperties($prefix = '')
{
return array(
- "${prefix}name" => "name",
- "${prefix}action_url" => "action_url",
- "${prefix}address" => "address",
- "${prefix}address6" => "address6",
- "${prefix}api_key" => "api_key",
- "${prefix}check_command" => "check_command",
- "${prefix}check_interval" => "check_interval",
- "${prefix}check_period" => "check_period",
- "${prefix}check_timeout" => "check_timeout",
- "${prefix}command_endpoint" => "command_endpoint",
- "${prefix}display_name" => "display_name",
- "${prefix}enable_active_checks" => "enable_active_checks",
- "${prefix}enable_event_handler" => "enable_event_handler",
- "${prefix}enable_flapping" => "enable_flapping",
- "${prefix}enable_notifications" => "enable_notifications",
- "${prefix}enable_passive_checks" => "enable_passive_checks",
- "${prefix}enable_perfdata" => "enable_perfdata",
- "${prefix}event_command" => "event_command",
- "${prefix}flapping_threshold_high" => "flapping_threshold_high",
- "${prefix}flapping_threshold_low" => "flapping_threshold_low",
- "${prefix}icon_image" => "icon_image",
- "${prefix}icon_image_alt" => "icon_image_alt",
- "${prefix}max_check_attempts" => "max_check_attempts",
- "${prefix}notes" => "notes",
- "${prefix}notes_url" => "notes_url",
- "${prefix}retry_interval" => "retry_interval",
- "${prefix}volatile" => "volatile",
- "${prefix}zone" => "zone",
- "${prefix}groups" => "Groups",
- "${prefix}templates" => "templates"
+ "{$prefix}name" => "name",
+ "{$prefix}action_url" => "action_url",
+ "{$prefix}address" => "address",
+ "{$prefix}address6" => "address6",
+ "{$prefix}api_key" => "api_key",
+ "{$prefix}check_command" => "check_command",
+ "{$prefix}check_interval" => "check_interval",
+ "{$prefix}check_period" => "check_period",
+ "{$prefix}check_timeout" => "check_timeout",
+ "{$prefix}command_endpoint" => "command_endpoint",
+ "{$prefix}display_name" => "display_name",
+ "{$prefix}enable_active_checks" => "enable_active_checks",
+ "{$prefix}enable_event_handler" => "enable_event_handler",
+ "{$prefix}enable_flapping" => "enable_flapping",
+ "{$prefix}enable_notifications" => "enable_notifications",
+ "{$prefix}enable_passive_checks" => "enable_passive_checks",
+ "{$prefix}enable_perfdata" => "enable_perfdata",
+ "{$prefix}event_command" => "event_command",
+ "{$prefix}flapping_threshold_high" => "flapping_threshold_high",
+ "{$prefix}flapping_threshold_low" => "flapping_threshold_low",
+ "{$prefix}icon_image" => "icon_image",
+ "{$prefix}icon_image_alt" => "icon_image_alt",
+ "{$prefix}max_check_attempts" => "max_check_attempts",
+ "{$prefix}notes" => "notes",
+ "{$prefix}notes_url" => "notes_url",
+ "{$prefix}retry_interval" => "retry_interval",
+ "{$prefix}volatile" => "volatile",
+ "{$prefix}zone" => "zone",
+ "{$prefix}groups" => "Groups",
+ "{$prefix}templates" => "templates"
);
}
protected function loadRendered($name)
@@ -731,7 +736,7 @@ class IcingaHostTest extends BaseTestCase
return file_get_contents(__DIR__ . '/rendered/' . $name . '.out');
}
- public function tearDown()
+ public function tearDown(): void
{
if ($this->hasDb()) {
$db = $this->getDb();
@@ -742,7 +747,7 @@ class IcingaHostTest extends BaseTestCase
}
}
- $kill = array('___TEST___zone');
+ $kill = ['___TEST___zone', '___TEST___zone2'];
foreach ($kill as $name) {
if (IcingaZone::exists($name, $db)) {
IcingaZone::load($name, $db)->delete();
@@ -751,6 +756,8 @@ class IcingaHostTest extends BaseTestCase
$this->deleteDatafields();
}
+
+ parent::tearDown();
}
protected function deleteDatafields()
diff --git a/test/php/library/Director/Objects/IcingaNotificationTest.php b/test/php/library/Director/Objects/IcingaNotificationTest.php
index 9d9436a..dbbce91 100644
--- a/test/php/library/Director/Objects/IcingaNotificationTest.php
+++ b/test/php/library/Director/Objects/IcingaNotificationTest.php
@@ -226,7 +226,7 @@ class IcingaNotificationTest extends BaseTestCase
return file_get_contents(__DIR__ . '/rendered/' . $name . '.out');
}
- public function tearDown()
+ public function tearDown(): void
{
if ($this->hasDb()) {
$db = $this->getDb();
@@ -244,5 +244,7 @@ class IcingaNotificationTest extends BaseTestCase
}
}
}
+
+ parent::tearDown();
}
}
diff --git a/test/php/library/Director/Objects/IcingaServiceSetTest.php b/test/php/library/Director/Objects/IcingaServiceSetTest.php
index ad7c135..a9a9fa1 100644
--- a/test/php/library/Director/Objects/IcingaServiceSetTest.php
+++ b/test/php/library/Director/Objects/IcingaServiceSetTest.php
@@ -10,8 +10,9 @@ class IcingaServiceSetTest extends IcingaObjectTestCase
protected $table = 'icinga_service_set';
protected $testObjectName = '___TEST___set';
- public function setUp()
+ public function setUp(): void
{
+ parent::setUp();
$this->assertNull($this->subject, 'subject must have been taken down before!');
if ($this->hasDb()) {
@@ -106,22 +107,20 @@ class IcingaServiceSetTest extends IcingaObjectTestCase
$this->checkForDanglingServices();
}
- /**
- * @expectedException \RuntimeException
- */
public function testCreatingSetWithoutType()
{
+ $this->expectException(\RuntimeException::class);
+
$set = IcingaServiceSet::create(array(
'object_name' => '___TEST__set_BAD',
));
$set->store($this->getDb());
}
- /**
- * @expectedException \InvalidArgumentException
- */
public function testCreatingServiceSetWithoutHost()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$set = IcingaServiceSet::create(array(
'object_name' => '___TEST__set_BAD2',
'object_type' => 'object',
diff --git a/test/php/library/Director/Objects/IcingaServiceTest.php b/test/php/library/Director/Objects/IcingaServiceTest.php
index 468db67..3005349 100644
--- a/test/php/library/Director/Objects/IcingaServiceTest.php
+++ b/test/php/library/Director/Objects/IcingaServiceTest.php
@@ -26,15 +26,14 @@ class IcingaServiceTest extends BaseTestCase
);
}
- /**
- * @expectedException \RuntimeException
- */
public function testFailsToStoreWithMissingLazyRelations()
{
if ($this->skipForMissingDb()) {
return;
}
+ $this->expectException(\RuntimeException::class);
+
$db = $this->getDb();
$service = $this->service();
$service->display_name = 'Something else';
@@ -45,16 +44,16 @@ class IcingaServiceTest extends BaseTestCase
public function testAcceptsAssignRules()
{
+ $this->expectNotToPerformAssertions();
$service = $this->service();
$service->object_type = 'apply';
$service->assign_filter = 'host.address="127.*"';
}
- /**
- * @expectedException \LogicException
- */
public function testRefusesAssignRulesWhenNotBeingAnApply()
{
+ $this->expectException(\LogicException::class);
+
$service = $this->service();
$service->assign_filter = 'host.address=127.*';
}
@@ -271,7 +270,7 @@ class IcingaServiceTest extends BaseTestCase
return file_get_contents(__DIR__ . '/rendered/' . $name . '.out');
}
- public function tearDown()
+ public function tearDown(): void
{
if ($this->hasDb()) {
$db = $this->getDb();
@@ -289,5 +288,7 @@ class IcingaServiceTest extends BaseTestCase
}
}
}
+
+ parent::tearDown();
}
}
diff --git a/test/php/library/Director/Objects/IcingaTemplateResolverTest.php b/test/php/library/Director/Objects/IcingaTemplateResolverTest.php
index 09d0ead..f521d74 100644
--- a/test/php/library/Director/Objects/IcingaTemplateResolverTest.php
+++ b/test/php/library/Director/Objects/IcingaTemplateResolverTest.php
@@ -144,7 +144,7 @@ class IcingaTemplateResolverTest extends BaseTestCase
return $host;
}
- public function tearDown()
+ public function tearDown(): void
{
$db = $this->getDb();
$kill = array('t1', 't2', 't6', 't3', 't4', 't5');
@@ -154,5 +154,7 @@ class IcingaTemplateResolverTest extends BaseTestCase
IcingaHost::load($name, $db)->delete();
}
}
+
+ parent::tearDown();
}
}
diff --git a/test/php/library/Director/Objects/IcingaTimePeriodTest.php b/test/php/library/Director/Objects/IcingaTimePeriodTest.php
index 84496d3..9888fa4 100644
--- a/test/php/library/Director/Objects/IcingaTimePeriodTest.php
+++ b/test/php/library/Director/Objects/IcingaTimePeriodTest.php
@@ -171,7 +171,7 @@ class IcingaTimePeriodTest extends BaseTestCase
return IcingaTimePeriod::load($this->testPeriodName . $suffix, $this->getDb());
}
- public function tearDown()
+ public function tearDown(): void
{
$db = $this->getDb();
@@ -180,5 +180,7 @@ class IcingaTimePeriodTest extends BaseTestCase
IcingaTimePeriod::load($name, $db)->delete();
}
}
+
+ parent::tearDown();
}
}