Added a test case to SizeForHumansTest

This commit is contained in:
Chris Kankiewicz
2021-04-25 16:39:46 -07:00
parent 5382bfe866
commit 5a53e16883

View File

@@ -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));
}
}