1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-19 12:11:26 +02:00

Add tests

This commit is contained in:
Oliver Vogel
2024-12-28 11:48:09 +01:00
parent 5a1b6f55f8
commit 8e12c2e152
2 changed files with 24 additions and 2 deletions

View File

@@ -16,7 +16,18 @@ use Intervention\Image\Tests\GdTestCase;
#[CoversClass(PixelColorsAnalyzer::class)]
final class PixelColorsAnalyzerTest extends GdTestCase
{
public function testAnalyze(): void
public function testAnalyzeAnimated(): void
{
$image = $this->readTestImage('animation.gif');
$analyzer = new PixelColorsAnalyzer(0, 0);
$analyzer->setDriver(new Driver());
$result = $analyzer->analyze($image);
$this->assertInstanceOf(Collection::class, $result);
$colors = array_map(fn(ColorInterface $color) => $color->toHex(), $result->toArray());
$this->assertEquals($colors, ["394b63", "394b63", "394b63", "ffa601", "ffa601", "ffa601", "ffa601", "394b63"]);
}
public function testAnalyzeNonAnimated(): void
{
$image = $this->readTestImage('tile.png');
$analyzer = new PixelColorsAnalyzer(0, 0);

View File

@@ -16,7 +16,18 @@ use Intervention\Image\Tests\ImagickTestCase;
#[CoversClass(PixelColorsAnalyzer::class)]
final class PixelColorsAnalyzerTest extends ImagickTestCase
{
public function testAnalyze(): void
public function testAnalyzeAnimated(): void
{
$image = $this->readTestImage('animation.gif');
$analyzer = new PixelColorsAnalyzer(0, 0);
$analyzer->setDriver(new Driver());
$result = $analyzer->analyze($image);
$this->assertInstanceOf(Collection::class, $result);
$colors = array_map(fn(ColorInterface $color) => $color->toHex(), $result->toArray());
$this->assertEquals($colors, ["394b63", "394b63", "394b63", "ffa601", "ffa601", "ffa601", "ffa601", "394b63"]);
}
public function testAnalyzeNonAnimated(): void
{
$image = $this->readTestImage('tile.png');
$analyzer = new PixelColorsAnalyzer(0, 0);