1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-29 16:50:07 +02:00

Add new method Format::fileExtension()

This commit is contained in:
Oliver Vogel
2024-10-06 17:15:16 +02:00
parent 4a5a7f6065
commit 57508a5f5a
2 changed files with 102 additions and 0 deletions

View File

@@ -193,4 +193,94 @@ final class FormatTest extends BaseTestCase
$format = Format::HEIC;
$this->assertInstanceOf(HeicEncoder::class, $format->encoder());
}
public function testFileExtensionsJpeg(): void
{
$format = Format::JPEG;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(2, $extensions);
$this->assertEquals(FileExtension::JPG, $format->fileExtension());
}
public function testFileExtensionsWebp(): void
{
$format = Format::WEBP;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(1, $extensions);
$this->assertEquals(FileExtension::WEBP, $format->fileExtension());
}
public function testFileExtensionsGif(): void
{
$format = Format::GIF;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(1, $extensions);
$this->assertEquals(FileExtension::GIF, $format->fileExtension());
}
public function testFileExtensionsPng(): void
{
$format = Format::PNG;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(1, $extensions);
$this->assertEquals(FileExtension::PNG, $format->fileExtension());
}
public function testFileExtensionsAvif(): void
{
$format = Format::AVIF;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(1, $extensions);
$this->assertEquals(FileExtension::AVIF, $format->fileExtension());
}
public function testFileExtensionsBmp(): void
{
$format = Format::BMP;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(1, $extensions);
$this->assertEquals(FileExtension::BMP, $format->fileExtension());
}
public function testFileExtensionsTiff(): void
{
$format = Format::TIFF;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(2, $extensions);
$this->assertEquals(FileExtension::TIF, $format->fileExtension());
}
public function testFileExtensionsJp2(): void
{
$format = Format::JP2;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(8, $extensions);
$this->assertEquals(FileExtension::JP2, $format->fileExtension());
}
public function testFileExtensionsHeic(): void
{
$format = Format::HEIC;
$extensions = $format->fileExtensions();
$this->assertIsArray($extensions);
$this->assertCount(2, $extensions);
$this->assertEquals(FileExtension::HEIC, $format->fileExtension());
}
}