test/php: provide DB mostly everwhere...
...as template repository would otherwise complain. Also, fit new boolean true rendering
This commit is contained in:
parent
fd400977f2
commit
ee247ab383
|
@ -89,7 +89,7 @@ abstract class BaseTestCase extends PHPUnit_Framework_TestCase
|
||||||
}
|
}
|
||||||
$properties['object_name'] = $name;
|
$properties['object_name'] = $name;
|
||||||
|
|
||||||
return IcingaObject::createByType($type, $properties);
|
return IcingaObject::createByType($type, $properties, $this->getDb());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function app()
|
protected function app()
|
||||||
|
|
|
@ -34,7 +34,7 @@ class AssignRendererTest extends BaseTestCase
|
||||||
. '&host.vars.is_clustered=true)';
|
. '&host.vars.is_clustered=true)';
|
||||||
|
|
||||||
$expected = 'assign where match("*internal", host.name) ||'
|
$expected = 'assign where match("*internal", host.name) ||'
|
||||||
. ' (service.vars.priority < 2 && host.vars.is_clustered == true)';
|
. ' (service.vars.priority < 2 && host.vars.is_clustered)';
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
|
|
|
@ -88,6 +88,6 @@ class HostApplyMatchesTest extends BaseTestCase
|
||||||
'location' => 'Nuremberg',
|
'location' => 'Nuremberg',
|
||||||
'tags' => array('Special', 'Amazing'),
|
'tags' => array('Special', 'Amazing'),
|
||||||
)
|
)
|
||||||
));
|
), $this->getDb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,8 @@ class IcingaCommandTest extends BaseTestCase
|
||||||
array(
|
array(
|
||||||
'object_name' => $this->testCommandName,
|
'object_name' => $this->testCommandName,
|
||||||
'object_type' => 'object'
|
'object_type' => 'object'
|
||||||
)
|
),
|
||||||
|
$this->getDb()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,8 @@ class IcingaHostTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
$host = $this->host();
|
$host = $this->host();
|
||||||
$newHost = IcingaHost::create(
|
$newHost = IcingaHost::create(
|
||||||
array('display_name' => 'Replaced display')
|
array('display_name' => 'Replaced display'),
|
||||||
|
$this->getDb()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -62,7 +63,8 @@ class IcingaHostTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
$host = $this->host();
|
$host = $this->host();
|
||||||
$newHost = IcingaHost::create(
|
$newHost = IcingaHost::create(
|
||||||
array('display_name' => 'Replaced display')
|
array('display_name' => 'Replaced display'),
|
||||||
|
$this->getDb()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -108,7 +110,8 @@ class IcingaHostTest extends BaseTestCase
|
||||||
'test2' => 18,
|
'test2' => 18,
|
||||||
'initially' => 'set and then preserved',
|
'initially' => 'set and then preserved',
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
|
$this->getDb()
|
||||||
);
|
);
|
||||||
|
|
||||||
$preserve = array('address', 'vars.test1', 'vars.initially');
|
$preserve = array('address', 'vars.test1', 'vars.initially');
|
||||||
|
@ -649,7 +652,7 @@ class IcingaHostTest extends BaseTestCase
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
));
|
), $this->getDb());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDefaultHostProperties($prefix = '')
|
protected function getDefaultHostProperties($prefix = '')
|
||||||
|
|
|
@ -10,6 +10,8 @@ use Icinga\Module\Director\Test\BaseTestCase;
|
||||||
|
|
||||||
class TemplateTreeTest extends BaseTestCase
|
class TemplateTreeTest extends BaseTestCase
|
||||||
{
|
{
|
||||||
|
protected $applyId;
|
||||||
|
|
||||||
protected function prepareHosts(Db $db)
|
protected function prepareHosts(Db $db)
|
||||||
{
|
{
|
||||||
$o1 = IcingaHost::create([
|
$o1 = IcingaHost::create([
|
||||||
|
@ -195,6 +197,7 @@ class TemplateTreeTest extends BaseTestCase
|
||||||
$o5->store();
|
$o5->store();
|
||||||
$o6->store();
|
$o6->store();
|
||||||
$o7->store();
|
$o7->store();
|
||||||
|
$this->applyId = (int) $o7->get('id');
|
||||||
|
|
||||||
$tree = new TemplateTree('service', $db);
|
$tree = new TemplateTree('service', $db);
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
|
@ -226,12 +229,11 @@ class TemplateTreeTest extends BaseTestCase
|
||||||
|
|
||||||
protected function removeServices(Db $db)
|
protected function removeServices(Db $db)
|
||||||
{
|
{
|
||||||
$key = [
|
if ($this->applyId) {
|
||||||
'object_name' => 'o7',
|
$key = ['id' => $this->applyId];
|
||||||
'object_type' => 'apply',
|
if (IcingaService::exists($key, $db)) {
|
||||||
];
|
IcingaService::load($key, $db)->delete();
|
||||||
if (IcingaService::exists($key, $db)) {
|
}
|
||||||
IcingaService::load($key, $db)->delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$kill = array('o6', 'o5', 'o4', 'o3', 'o2', 'o1');
|
$kill = array('o6', 'o5', 'o4', 'o3', 'o2', 'o1');
|
||||||
|
|
Loading…
Reference in New Issue