summaryrefslogtreecommitdiffstats
path: root/test/php/library/Director/Application/DependencyTest.php
blob: cc6047eeef3fa8f7527ad899ec9b15e5a8efb566 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

namespace Tests\Icinga\Module\Director\Application;

use Icinga\Module\Director\Application\Dependency;
use Icinga\Module\Director\Test\BaseTestCase;

class DependencyTest extends BaseTestCase
{
    public function testIsNotInstalled()
    {
        $dependency = new Dependency('something', '>=0.3.0');
        $this->assertFalse($dependency->isInstalled());
    }

    public function testNotSatisfiedWhenNotInstalled()
    {
        $dependency = new Dependency('something', '>=0.3.0');
        $this->assertFalse($dependency->isSatisfied());
    }

    public function testIsInstalled()
    {
        $dependency = new Dependency('something', '>=0.3.0');
        $dependency->setInstalledVersion('1.10.0');
        $this->assertTrue($dependency->isInstalled());
    }

    public function testNotEnabled()
    {
        $dependency = new Dependency('something', '>=0.3.0');
        $this->assertFalse($dependency->isEnabled());
    }

    public function testIsEnabled()
    {
        $dependency = new Dependency('something', '>=0.3.0');
        $dependency->setEnabled();
        $this->assertTrue($dependency->isEnabled());
    }

    public function testNotSatisfiedWhenNotEnabled()
    {
        $dependency = new Dependency('something', '>=0.3.0');
        $dependency->setInstalledVersion('1.10.0');
        $this->assertFalse($dependency->isSatisfied());
    }

    public function testSatisfiedWhenEqual()
    {
        $dependency = new Dependency('something', '>=0.3.0');
        $dependency->setInstalledVersion('0.3.0');
        $dependency->setEnabled();
        $this->assertTrue($dependency->isSatisfied());
    }

    public function testSatisfiedWhenGreater()
    {
        $dependency = new Dependency('something', '>=0.3.0');
        $dependency->setInstalledVersion('0.10.0');
        $dependency->setEnabled();
        $this->assertTrue($dependency->isSatisfied());
    }

    public function testNotSatisfiedWhenSmaller()
    {
        $dependency = new Dependency('something', '>=20.3.0');
        $dependency->setInstalledVersion('4.999.999');
        $dependency->setEnabled();
        $this->assertFalse($dependency->isSatisfied());
    }
}