From 37113934a2f429531714b5d0a999c4686c57173e Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 8 May 2024 20:12:23 +0200 Subject: [PATCH] Remove file format restriction (#2452) --- psalm.xml | 2 ++ src/Thumbnail/FileThumbnail.php | 4 ---- tests/Thumbnail/FileThumbnailTest.php | 7 +++---- tests/Thumbnail/FormatThumbnailTest.php | 2 +- tests/Thumbnail/LiipImagineThumbnailTest.php | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/psalm.xml b/psalm.xml index e9cc8e7e5..199e51a24 100644 --- a/psalm.xml +++ b/psalm.xml @@ -21,5 +21,7 @@ + + diff --git a/src/Thumbnail/FileThumbnail.php b/src/Thumbnail/FileThumbnail.php index ea418d881..816af8d40 100644 --- a/src/Thumbnail/FileThumbnail.php +++ b/src/Thumbnail/FileThumbnail.php @@ -28,10 +28,6 @@ public function __construct(private Packages $packages) public function generatePublicUrl(MediaProviderInterface $provider, MediaInterface $media, string $format): string { - if (MediaProviderInterface::FORMAT_ADMIN !== $format) { - throw new \InvalidArgumentException(sprintf('Unsupported format "%s".', $format)); - } - return $this->packages->getUrl('bundles/sonatamedia/file.png'); } diff --git a/tests/Thumbnail/FileThumbnailTest.php b/tests/Thumbnail/FileThumbnailTest.php index e32e0987e..e9f064dfb 100644 --- a/tests/Thumbnail/FileThumbnailTest.php +++ b/tests/Thumbnail/FileThumbnailTest.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Sonata\MediaBundle\Tests\Security; +namespace Sonata\MediaBundle\Tests\Thumbnail; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -47,10 +47,9 @@ public function testGeneratePublicUrl(): void static::assertSame('bundles/sonatamedia/file.png', $publicUrl); - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Unsupported format "random".'); + $publicUrl = $this->thumbnail->generatePublicUrl($provider, $media, 'random'); - $this->thumbnail->generatePublicUrl($provider, $media, 'random'); + static::assertSame('bundles/sonatamedia/file.png', $publicUrl); } public function testGeneratePrivateUrl(): void diff --git a/tests/Thumbnail/FormatThumbnailTest.php b/tests/Thumbnail/FormatThumbnailTest.php index 4ac83c470..cd1fd53fa 100644 --- a/tests/Thumbnail/FormatThumbnailTest.php +++ b/tests/Thumbnail/FormatThumbnailTest.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Sonata\MediaBundle\Tests\Security; +namespace Sonata\MediaBundle\Tests\Thumbnail; use Gaufrette\Adapter\InMemory; use Gaufrette\File; diff --git a/tests/Thumbnail/LiipImagineThumbnailTest.php b/tests/Thumbnail/LiipImagineThumbnailTest.php index 139247303..6c99f5d9d 100644 --- a/tests/Thumbnail/LiipImagineThumbnailTest.php +++ b/tests/Thumbnail/LiipImagineThumbnailTest.php @@ -11,7 +11,7 @@ * file that was distributed with this source code. */ -namespace Sonata\MediaBundle\Tests\Security; +namespace Sonata\MediaBundle\Tests\Thumbnail; use Gaufrette\Adapter\InMemory; use Gaufrette\File;