diff --git a/tests/ViewFunctions/SizeForHumansTest.php b/tests/ViewFunctions/SizeForHumansTest.php index 58273e1..c15b846 100644 --- a/tests/ViewFunctions/SizeForHumansTest.php +++ b/tests/ViewFunctions/SizeForHumansTest.php @@ -3,6 +3,7 @@ namespace Tests\ViewFunctions; use App\ViewFunctions\SizeForHumans; +use RuntimeException; use Symfony\Component\Finder\SplFileInfo; use Tests\TestCase; @@ -78,4 +79,15 @@ class SizeForHumansTest extends TestCase $this->assertEquals('8.00EB', $sizeForHumans($file)); } + + /** @test */ + public function it_returns_zero_bytes_when_it_can_not_get_the_file_size(): void + { + $file = $this->createMock(SplFileInfo::class); + $file->method('getSize')->willThrowException(new RuntimeException); + + $sizeForHumans = new SizeForHumans; + + $this->assertEquals('0B', $sizeForHumans($file)); + } }