mirror of
https://github.com/Intervention/image.git
synced 2025-08-23 22:12:51 +02:00
Add tests for PNG indexed options
This commit is contained in:
@@ -7,8 +7,10 @@ namespace Intervention\Image\Tests\Unit\Drivers\Gd\Encoders;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use Intervention\Image\Encoders\PngEncoder;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Tests\GdTestCase;
|
||||
use Intervention\Image\Tests\Traits\CanInspectPngFormat;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
#[RequiresPhpExtension('gd')]
|
||||
#[CoversClass(\Intervention\Image\Encoders\PngEncoder::class)]
|
||||
@@ -34,4 +36,59 @@ final class PngEncoderTest extends GdTestCase
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
$this->assertTrue($this->isInterlacedPng((string) $result));
|
||||
}
|
||||
|
||||
#[DataProvider('indexedDataProvider')]
|
||||
public function testEncoderIndexed(ImageInterface $image, PngEncoder $encoder, string $result): void
|
||||
{
|
||||
$this->assertEquals(
|
||||
$result,
|
||||
$this->pngColorType((string) $encoder->encode($image)),
|
||||
);
|
||||
}
|
||||
|
||||
public static function indexedDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
static::createTestImage(3, 2), // new
|
||||
new PngEncoder(indexed: false),
|
||||
'truecolor-alpha',
|
||||
],
|
||||
[
|
||||
static::createTestImage(3, 2), // new
|
||||
new PngEncoder(indexed: true),
|
||||
'indexed',
|
||||
],
|
||||
[
|
||||
static::readTestImage('circle.png'), // truecolor-alpha
|
||||
new PngEncoder(indexed: false),
|
||||
'truecolor-alpha',
|
||||
],
|
||||
[
|
||||
static::readTestImage('circle.png'), // indexedcolor-alpha
|
||||
new PngEncoder(indexed: true),
|
||||
'indexed',
|
||||
],
|
||||
[
|
||||
static::readTestImage('tile.png'), // indexed
|
||||
new PngEncoder(indexed: false),
|
||||
'truecolor-alpha',
|
||||
],
|
||||
[
|
||||
static::readTestImage('tile.png'), // indexed
|
||||
new PngEncoder(indexed: true),
|
||||
'indexed',
|
||||
],
|
||||
[
|
||||
static::readTestImage('test.jpg'), // jpeg
|
||||
new PngEncoder(indexed: false),
|
||||
'truecolor-alpha',
|
||||
],
|
||||
[
|
||||
static::readTestImage('test.jpg'), // jpeg
|
||||
new PngEncoder(indexed: true),
|
||||
'indexed',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user