mirror of
https://github.com/Intervention/image.git
synced 2025-08-19 12:11:26 +02:00
Add tests
This commit is contained in:
@@ -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);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user