From 0ea0a8fd831772ba188e8ad53b7dc7e2d4720314 Mon Sep 17 00:00:00 2001 From: raviks789 <33730024+raviks789@users.noreply.github.com> Date: Tue, 16 Jan 2024 13:21:27 +0100 Subject: [PATCH] Fix zone creation and deletion for tests --- library/Director/Test/BaseTestCase.php | 7 +++++-- test/php/library/Director/Objects/IcingaHostTest.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/library/Director/Test/BaseTestCase.php b/library/Director/Test/BaseTestCase.php index adc24cb6..f0cf8e55 100644 --- a/library/Director/Test/BaseTestCase.php +++ b/library/Director/Test/BaseTestCase.php @@ -76,11 +76,14 @@ abstract class BaseTestCase extends IcingaBaseTestCase 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/test/php/library/Director/Objects/IcingaHostTest.php b/test/php/library/Director/Objects/IcingaHostTest.php index 52ec23e6..f8ec222d 100644 --- a/test/php/library/Director/Objects/IcingaHostTest.php +++ b/test/php/library/Director/Objects/IcingaHostTest.php @@ -747,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();