1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 12:18:14 +01:00

Add tests for NativeObjectDecoders

This commit is contained in:
Oliver Vogel 2024-05-09 09:15:44 +02:00
parent 93fcd10287
commit 55c64ef812
No known key found for this signature in database
GPG Key ID: 1B19D214C02D69BB
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Intervention\Image\Tests\Unit\Drivers\Gd\Decoders;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Drivers\Gd\Decoders\NativeObjectDecoder;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\Image;
use Intervention\Image\Tests\BaseTestCase;
#[RequiresPhpExtension('gd')]
#[CoversClass(NativeObjectDecoder::class)]
final class NativeObjectDecoderTest extends BaseTestCase
{
protected NativeObjectDecoder $decoder;
protected function setUp(): void
{
$this->decoder = new NativeObjectDecoder();
$this->decoder->setDriver(new Driver());
}
public function testDecode(): void
{
$result = $this->decoder->decode(
imagecreatetruecolor(3, 2)
);
$this->assertInstanceOf(Image::class, $result);
}
}

View File

@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Intervention\Image\Tests\Unit\Drivers\Imagick\Decoders;
use Imagick;
use ImagickPixel;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use Intervention\Image\Drivers\Imagick\Decoders\NativeObjectDecoder;
use Intervention\Image\Drivers\Imagick\Driver;
use Intervention\Image\Image;
use Intervention\Image\Tests\BaseTestCase;
#[RequiresPhpExtension('imagick')]
#[CoversClass(NativeObjectDecoder::class)]
final class NativeObjectDecoderTest extends BaseTestCase
{
protected NativeObjectDecoder $decoder;
protected function setUp(): void
{
$this->decoder = new NativeObjectDecoder();
$this->decoder->setDriver(new Driver());
}
public function testDecode(): void
{
$native = new Imagick();
$native->newImage(3, 2, new ImagickPixel('red'), 'png');
$result = $this->decoder->decode($native);
$this->assertInstanceOf(Image::class, $result);
}
}