mirror of
https://github.com/Intervention/image.git
synced 2025-08-29 16:50:07 +02:00
Add Format::tryCreate()
This commit is contained in:
@@ -38,6 +38,18 @@ final class FormatTest extends BaseTestCase
|
||||
Format::create('foo');
|
||||
}
|
||||
|
||||
public function testTryCreate(): void
|
||||
{
|
||||
$this->assertEquals(Format::JPEG, Format::tryCreate(Format::JPEG));
|
||||
$this->assertEquals(Format::JPEG, Format::tryCreate('jpg'));
|
||||
$this->assertEquals(Format::JPEG, Format::tryCreate('jpeg'));
|
||||
$this->assertEquals(Format::JPEG, Format::tryCreate('image/jpeg'));
|
||||
$this->assertEquals(Format::GIF, Format::tryCreate('image/gif'));
|
||||
$this->assertEquals(Format::PNG, Format::tryCreate(FileExtension::PNG));
|
||||
$this->assertEquals(Format::WEBP, Format::tryCreate(MediaType::IMAGE_WEBP));
|
||||
$this->assertNull(Format::tryCreate('no-format'));
|
||||
}
|
||||
|
||||
public function testMediaTypesJpeg(): void
|
||||
{
|
||||
$format = Format::JPEG;
|
||||
|
Reference in New Issue
Block a user