2013-06-03 15:34:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Icinga\Protocol\Statusdat;
|
2013-06-03 16:14:46 +02:00
|
|
|
|
2013-06-03 15:34:57 +02:00
|
|
|
use \Icinga\Protocol\Statusdat as SD;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a high level test for the whole statusdat component, i.e. all parts put together
|
|
|
|
* and called like they would be in a real situation. This should work when all isolated tests have passed.
|
|
|
|
*/
|
|
|
|
class StatusdatComponentTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function getReader() {
|
|
|
|
$reader = new SD\Reader(new \Zend_Config(array(
|
|
|
|
"status_file" => dirname(__FILE__)."/status.dat",
|
2013-10-19 20:09:17 +02:00
|
|
|
"object_file" => dirname(__FILE__)."/objects.cache"
|
2013-06-03 15:34:57 +02:00
|
|
|
)),null,true);
|
|
|
|
return $reader;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testServicegroupFilterFromService() {
|
|
|
|
$r = $this->getReader();
|
|
|
|
$group = array(array('a1','b2'));
|
|
|
|
$result = $r->select()->from("services")->where("group IN ?",$group)->getResult();
|
2013-10-19 20:09:17 +02:00
|
|
|
|
|
|
|
$this->assertCount(9, $result, 'Assert items to be returned in a servicegroup filter');
|
2013-06-03 15:34:57 +02:00
|
|
|
foreach($result as $obj) {
|
|
|
|
$this->assertTrue(is_object($obj));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testServicegroupFilterFromHost() {
|
|
|
|
$r = $this->getReader();
|
|
|
|
$group = array(array('a1','b2'));
|
|
|
|
$result = $r->select()->from("hosts")->where("services.group IN ?",$group)->getResult();
|
2013-10-19 20:09:17 +02:00
|
|
|
$this->assertCount(3, $result);
|
2013-06-03 15:34:57 +02:00
|
|
|
foreach($result as $obj) {
|
|
|
|
$this->assertTrue(is_object($obj));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testHostgroupFilterFromHost() {
|
|
|
|
$r = $this->getReader();
|
|
|
|
$group = array(array('exc-hostb'));
|
|
|
|
$result = $r->select()->from("hosts")->where("group IN ?",$group)->getResult();
|
2013-10-19 20:09:17 +02:00
|
|
|
$this->assertCount(3, $result);
|
2013-06-03 15:34:57 +02:00
|
|
|
foreach($result as $obj) {
|
|
|
|
$this->assertTrue(is_object($obj));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testHostgroupFilterFromService() {
|
|
|
|
$r = $this->getReader();
|
|
|
|
$group = array(array('exc-hostb'));
|
|
|
|
$result = $r->select()->from("services")->where("host.group IN ?",$group)->getResult();
|
|
|
|
|
2013-10-19 20:09:17 +02:00
|
|
|
$this->assertCount(9, $result);
|
2013-06-03 15:34:57 +02:00
|
|
|
foreach($result as $obj) {
|
|
|
|
$this->assertTrue(is_object($obj));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|