icingaweb2-module-businessp.../test/php/library/Businessprocess/HostNodeTest.php

66 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2016-12-23 06:46:56 -05:00
namespace Tests\Icinga\Module\Businessprocess;
2017-01-11 08:04:45 -05:00
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\HostNode;
use Icinga\Module\Businessprocess\Test\BaseTestCase;
class HostNodeTest extends BaseTestCase
{
public function testReturnsCorrectHostName()
{
$this->assertEquals(
'localhost',
$this->localhost()->getHostname()
);
}
2016-11-27 18:54:07 -05:00
public function testReturnsCorrectIdentifierWhenCastedToString()
{
$this->assertEquals(
'localhost;Hoststatus',
2016-11-27 18:54:07 -05:00
(string) $this->localhost()
);
}
public function testReturnsCorrectAlias()
{
$this->assertEquals(
'localhost',
$this->localhost()->getAlias()
);
}
public function testRendersCorrectLink()
{
$this->assertEquals(
'<a href="/icingaweb2/monitoring/host/show?host=localhost">'
. 'localhost</a>',
$this->localhost()->getLink()->render()
);
}
2016-11-29 05:17:42 -05:00
/**
* @expectedException \Icinga\Exception\ProgrammingError
2016-11-29 05:17:42 -05:00
*/
2017-01-11 18:04:58 -05:00
public function testSettingAnInvalidStateFails()
2016-11-29 05:17:42 -05:00
{
2017-01-11 08:04:45 -05:00
$bp = new BpConfig();
2016-11-29 05:17:42 -05:00
$host = $bp->createHost('localhost')->setState(98);
$bp->createBp('p')->addChild($host)->getState();
}
/**
* @return HostNode
*/
protected function localhost()
{
2017-01-11 08:04:45 -05:00
$bp = new BpConfig();
return new HostNode($bp, (object) array(
'hostname' => 'localhost',
'state' => 0,
));
}
2016-11-26 15:13:54 -05:00
}