Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Image/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,11 @@ protected static function create($formatID)
{
switch ($formatID) {
case static::ID_JPEG:
return new static($formatID, 'jpg', 'image/jpeg', array('jpg', 'pjpeg', 'jfif'));
return new static($formatID, 'image/jpeg', 'jpg', array('jpg', 'pjpeg', 'jfif'));
case static::ID_WBMP:
return new static($formatID, 'jpg', 'vnd.wap.wbmp');
return new static($formatID, 'image/vnd.wap.wbmp', $formatID);
default:
return new static($formatID, $formatID, "image/{$formatID}");
return new static($formatID, "image/{$formatID}", $formatID);
}
}
}
41 changes: 41 additions & 0 deletions tests/tests/Image/FormatTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Imagine package.
*
* (c) Bulat Shakirzyanov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Imagine\Test\Image;

use Imagine\Image\Format;
use Imagine\Test\ImagineTestCase;

class FormatTest extends ImagineTestCase
{
public function formatIdMimeTypeProvider()
{
return array(
array(Format::ID_JPEG, 'image/jpeg'),
array(Format::ID_WBMP, 'image/vnd.wap.wbmp'),
array(Format::ID_AVIF, 'image/avif'),
array(Format::ID_WEBP, 'image/webp'),
);
}

/**
* @dataProvider formatIdMimeTypeProvider
*
* @param string $formatId
* @param string $expectedMimeType
*/
public function testMimeTypes($formatId, $expectedMimeType)
{
$format = Format::get($formatId);

$this->assertEquals($format->getMimeType(), $expectedMimeType);
}
}