diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /test/php/library/Director/Application/MemoryLimitTest.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/php/library/Director/Application/MemoryLimitTest.php')
-rw-r--r-- | test/php/library/Director/Application/MemoryLimitTest.php | 67 |
1 files changed, 67 insertions, 0 deletions
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 @@ +<?php + +namespace Tests\Icinga\Module\Director\Application; + +use Icinga\Module\Director\Application\MemoryLimit; +use Icinga\Module\Director\Test\BaseTestCase; + +class MemoryLimitTest extends BaseTestCase +{ + public function testBytesValuesAreHandled() + { + $this->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') + ); + } +} |