File: SimulationTest.php

package info (click to toggle)
icingaweb2-module-businessprocess 2.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,720 kB
  • sloc: php: 10,971; javascript: 2,019; sh: 115; xml: 49; makefile: 18
file content (47 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download | duplicates (4)
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
<?php

namespace Tests\Icinga\Module\Businessprocess;

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

class SimulationTest extends BaseTestCase
{
    public function testSimulationInstantiation()
    {
        $class = 'Icinga\\Module\\Businessprocess\\Simulation';
        $this->assertInstanceOf(
            $class,
            Simulation::create()
        );
    }

    public function testAppliedSimulation()
    {
        $data = (object) array(
            'state'        => 0,
            'acknowledged' => false,
            'in_downtime'  => false
        );
        $config = $this->makeInstance()->loadProcess('simple_with-header');
        $simulation = Simulation::create(array(
            'host1;Hoststatus' => $data
        ));
        $parent = $config->getBpNode('singleHost');

        $config->applySimulation($simulation);
        $this->assertEquals(
            'OK',
            $parent->getStateName()
        );

        $parent->clearState();
        $data->state = 1;
        $simulation->set('host1;Hoststatus', $data);
        $config->applySimulation($simulation);
        $this->assertEquals(
            'CRITICAL',
            $parent->getStateName()
        );
    }
}