From 8e12c2e15265eee68758236d20443da5702d8cf2 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sat, 28 Dec 2024 11:48:09 +0100 Subject: [PATCH] Add tests --- .../Gd/Analyzers/PixelColorsAnalyzerTest.php | 13 ++++++++++++- .../Imagick/Analyzers/PixelColorsAnalyzerTest.php | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/Unit/Drivers/Gd/Analyzers/PixelColorsAnalyzerTest.php b/tests/Unit/Drivers/Gd/Analyzers/PixelColorsAnalyzerTest.php index 9afa671f..927e80a0 100644 --- a/tests/Unit/Drivers/Gd/Analyzers/PixelColorsAnalyzerTest.php +++ b/tests/Unit/Drivers/Gd/Analyzers/PixelColorsAnalyzerTest.php @@ -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); diff --git a/tests/Unit/Drivers/Imagick/Analyzers/PixelColorsAnalyzerTest.php b/tests/Unit/Drivers/Imagick/Analyzers/PixelColorsAnalyzerTest.php index f28d9621..c48a8881 100644 --- a/tests/Unit/Drivers/Imagick/Analyzers/PixelColorsAnalyzerTest.php +++ b/tests/Unit/Drivers/Imagick/Analyzers/PixelColorsAnalyzerTest.php @@ -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);