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
namespace Tests\Icinga\Modules\Director;
namespace Tests\Icinga\Module\Director\IcingaConfig;
use Icinga\Data\Filter\Filter;
use Icinga\Module\Director\IcingaConfig\AssignRenderer;

View File

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

View File

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