Skip to content

Commit

Permalink
Fix invalid format MIME type definition (#835)
Browse files Browse the repository at this point in the history
  • Loading branch information
xdanik authored Nov 16, 2022
1 parent 9b9aacb commit 9965558
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CHANGELOG

### NEXT (YYYY-MM-DD)

* Fix invalid format MIME type definition (#835, @xdanik)

### 1.3.2 (2022-04-01)
* Workaround for a bug in PHP 7.3+opcache that causes segmentation faults (#826, #829, #828, @ausi, @mnocon, @mlocati)
Expand Down
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);
}
}
}
1 change: 1 addition & 0 deletions tests/tests/Filter/Advanced/BlackWhiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class BlackWhiteTest extends FilterTestCase
{
/**
* @dataProvider getData
*
* @doesNotPerformAssertions
*
* @param int $border
Expand Down
1 change: 1 addition & 0 deletions tests/tests/Image/AbstractImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ public function provideExensions()

/**
* @dataProvider provideExensions
*
* @doesNotPerformAssertions
*
* @param string $extension
Expand Down
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);
}
}
1 change: 1 addition & 0 deletions tests/tests/Issues/Issue131Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ private function getGmagickImagine($file)

/**
* @doesNotPerformAssertions
*
* @group imagick
*/
public function testShouldSaveOneFileWithImagick()
Expand Down

0 comments on commit 9965558

Please sign in to comment.