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

ImageMagick PNG encoder test

This commit is contained in:
Gwendolen Lynch
2021-12-22 12:13:48 +01:00
parent 8ba4b91f56
commit 4952544a52

View File

@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Intervention\Image\Tests\Drivers\Imagick\Encoders;
use Imagick;
use ImagickPixel;
use Intervention\Image\Collection;
use Intervention\Image\Drivers\Imagick\Encoders\PngEncoder;
use Intervention\Image\Drivers\Imagick\Frame;
use Intervention\Image\Drivers\Imagick\Image;
use Intervention\MimeSniffer\MimeSniffer;
use Intervention\MimeSniffer\Types\ImagePng;
use PHPUnit\Framework\TestCase;
/**
* @requires extension imagick
*/
final class PngEncoderTest extends TestCase
{
protected function getTestImage(): Image
{
$imagick = new Imagick();
$imagick->newImage(3, 2, new ImagickPixel('red'), 'jpg');
$frame = new Frame($imagick);
return new Image(new Collection([$frame]));
}
public function testEncode(): void
{
$image = $this->getTestImage();
$encoder = new PngEncoder(75);
$result = $encoder->encode($image);
$this->assertTrue(MimeSniffer::createFromString((string) $result)->matches(new ImagePng()));
}
}