test/php: add new host/service render target checks

This commit is contained in:
Thomas Gelf 2016-04-20 10:20:13 +02:00
parent f8ef034358
commit df8926a420
2 changed files with 69 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace Tests\Icinga\Module\Director\Objects;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaZone;
use Icinga\Module\Director\Test\BaseTestCase;
@ -271,6 +272,56 @@ class IcingaHostTest extends BaseTestCase
$host->store($this->getDb());
}
public function testRendersToTheCorrectZone()
{
if ($this->skipForMissingDb()) {
return;
}
$db = $this->getDb();
$host = $this->host()->setConnection($db);
$config = new IcingaConfig($db);
$host->renderToConfig($config);
$this->assertEquals(
array('zones.d/master.conf'),
$config->getFileNames()
);
$zone = $this->newObject('zone', '___TEST___zone');
$zone->store($db);
$config = new IcingaConfig($db);
$host->zone = '___TEST___zone';
$host->renderToConfig($config);
$this->assertEquals(
array('zones.d/___TEST___zone.conf'),
$config->getFileNames()
);
$host->has_agent = true;
$host->master_should_connect = true;
$host->accept_config = true;
$config = new IcingaConfig($db);
$host->renderToConfig($config);
$this->assertEquals(
array('zones.d/___TEST___zone.conf'),
$config->getFileNames()
);
$host->object_type = 'template';
$host->zone_id = null;
$config = new IcingaConfig($db);
$host->renderToConfig($config);
$this->assertEquals(
array('zones.d/director-global.conf'),
$config->getFileNames()
);
}
protected function getDummyRelatedProperties()
{
return array(

View File

@ -2,6 +2,7 @@
namespace Tests\Icinga\Module\Director\Objects;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaService;
use Icinga\Module\Director\Test\BaseTestCase;
@ -191,6 +192,23 @@ class IcingaServiceTest extends BaseTestCase
);
}
public function testRendersToTheCorrectZone()
{
if ($this->skipForMissingDb()) {
return;
}
$db = $this->getDb();
$service = $this->service()->setConnection($db);
$config = new IcingaConfig($db);
$service->renderToConfig($config);
$this->assertEquals(
array('zones.d/master.conf'),
$config->getFileNames()
);
}
protected function host()
{
return IcingaHost::create(array(