mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-02-14 00:13:27 -05:00
parent
e6c292333b
commit
8c12491a84
2 changed files with 105 additions and 0 deletions
48
test/php/library/Businessprocess/HostNodeTest.php
Normal file
48
test/php/library/Businessprocess/HostNodeTest.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
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
|
||||
{
|
||||
public function testReturnsCorrectHostName()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'localhost',
|
||||
$this->localhost()->getHostname()
|
||||
);
|
||||
}
|
||||
|
||||
public function testReturnsCorrectAlias()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'localhost',
|
||||
$this->localhost()->getAlias()
|
||||
);
|
||||
}
|
||||
|
||||
public function testRendersCorrectLink()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'<a href="/icingaweb2/monitoring/host/show?host=localhost">'
|
||||
. 'localhost: ping <> pong</a>',
|
||||
$this->localhost()->renderLink(new View())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HostNode
|
||||
*/
|
||||
protected function localhost()
|
||||
{
|
||||
$bp = new BusinessProcess();
|
||||
return new HostNode($bp, (object) array(
|
||||
'hostname' => 'localhost',
|
||||
'state' => 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
57
test/php/library/Businessprocess/ServiceNodeTest.php
Normal file
57
test/php/library/Businessprocess/ServiceNodeTest.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
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
|
||||
{
|
||||
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(
|
||||
'<a href="/icingaweb2/monitoring/service/show?host=localhost&service=ping%20%3C%3E%20pong">'
|
||||
. 'localhost: ping <> pong</a>',
|
||||
$this->pingOnLocalhost()->renderLink(new View())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ServiceNode
|
||||
*/
|
||||
protected function pingOnLocalhost()
|
||||
{
|
||||
$bp = new BusinessProcess();
|
||||
return new ServiceNode($bp, (object) array(
|
||||
'hostname' => 'localhost',
|
||||
'service' => 'ping <> pong',
|
||||
'state' => 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue