test/php: allow to skip tests with db-dependency

This commit is contained in:
Thomas Gelf 2016-02-26 12:01:00 +01:00
parent 4bc5afb2f8
commit f2a1ec91f7
3 changed files with 16 additions and 6 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Tests\Icinga\Modules\Director; namespace Tests\Icinga\Module\Director\IcingaConfig;
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Module\Director\IcingaConfig\AssignRenderer; use Icinga\Module\Director\IcingaConfig\AssignRenderer;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Tests\Icinga\Modules\Director\Objects; namespace Tests\Icinga\Module\Director\Objects;
use Icinga\Module\Director\Objects\IcingaHost; use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Test\BaseTestCase; use Icinga\Module\Director\Test\BaseTestCase;
@ -102,6 +102,10 @@ class IcingaHostTest extends BaseTestCase
public function testWhetherHostVarsArePersisted() public function testWhetherHostVarsArePersisted()
{ {
if ($this->skipForMissingDb()) {
return;
}
$db = $this->getDb(); $db = $this->getDb();
$this->host()->store($db); $this->host()->store($db);
$host = IcingaHost::load($this->testHostName, $db); $host = IcingaHost::load($this->testHostName, $db);
@ -166,9 +170,11 @@ class IcingaHostTest extends BaseTestCase
public function tearDown() public function tearDown()
{ {
$db = $this->getDb(); if ($this->hasDb()) {
if (IcingaHost::exists($this->testHostName, $db)) { $db = $this->getDb();
IcingaHost::load($this->testHostName, $db)->delete(); if (IcingaHost::exists($this->testHostName, $db)) {
IcingaHost::load($this->testHostName, $db)->delete();
}
} }
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Tests\Icinga\Modules\Director\Objects; namespace Tests\Icinga\Module\Director\Objects;
use Icinga\Module\Director\Objects\IcingaTimePeriodRange; use Icinga\Module\Director\Objects\IcingaTimePeriodRange;
use Icinga\Module\Director\Objects\IcingaTimePeriodRanges; use Icinga\Module\Director\Objects\IcingaTimePeriodRanges;
@ -13,6 +13,10 @@ class IcingaTimePeriodRangesTest extends BaseTestCase
public function testWhetherUpdatedTimeperiodRangesAreCorrectlyStored() public function testWhetherUpdatedTimeperiodRangesAreCorrectlyStored()
{ {
if ($this->skipForMissingDb()) {
return;
}
$period = $this->createTestPeriod(); $period = $this->createTestPeriod();
$newRanges = array( $newRanges = array(