Skip to content

Commit

Permalink
Remove file format restriction (#2452)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed May 8, 2024
1 parent 1f8bee3 commit 3711393
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
<referencedMethod name="Symfony\Component\Console\Helper\HelperInterface::ask"/>
</errorLevel>
</UndefinedInterfaceMethod>
<!-- Until we drop PHP < 8.3 support -->
<MissingClassConstType errorLevel="suppress"/>
</issueHandlers>
</psalm>
4 changes: 0 additions & 4 deletions src/Thumbnail/FileThumbnail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
7 changes: 3 additions & 4 deletions tests/Thumbnail/FileThumbnailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Thumbnail/FormatThumbnailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Thumbnail/LiipImagineThumbnailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3711393

Please sign in to comment.