Tests: add some more basic tests

This commit is contained in:
Thomas Gelf 2016-11-29 11:17:42 +01:00
parent cbf8db3073
commit 7511d0f4c5
2 changed files with 51 additions and 1 deletions

View file

@ -5,7 +5,6 @@ namespace Tests\Icinga\Module\Businessprocess\Operator;
use Icinga\Module\Businessprocess\BusinessProcess;
use Icinga\Module\Businessprocess\HostNode;
use Icinga\Module\Businessprocess\Test\BaseTestCase;
use Icinga\Web\View;
class HostNodeTest extends BaseTestCase
{
@ -42,6 +41,16 @@ class HostNodeTest extends BaseTestCase
);
}
/**
* @expectedException \Icinga\Exception\ConfigurationError
*/
public function testWhetherSettingAnInvalidStateFails()
{
$bp = new BusinessProcess();
$host = $bp->createHost('localhost')->setState(98);
$bp->createBp('p')->addChild($host)->getState();
}
/**
* @return HostNode
*/

View file

@ -102,6 +102,47 @@ class AndOperatorTest extends BaseTestCase
);
}
public function testWhetherSimpleAndOperationWorks()
{
$bp = new BusinessProcess();
$bp->throwErrors();
$host = $bp->createHost('localhost')->setState(1);
$service = $bp->createService('localhost', 'ping')->setState(1);
$p = $bp->createBp('p');
$p->addChild($host);
$p->addChild($service);
$this->assertEquals(
'DOWN',
$host->getStateName()
);
$this->assertEquals(
'WARNING',
$service->getStateName()
);
$this->assertEquals(
'CRITICAL',
$p->getStateName()
);
}
public function testWhetherSimpleOrOperationWorks()
{
$bp = new BusinessProcess();
$bp->throwErrors();
$host = $bp->createHost('localhost')->setState(1);
$service = $bp->createService('localhost', 'ping')->setState(1);
$p = $bp->createBp('p', '|');
$p->addChild($host);
$p->addChild($service);
$this->assertEquals('DOWN',$host->getStateName());
$this->assertEquals('WARNING', $service->getStateName());
$this->assertEquals('WARNING', $p->getStateName());
}
/**
* @return BusinessProcess
*/