From 0947618d8ca47fb87fbee534b0cfbae35c96e6d3 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 4 Dec 2023 18:02:07 +0800 Subject: [PATCH] [10.x] `league/flysystem` 3.22.0 now prefer inclusive mime-type instead of `null`. (#49229) * [10.x] Test Improvements Signed-off-by: Mior Muhammad Zaki * wip Signed-off-by: Mior Muhammad Zaki * Apply fixes from StyleCI * wip Signed-off-by: Mior Muhammad Zaki --------- Signed-off-by: Mior Muhammad Zaki Co-authored-by: StyleCI Bot --- tests/Filesystem/FilesystemAdapterTest.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/Filesystem/FilesystemAdapterTest.php b/tests/Filesystem/FilesystemAdapterTest.php index d6cc99c64dcd..2a98d21a2145 100644 --- a/tests/Filesystem/FilesystemAdapterTest.php +++ b/tests/Filesystem/FilesystemAdapterTest.php @@ -3,6 +3,7 @@ namespace Illuminate\Tests\Filesystem; use Carbon\Carbon; +use Composer\InstalledVersions; use GuzzleHttp\Psr7\Stream; use Illuminate\Filesystem\FilesystemAdapter; use Illuminate\Filesystem\FilesystemManager; @@ -198,9 +199,19 @@ public function testJsonReturnsNullIfJsonDataIsInvalid() $this->assertNull($filesystemAdapter->json('file.json')); } - public function testMimeTypeNotDetected() + public function testMimeTypeDetectedPreferInclusiveMimeTypeOverNullAsEmpty() { + if (version_compare(InstalledVersions::getPrettyVersion('league/flysystem'), '3.22.0', '<')) { + $this->markTestSkipped('Require league/flysystem 3.22.0'); + } + $this->filesystem->write('unknown.mime-type', ''); + $filesystemAdapter = new FilesystemAdapter($this->filesystem, $this->adapter); + $this->assertSame('application/x-empty', $filesystemAdapter->mimeType('unknown.mime-type')); + } + + public function testMimeTypeNotDetected() + { $filesystemAdapter = new FilesystemAdapter($this->filesystem, $this->adapter); $this->assertFalse($filesystemAdapter->mimeType('unknown.mime-type')); } @@ -531,8 +542,6 @@ public function testThrowExceptionsForPut() public function testThrowExceptionsForMimeType() { - $this->filesystem->write('unknown.mime-type', ''); - $adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throw' => true]); try {