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;
|
||||
|
||||
return IcingaObject::createByType($type, $properties);
|
||||
return IcingaObject::createByType($type, $properties, $this->getDb());
|
||||
}
|
||||
|
||||
protected function app()
|
||||
|
|
|
@ -34,7 +34,7 @@ class AssignRendererTest extends BaseTestCase
|
|||
. '&host.vars.is_clustered=true)';
|
||||
|
||||
$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(
|
||||
$expected,
|
||||
|
|
|
@ -88,6 +88,6 @@ class HostApplyMatchesTest extends BaseTestCase
|
|||
'location' => 'Nuremberg',
|
||||
'tags' => array('Special', 'Amazing'),
|
||||
)
|
||||
));
|
||||
), $this->getDb());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -196,7 +196,8 @@ class IcingaCommandTest extends BaseTestCase
|
|||
array(
|
||||
'object_name' => $this->testCommandName,
|
||||
'object_type' => 'object'
|
||||
)
|
||||
),
|
||||
$this->getDb()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,8 @@ class IcingaHostTest extends BaseTestCase
|
|||
{
|
||||
$host = $this->host();
|
||||
$newHost = IcingaHost::create(
|
||||
array('display_name' => 'Replaced display')
|
||||
array('display_name' => 'Replaced display'),
|
||||
$this->getDb()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -62,7 +63,8 @@ class IcingaHostTest extends BaseTestCase
|
|||
{
|
||||
$host = $this->host();
|
||||
$newHost = IcingaHost::create(
|
||||
array('display_name' => 'Replaced display')
|
||||
array('display_name' => 'Replaced display'),
|
||||
$this->getDb()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
|
@ -108,7 +110,8 @@ class IcingaHostTest extends BaseTestCase
|
|||
'test2' => 18,
|
||||
'initially' => 'set and then preserved',
|
||||
)
|
||||
)
|
||||
),
|
||||
$this->getDb()
|
||||
);
|
||||
|
||||
$preserve = array('address', 'vars.test1', 'vars.initially');
|
||||
|
@ -649,7 +652,7 @@ class IcingaHostTest extends BaseTestCase
|
|||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
), $this->getDb());
|
||||
}
|
||||
|
||||
protected function getDefaultHostProperties($prefix = '')
|
||||
|
|
|
@ -10,6 +10,8 @@ use Icinga\Module\Director\Test\BaseTestCase;
|
|||
|
||||
class TemplateTreeTest extends BaseTestCase
|
||||
{
|
||||
protected $applyId;
|
||||
|
||||
protected function prepareHosts(Db $db)
|
||||
{
|
||||
$o1 = IcingaHost::create([
|
||||
|
@ -195,6 +197,7 @@ class TemplateTreeTest extends BaseTestCase
|
|||
$o5->store();
|
||||
$o6->store();
|
||||
$o7->store();
|
||||
$this->applyId = (int) $o7->get('id');
|
||||
|
||||
$tree = new TemplateTree('service', $db);
|
||||
$this->assertEquals([
|
||||
|
@ -226,13 +229,12 @@ class TemplateTreeTest extends BaseTestCase
|
|||
|
||||
protected function removeServices(Db $db)
|
||||
{
|
||||
$key = [
|
||||
'object_name' => 'o7',
|
||||
'object_type' => 'apply',
|
||||
];
|
||||
if ($this->applyId) {
|
||||
$key = ['id' => $this->applyId];
|
||||
if (IcingaService::exists($key, $db)) {
|
||||
IcingaService::load($key, $db)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$kill = array('o6', 'o5', 'o4', 'o3', 'o2', 'o1');
|
||||
foreach ($kill as $name) {
|
||||
|
|
Loading…
Reference in New Issue