From 5a53e16883714afa258bdec7dfaf2e91ff3236cd Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Sun, 25 Apr 2021 16:39:46 -0700 Subject: [PATCH] Added a test case to SizeForHumansTest --- tests/ViewFunctions/SizeForHumansTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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)); + } }