summaryrefslogtreecommitdiffstats
path: root/test/php/library/Businessprocess/ServiceNodeTest.php
blob: d56529dbcdde6efc7ae104a113bae34b8203c715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php

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(
            'localhost: ping <> pong',
            $this->pingOnLocalhost()->getAlias()
        );
    }

    public function testRendersCorrectLink()
    {
        $this->assertEquals(
            '<a href="/icingaweb2/businessprocess/service/show?host=localhost&amp;service=ping%20%3C%3E%20pong">'
            . 'localhost: ping &lt;&gt; pong</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');
    }
}