summaryrefslogtreecommitdiffstats
path: root/test/php/library/Businessprocess/BpNodeTest.php
blob: c3da723dc394308ca695640780eb7737a2a7ba7a (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
<?php

namespace Tests\Icinga\Module\Businessprocess;

use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\Test\BaseTestCase;

class BpNodeTest extends BaseTestCase
{
    public function testThrowsNestingErrorWhenCheckedForLoops()
    {
        $this->expectException(\Icinga\Module\Businessprocess\Exception\NestingError::class);

        /** @var BpNode $bpNode */
        $bpNode = $this->makeLoop()->getNode('d');
        $bpNode->checkForLoops();
    }

    public function testNestingErrorReportsFullLoop()
    {
        $this->expectException(\Icinga\Module\Businessprocess\Exception\NestingError::class);
        $this->expectExceptionMessage('d -> a -> b -> c -> a');

        /** @var BpNode $bpNode */
        $bpNode = $this->makeLoop()->getNode('d');
        $bpNode->checkForLoops();
    }

    public function testStateForALoopGivesUnknown()
    {
        $loop = $this->makeLoop();
        /** @var BpNode $bpNode */
        $bpNode = $loop->getNode('d');
        $this->assertEquals(
            'UNKNOWN',
            $bpNode->getStateName()
        );
    }
}