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:
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
|
Reference in New Issue
Block a user