blob: 8b4301d3bfc0133478c6a87f86311078fe029d37 (
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
|
<?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')
);
}
}
|