|
| 1 | +<?php |
| 2 | + |
| 3 | +use Tatter\Files\Entities\File; |
| 4 | +use Tests\Support\Fakers\FileFaker; |
| 5 | +use Tests\Support\FilesTestCase; |
| 6 | + |
| 7 | +class HelperTest extends FilesTestCase |
| 8 | +{ |
| 9 | + |
| 10 | + public static function setUpBeforeClass(): void |
| 11 | + { |
| 12 | + parent::setUpBeforeClass(); |
| 13 | + |
| 14 | + helper('files'); |
| 15 | + } |
| 16 | + |
| 17 | + /** |
| 18 | + * @dataProvider bytesProvider |
| 19 | + */ |
| 20 | + public function testBytesToHuman($bytes, $expected) |
| 21 | + { |
| 22 | + $this->assertEquals($expected, bytes2human($bytes)); |
| 23 | + } |
| 24 | + |
| 25 | + public function bytesProvider() |
| 26 | + { |
| 27 | + return [ |
| 28 | + [1, '1 bytes'], |
| 29 | + [1024, '1024 bytes'], |
| 30 | + [1025, '1 KB'], |
| 31 | + [1024*1024, '1024 KB'], |
| 32 | + [1024*1025, '1 MB'], |
| 33 | + [1024*1024*1024, '1024 MB'], |
| 34 | + [1024*1024*1025, '1 GB'], |
| 35 | + [1024*1024*1024*1024, '1024 GB'], |
| 36 | + [1024*1024*1024*1025, '1 TB'], |
| 37 | + [1024*1024*1024*1024*1024, '1024 TB'], |
| 38 | + [1024*1024*1024*1024*1025, '1 PB'], |
| 39 | + ]; |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * @dataProvider iniProvider |
| 44 | + */ |
| 45 | + public function testReturnBytes($ini, $expected) |
| 46 | + { |
| 47 | + $this->assertEquals($expected, return_bytes($ini)); |
| 48 | + } |
| 49 | + |
| 50 | + public function iniProvider() |
| 51 | + { |
| 52 | + return [ |
| 53 | + ['1', 1], |
| 54 | + ['1025', 1025], |
| 55 | + ['1k', 1024], |
| 56 | + ['1m', 1024*1024], |
| 57 | + ['1g', 1024*1024*1024], |
| 58 | + ]; |
| 59 | + } |
| 60 | +} |
0 commit comments