diff --git a/src/Models/Media.php b/src/Models/Media.php index e04be32..3c00527 100644 --- a/src/Models/Media.php +++ b/src/Models/Media.php @@ -69,7 +69,7 @@ protected function fileName(): Attribute return Attribute::make( set: function ($value) { $fileName = sha1($value.microtime()); - $ext = pathinfo($value, PATHINFO_EXTENSION); + $ext = strtolower(pathinfo($value, PATHINFO_EXTENSION)); return "$fileName.$ext"; }, diff --git a/tests/FileStorageTest.php b/tests/FileStorageTest.php index 1b6ca7d..4558dc8 100644 --- a/tests/FileStorageTest.php +++ b/tests/FileStorageTest.php @@ -36,7 +36,7 @@ protected function setUp(): void $this->fileStorage = new FileStorage($config); - $path = __DIR__.'/TestSupport/assets/avatar.jpg'; + $path = __DIR__.'/TestSupport/assets/avatar.JPG'; $this->testFile = UploadedFile::fake()->create($path, file_get_contents($path)); Queue::fake(); @@ -54,6 +54,7 @@ public function testCreateMedia(): void $this->assertNull($media->preview); $this->assertSame($media->type, TestDocumentType::AVATAR->value); + $this->assertSame('jpg', pathinfo($media->file_name, PATHINFO_EXTENSION)); Queue::assertPushedWithChain(OptimizeImage::class, [ GeneratePreview::class, @@ -66,7 +67,7 @@ public function testUpdateMedia(): void $originalMedia = Media::factory()->create([ 'model_type' => 'App/Models/User', 'model_id' => 1, - 'file_name' => 'fake-file.jpg', + 'file_name' => 'fake-file.JPG', 'type' => TestDocumentType::AVATAR, ]); diff --git a/tests/TestSupport/assets/avatar.jpg b/tests/TestSupport/assets/avatar.JPG similarity index 100% rename from tests/TestSupport/assets/avatar.jpg rename to tests/TestSupport/assets/avatar.JPG