1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-14 01:44:03 +02:00

set default output of undefined images to jpeg

This commit is contained in:
Oliver Vogel
2014-05-23 17:12:21 +02:00
parent a9dd84fc63
commit c471b680a1
2 changed files with 9 additions and 8 deletions

View File

@@ -126,7 +126,7 @@ abstract class AbstractEncoder
$format = $this->image->mime; $format = $this->image->mime;
} }
$this->format = $format; $this->format = $format ? $format : 'jpg';
return $this; return $this;
} }

View File

@@ -71,16 +71,16 @@ class EncoderTest extends PHPUnit_Framework_TestCase
$this->assertEquals('image/jpeg; charset=binary', $this->getMime($encoder->result)); $this->assertEquals('image/jpeg; charset=binary', $this->getMime($encoder->result));
} }
/**
* @expectedException \Intervention\Image\Exception\NotSupportedException
*/
public function testProcessUnknownGd() public function testProcessUnknownGd()
{ {
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg'); $core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$encoder = new GdEncoder; $encoder = new GdEncoder;
$image = Mockery::mock('\Intervention\Image\Image'); $image = Mockery::mock('\Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($core);
$image->shouldReceive('setEncoded')->once()->andReturn($image);
$img = $encoder->process($image, null); $img = $encoder->process($image, null);
$this->assertInstanceOf('Intervention\Image\Image', $img); $this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertEquals('image/jpeg; charset=binary', $this->getMime($encoder->result));
} }
public function testProcessJpegImagick() public function testProcessJpegImagick()
@@ -144,15 +144,16 @@ class EncoderTest extends PHPUnit_Framework_TestCase
$this->assertEquals('mock-jpeg', $encoder->result); $this->assertEquals('mock-jpeg', $encoder->result);
} }
/**
* @expectedException \Intervention\Image\Exception\NotSupportedException
*/
public function testProcessUnknownImagick() public function testProcessUnknownImagick()
{ {
$core = Mockery::mock('Imagick'); $core = $this->getImagickMock('jpeg');
$encoder = new ImagickEncoder; $encoder = new ImagickEncoder;
$image = Mockery::mock('\Intervention\Image\Image'); $image = Mockery::mock('\Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($core);
$image->shouldReceive('setEncoded')->once()->andReturn($image);
$img = $encoder->process($image, null); $img = $encoder->process($image, null);
$this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertEquals('mock-jpeg', $encoder->result);
} }
public function getImagickMock($type) public function getImagickMock($type)