icingaweb2-module-businessp.../test/php/library/Businessprocess/ServiceNodeTest.php
Eric Lippmann 0ce3381488 License source files as GPL-3.0-or-later
Add SPDX license headers and mark source files as GPL-3.0-or-later to
preserve the option to relicense under later GPL versions.
2026-03-11 20:44:42 +01:00

59 lines
1.6 KiB
PHP

<?php
// SPDX-FileCopyrightText: 2018 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-3.0-or-later
namespace Tests\Icinga\Module\Businessprocess;
use Icinga\Module\Businessprocess\BpConfig;
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(
'ping <> pong on localhost',
$this->pingOnLocalhost()->getAlias()
);
}
public function testRendersCorrectLink()
{
$this->assertEquals(
'<a href="/icingaweb2/businessprocess/service/show?host=localhost&amp;service=ping%20%3C%3E%20pong">'
. 'ping &lt;&gt; pong on localhost</a>',
$this->pingOnLocalhost()->getLink()->render()
);
}
/**
* @return ServiceNode
*/
protected function pingOnLocalhost()
{
$bp = new BpConfig();
return (new ServiceNode((object) array(
'hostname' => 'localhost',
'service' => 'ping <> pong',
'state' => 0,
)))->setBpConfig($bp)->setHostAlias('localhost')->setAlias('ping <> pong');
}
}