1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-13 09:24:05 +02:00

check on webp functions before running tests

This commit is contained in:
Oliver Vogel
2017-07-03 17:04:25 +02:00
parent baeeac5125
commit dccbee2e9d
2 changed files with 27 additions and 21 deletions

View File

@@ -48,14 +48,16 @@ class EncoderTest extends PHPUnit_Framework_TestCase
public function testProcessWebpGd()
{
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$encoder = new GdEncoder;
$image = Mockery::mock('\Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($core);
$image->shouldReceive('setEncoded')->once()->andReturn($image);
$img = $encoder->process($image, 'webp', 90);
$this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertEquals('image/webp; charset=binary', $this->getMime($encoder->result));
if (function_exists('imagewebp')) {
$core = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$encoder = new GdEncoder;
$image = Mockery::mock('\Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($core);
$image->shouldReceive('setEncoded')->once()->andReturn($image);
$img = $encoder->process($image, 'webp', 90);
$this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertEquals('image/webp; charset=binary', $this->getMime($encoder->result));
}
}
/**

View File

@@ -85,16 +85,18 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
public function testMakeFromWebp()
{
$img = $this->manager()->make('tests/images/test.webp');
$this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertInternalType('resource', $img->getCore());
$this->assertEquals(16, $img->getWidth());
$this->assertEquals(16, $img->getHeight());
$this->assertEquals('image/webp', $img->mime);
$this->assertEquals('tests/images', $img->dirname);
$this->assertEquals('test.webp', $img->basename);
$this->assertEquals('webp', $img->extension);
$this->assertEquals('test', $img->filename);
if (function_exists('imagecreatefromwebp')) {
$img = $this->manager()->make('tests/images/test.webp');
$this->assertInstanceOf('Intervention\Image\Image', $img);
$this->assertInternalType('resource', $img->getCore());
$this->assertEquals(16, $img->getWidth());
$this->assertEquals(16, $img->getHeight());
$this->assertEquals('image/webp', $img->mime);
$this->assertEquals('tests/images', $img->dirname);
$this->assertEquals('test.webp', $img->basename);
$this->assertEquals('webp', $img->extension);
$this->assertEquals('test', $img->filename);
}
}
public function testCanvas()
@@ -1498,9 +1500,11 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
public function testEncodeWebp()
{
$img = $this->manager()->make('tests/images/trim.png');
$data = (string) $img->encode('webp');
$this->assertEquals('image/webp; charset=binary', $this->getMime($data));
if (function_exists('imagewebp')) {
$img = $this->manager()->make('tests/images/trim.png');
$data = (string) $img->encode('webp');
$this->assertEquals('image/webp; charset=binary', $this->getMime($data));
}
}
public function testEncodeDataUrl()