2016-11-23 18:29:30 -05:00
|
|
|
<?php
|
|
|
|
|
|
2016-12-23 06:46:56 -05:00
|
|
|
namespace Tests\Icinga\Module\Businessprocess;
|
2016-11-23 18:29:30 -05:00
|
|
|
|
2017-01-11 08:04:45 -05:00
|
|
|
use Icinga\Module\Businessprocess\BpConfig;
|
2016-11-23 18:29:30 -05:00
|
|
|
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()
|
2016-11-23 18:29:30 -05:00
|
|
|
{
|
|
|
|
|
$this->assertEquals(
|
2016-11-23 18:30:34 -05:00
|
|
|
'localhost;Hoststatus',
|
2016-11-27 18:54:07 -05:00
|
|
|
(string) $this->localhost()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testReturnsCorrectAlias()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
'localhost',
|
2016-11-23 18:29:30 -05:00
|
|
|
$this->localhost()->getAlias()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testRendersCorrectLink()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals(
|
2019-02-18 09:24:12 -05:00
|
|
|
'<a href="/icingaweb2/businessprocess/host/show?host=localhost">'
|
2016-11-23 18:30:34 -05:00
|
|
|
. 'localhost</a>',
|
2016-11-28 18:36:05 -05:00
|
|
|
$this->localhost()->getLink()->render()
|
2016-11-23 18:29:30 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-29 05:17:42 -05:00
|
|
|
/**
|
2016-11-29 05:23:11 -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();
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-23 18:29:30 -05:00
|
|
|
/**
|
|
|
|
|
* @return HostNode
|
|
|
|
|
*/
|
|
|
|
|
protected function localhost()
|
|
|
|
|
{
|
2017-01-11 08:04:45 -05:00
|
|
|
$bp = new BpConfig();
|
2019-02-04 02:37:36 -05:00
|
|
|
return (new HostNode((object) array(
|
2016-11-23 18:29:30 -05:00
|
|
|
'hostname' => 'localhost',
|
|
|
|
|
'state' => 0,
|
2019-02-04 02:37:36 -05:00
|
|
|
)))->setBpConfig($bp);
|
2016-11-23 18:29:30 -05:00
|
|
|
}
|
2016-11-26 15:13:54 -05:00
|
|
|
}
|