Skip to content

Commit 996c834

Browse files
committed
Add comments to tests
1 parent f351317 commit 996c834

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/FileSizeTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,29 @@
1010

1111
class FileSizeTest extends \PHPUnit_Framework_TestCase
1212
{
13+
/**
14+
* Test a numeric string input.
15+
*/
1316
public function testBytes()
1417
{
1518
$size = new FileSize('128974848');
1619

1720
$this->assertSame($size->as('B'), 128974848);
1821
}
1922

23+
/**
24+
* Test that "partial bytes" are rounded up.
25+
*/
2026
public function testBytesRounding()
2127
{
2228
$size = new FileSize('99.7 bytes');
2329

2430
$this->assertSame($size->as('B'), 100);
2531
}
2632

33+
/**
34+
* Test #add.
35+
*/
2736
public function testAdd()
2837
{
2938
$size = new FileSize('123 megabytes');
@@ -32,6 +41,9 @@ public function testAdd()
3241
$this->assertSame($size->as('B'), 129128448);
3342
}
3443

44+
/**
45+
* Test #subtract.
46+
*/
3547
public function testSubtract()
3648
{
3749
$size = new FileSize('123M');
@@ -40,6 +52,9 @@ public function testSubtract()
4052
$this->assertSame($size->as('B'), 128821248);
4153
}
4254

55+
/**
56+
* Test #multiplyBy.
57+
*/
4358
public function testMultiplyBy()
4459
{
4560
$size = new FileSize('425.51 m');
@@ -48,6 +63,9 @@ public function testMultiplyBy()
4863
$this->assertSame($size->as('GB'), 3.79);
4964
}
5065

66+
/**
67+
* Test #divideBy.
68+
*/
5169
public function testDivideBy()
5270
{
5371
$size = new FileSize('300K');
@@ -56,27 +74,39 @@ public function testDivideBy()
5674
$this->assertSame($size->as('KiB'), (float) 150);
5775
}
5876

77+
/**
78+
* Test upward unit conversion.
79+
*/
5980
public function testConvertUp()
6081
{
6182
$size = new FileSize('123456789 TB');
6283

6384
$this->assertSame($size->as('exabytes'), 5.74);
6485
}
6586

87+
/**
88+
* Test downward unit conversion.
89+
*/
6690
public function testConvertDown()
6791
{
6892
$size = new FileSize('1 Gigabyte');
6993

7094
$this->assertSame($size->as('B'), 1073741824);
7195
}
7296

97+
/**
98+
* Test when the unit has not changed.
99+
*/
73100
public function testNoConvert()
74101
{
75102
$size = new FileSize('525 Gibibytes');
76103

77104
$this->assertSame($size->as('GB'), (float) 525);
78105
}
79106

107+
/**
108+
* Test auto-formatting for a small value.
109+
*/
80110
public function testAutoSmall()
81111
{
82112
$size = new FileSize('1.2345 KB');
@@ -85,13 +115,19 @@ public function testAutoSmall()
85115
$this->assertSame($size->asAuto(), '422 B');
86116
}
87117

118+
/**
119+
* Test auto-formatting for a large value.
120+
*/
88121
public function testAutoLarge()
89122
{
90123
$size = new FileSize('1234522678.12 KB');
91124

92125
$this->assertSame($size->asAuto(), '1.15 TB');
93126
}
94127

128+
/**
129+
* Test the rounding in auto-formatting (should not leave trailing zeros).
130+
*/
95131
public function testAutoRounding()
96132
{
97133
$size = new FileSize('158.1983 mb');

0 commit comments

Comments
 (0)