test/php: add new host/service render target checks
This commit is contained in:
parent
f8ef034358
commit
df8926a420
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue