AndOperatorTest: test pending

fixes #8727
This commit is contained in:
Thomas Gelf 2016-11-29 11:23:11 +01:00
parent 857913172b
commit 962faab992
3 changed files with 55 additions and 2 deletions

View file

@ -42,7 +42,7 @@ class HostNodeTest extends BaseTestCase
}
/**
* @expectedException \Icinga\Exception\ConfigurationError
* @expectedException \Icinga\Exception\ProgrammingError
*/
public function testWhetherSettingAnInvalidStateFails()
{

View file

@ -143,6 +143,60 @@ class AndOperatorTest extends BaseTestCase
$this->assertEquals('WARNING', $p->getStateName());
}
public function testWhetherPendingIsAccepted()
{
$bp = new BusinessProcess();
$host = $bp->createHost('localhost')->setState(99);
$service = $bp->createService('localhost', 'ping')->setState(99);
$p = $bp->createBp('p')
->addChild($host)
->addChild($service);
$this->assertEquals(
'PENDING',
$p->getStateName()
);
}
public function testWhetherWarningIsWorseThanPending()
{
$bp = new BusinessProcess();
$host = $bp->createHost('localhost')->setState(99);
$service = $bp->createService('localhost', 'ping')->setState(1);
$p = $bp->createBp('p')
->addChild($host)
->addChild($service);
$this->assertEquals(
'WARNING',
$p->getStateName()
);
}
public function testWhetherPendingIsWorseThanUpOrOk()
{
$bp = new BusinessProcess();
$host = $bp->createHost('localhost')->setState(99);
$service = $bp->createService('localhost', 'ping')->setState(0);
$p = $bp->createBp('p')
->addChild($host)
->addChild($service);
$this->assertEquals(
'PENDING',
$p->getStateName()
);
$p->clearState();
$host->setState(0);
$service->setState(99);
$this->assertEquals(
'PENDING',
$p->getStateName()
);
}
/**
* @return BusinessProcess
*/

View file

@ -5,7 +5,6 @@ namespace Tests\Icinga\Module\Businessprocess\Operator;
use Icinga\Module\Businessprocess\BusinessProcess;
use Icinga\Module\Businessprocess\ServiceNode;
use Icinga\Module\Businessprocess\Test\BaseTestCase;
use Icinga\Web\View;
class ServiceNodeTest extends BaseTestCase
{