diff --git a/src/Symfony/Component/AssetMapper/Path/LocalPublicAssetsFilesystem.php b/src/Symfony/Component/AssetMapper/Path/LocalPublicAssetsFilesystem.php index 52435409990aa..b7d13cc2e87cd 100644 --- a/src/Symfony/Component/AssetMapper/Path/LocalPublicAssetsFilesystem.php +++ b/src/Symfony/Component/AssetMapper/Path/LocalPublicAssetsFilesystem.php @@ -50,7 +50,7 @@ public function getDestinationPath(): string return $this->publicDir; } - private function compress($targetPath): void + private function compress(string $targetPath): void { foreach ($this->extensionsToCompress as $ext) { if (!str_ends_with($targetPath, ".$ext")) { diff --git a/src/Symfony/Component/AssetMapper/Tests/Compressor/ChainCompressorTest.php b/src/Symfony/Component/AssetMapper/Tests/Compressor/ChainCompressorTest.php index 02612b6981a36..fc81c75229109 100644 --- a/src/Symfony/Component/AssetMapper/Tests/Compressor/ChainCompressorTest.php +++ b/src/Symfony/Component/AssetMapper/Tests/Compressor/ChainCompressorTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\AssetMapper\Compressor\BrotliCompressor; use Symfony\Component\AssetMapper\Compressor\ChainCompressor; +use Symfony\Component\AssetMapper\Compressor\GzipCompressor; use Symfony\Component\AssetMapper\Compressor\ZstandardCompressor; use Symfony\Component\Filesystem\Filesystem; @@ -41,7 +42,10 @@ protected function tearDown(): void public function testCompress() { - $extensions = ['gz']; + $extensions = []; + if (null === (new GzipCompressor())->getUnsupportedReason()) { + $extensions[] = 'gz'; + } if (null === (new BrotliCompressor())->getUnsupportedReason()) { $extensions[] = 'br'; } @@ -49,6 +53,10 @@ public function testCompress() $extensions[] = 'zst'; } + if (!$extensions) { + $this->markTestSkipped('No supported compressors available.'); + } + $this->filesystem->dumpFile(self::WRITABLE_ROOT.'/foo/bar.js', 'foobar'); (new ChainCompressor())->compress(self::WRITABLE_ROOT.'/foo/bar.js');