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\ServiceNode;
|
|
|
|
|
use Icinga\Module\Businessprocess\Test\BaseTestCase;
|
|
|
|
|
|
|
|
|
|
class ServiceNodeTest extends BaseTestCase
|
|
|
|
|
{
|
|
|
|
|
public function testReturnsCorrectHostName()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
'localhost',
|
|
|
|
|
$this->pingOnLocalhost()->getHostname()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testReturnsCorrectServiceDescription()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
'ping <> pong',
|
|
|
|
|
$this->pingOnLocalhost()->getServiceDescription()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testReturnsCorrectAlias()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
'localhost: ping <> pong',
|
|
|
|
|
$this->pingOnLocalhost()->getAlias()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testRendersCorrectLink()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals(
|
2019-02-18 09:24:12 -05:00
|
|
|
'<a href="/icingaweb2/businessprocess/service/show?host=localhost&service=ping%20%3C%3E%20pong">'
|
2016-11-23 18:29:30 -05:00
|
|
|
. 'localhost: ping <> pong</a>',
|
2016-11-28 18:36:05 -05:00
|
|
|
$this->pingOnLocalhost()->getLink()->render()
|
2016-11-23 18:29:30 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return ServiceNode
|
|
|
|
|
*/
|
|
|
|
|
protected function pingOnLocalhost()
|
|
|
|
|
{
|
2017-01-11 08:04:45 -05:00
|
|
|
$bp = new BpConfig();
|
2016-11-23 18:29:30 -05:00
|
|
|
return new ServiceNode($bp, (object) array(
|
|
|
|
|
'hostname' => 'localhost',
|
|
|
|
|
'service' => 'ping <> pong',
|
|
|
|
|
'state' => 0,
|
|
|
|
|
));
|
|
|
|
|
}
|
2016-11-26 15:13:54 -05:00
|
|
|
}
|