mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-06-06 15:22:26 -04:00
Add SPDX license headers and mark source files as GPL-3.0-or-later to preserve the option to relicense under later GPL versions.
75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
// SPDX-FileCopyrightText: 2021 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
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());
|
|
}
|
|
}
|