File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class FormatBytesTest extends TestCase
4+ {
5+ /** @test */
6+ public function it_returns_zero_for_negative_bytes ()
7+ {
8+ $ this ->assertEquals ('0 B ' , format_bytes (-100 ));
9+ }
10+
11+ /** @test */
12+ public function it_works_with_bytes ()
13+ {
14+ $ this ->assertEquals ('450 B ' , format_bytes (450 ));
15+ }
16+
17+ /** @test */
18+ public function it_works_with_kilobytes ()
19+ {
20+ $ this ->assertEquals ('3.68 KB ' , format_bytes (3768 ));
21+ }
22+
23+ /** @test */
24+ public function it_works_with_megabytes ()
25+ {
26+ $ this ->assertEquals ('15.04 MB ' , format_bytes (15768749 ));
27+ }
28+
29+ /** @test */
30+ public function it_works_with_gigabytes ()
31+ {
32+ $ this ->assertEquals ('6.91 GB ' , format_bytes (7415768749 ));
33+ }
34+
35+ /** @test */
36+ public function it_works_with_terabytes ()
37+ {
38+ $ this ->assertEquals ('8.31 TB ' , format_bytes (9137415768749 ));
39+ }
40+
41+ /** @test */
42+ public function terabytes_is_the_greatest_unit ()
43+ {
44+ $ this ->assertEquals ('6702.19 TB ' , format_bytes (7369137415768749 ));
45+ }
46+
47+ /** @test */
48+ public function it_works_with_zero_precision ()
49+ {
50+ $ this ->assertEquals ('703 MB ' , format_bytes (736968749 , 0 ));
51+ }
52+
53+ /** @test */
54+ public function it_works_with_custom_precision ()
55+ {
56+ $ this ->assertEquals ('80.121 MB ' , format_bytes (84012659 , 3 ));
57+ }
58+ }
You can’t perform that action at this time.
0 commit comments