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:
parent
93fcd10287
commit
55c64ef812
34
tests/Unit/Drivers/Gd/Decoders/NativeObjectDecoderTest.php
Normal file
34
tests/Unit/Drivers/Gd/Decoders/NativeObjectDecoderTest.php
Normal 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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user