1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OpCacheGUITest\Unit\Format; |
4
|
|
|
|
5
|
|
|
use OpCacheGUI\Format\Byte; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
class ByteTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @covers OpCacheGUI\Format\Byte::format |
12
|
|
|
*/ |
13
|
|
|
public function testFormatWithBytes() |
14
|
|
|
{ |
15
|
|
|
$formatter = new Byte(); |
16
|
|
|
|
17
|
|
|
$this->assertSame('120B', $formatter->format(120)); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @covers OpCacheGUI\Format\Byte::format |
22
|
|
|
*/ |
23
|
|
|
public function testFormatWithKiloBytes() |
24
|
|
|
{ |
25
|
|
|
$formatter = new Byte(); |
26
|
|
|
|
27
|
|
|
$this->assertSame('11.72KB', $formatter->format(12000)); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @covers OpCacheGUI\Format\Byte::format |
32
|
|
|
*/ |
33
|
|
|
public function testFormatWithMegaBytes() |
34
|
|
|
{ |
35
|
|
|
$formatter = new Byte(); |
36
|
|
|
|
37
|
|
|
$this->assertSame('11.44MB', $formatter->format(12000000)); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @covers OpCacheGUI\Format\Byte::format |
42
|
|
|
*/ |
43
|
|
|
public function testFormatWithGigaBytes() |
44
|
|
|
{ |
45
|
|
|
$formatter = new Byte(); |
46
|
|
|
|
47
|
|
|
$this->assertSame('11.18GB', $formatter->format(12000000000)); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @covers OpCacheGUI\Format\Byte::format |
52
|
|
|
*/ |
53
|
|
|
public function testFormatWithMoteThanGigaBytes() |
54
|
|
|
{ |
55
|
|
|
$formatter = new Byte(); |
56
|
|
|
|
57
|
|
|
$this->assertSame('10913.94GB', $formatter->format(12000000000000000)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @covers OpCacheGUI\Format\Byte::format |
62
|
|
|
*/ |
63
|
|
|
public function testFormatWithKiloBytesAndNoDecimals() |
64
|
|
|
{ |
65
|
|
|
$formatter = new Byte(); |
66
|
|
|
|
67
|
|
|
$this->assertSame('12KB', $formatter->format(12000, 0)); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @covers OpCacheGUI\Format\Byte::format |
72
|
|
|
*/ |
73
|
|
|
public function testFormatWithKiloBytesAndOneDecimals() |
74
|
|
|
{ |
75
|
|
|
$formatter = new Byte(); |
76
|
|
|
|
77
|
|
|
$this->assertSame('11.7KB', $formatter->format(12000, 1)); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @covers OpCacheGUI\Format\Byte::format |
82
|
|
|
*/ |
83
|
|
|
public function testFormatWithKiloBytesAndFourDecimals() |
84
|
|
|
{ |
85
|
|
|
$formatter = new Byte(); |
86
|
|
|
|
87
|
|
|
$this->assertSame('11.7188KB', $formatter->format(12000, 4)); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|