From f66ab8dae2f3d0418759f81a3a64dc9517a62449 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:31 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- .../Director/Application/DependencyTest.php | 72 ++++++++++++++++++++++ .../Application/FiltersWorkAsExpectedTest.php | 15 +++++ .../Director/Application/MemoryLimitTest.php | 67 ++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 test/php/library/Director/Application/DependencyTest.php create mode 100644 test/php/library/Director/Application/FiltersWorkAsExpectedTest.php create mode 100644 test/php/library/Director/Application/MemoryLimitTest.php (limited to 'test/php/library/Director/Application') diff --git a/test/php/library/Director/Application/DependencyTest.php b/test/php/library/Director/Application/DependencyTest.php new file mode 100644 index 0000000..cc6047e --- /dev/null +++ b/test/php/library/Director/Application/DependencyTest.php @@ -0,0 +1,72 @@ +=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()); + } +} diff --git a/test/php/library/Director/Application/FiltersWorkAsExpectedTest.php b/test/php/library/Director/Application/FiltersWorkAsExpectedTest.php new file mode 100644 index 0000000..216a925 --- /dev/null +++ b/test/php/library/Director/Application/FiltersWorkAsExpectedTest.php @@ -0,0 +1,15 @@ +assertTrue($filter->matches((object) ['a' => '1']), '1 is not true'); + } +} diff --git a/test/php/library/Director/Application/MemoryLimitTest.php b/test/php/library/Director/Application/MemoryLimitTest.php new file mode 100644 index 0000000..8b4301d --- /dev/null +++ b/test/php/library/Director/Application/MemoryLimitTest.php @@ -0,0 +1,67 @@ +assertTrue(is_int(MemoryLimit::parsePhpIniByteString('1073741824'))); + $this->assertEquals( + 1073741824, + MemoryLimit::parsePhpIniByteString('1073741824') + ); + } + + public function testIntegersAreAccepted() + { + $this->assertEquals( + MemoryLimit::parsePhpIniByteString(1073741824), + 1073741824 + ); + } + + public function testNoLimitGivesMinusOne() + { + $this->assertTrue(is_int(MemoryLimit::parsePhpIniByteString('-1'))); + $this->assertEquals( + -1, + MemoryLimit::parsePhpIniByteString('-1') + ); + } + + public function testInvalidStringGivesBytes() + { + $this->assertEquals( + 1024, + MemoryLimit::parsePhpIniByteString('1024MB') + ); + } + + public function testHandlesKiloBytes() + { + $this->assertEquals( + 45 * 1024, + MemoryLimit::parsePhpIniByteString('45K') + ); + } + + public function testHandlesMegaBytes() + { + $this->assertEquals( + 512 * 1024 * 1024, + MemoryLimit::parsePhpIniByteString('512M') + ); + } + + public function testHandlesGigaBytes() + { + $this->assertEquals( + 2 * 1024 * 1024 * 1024, + MemoryLimit::parsePhpIniByteString('2G') + ); + } +} -- cgit v1.2.3