diff --git a/tests/Colors/Cmyk/Decoders/StringColorDecoderTest.php b/tests/Colors/Cmyk/Decoders/StringColorDecoderTest.php index f73093c8..2dd30ed8 100644 --- a/tests/Colors/Cmyk/Decoders/StringColorDecoderTest.php +++ b/tests/Colors/Cmyk/Decoders/StringColorDecoderTest.php @@ -6,6 +6,7 @@ namespace Intervention\Image\Tests\Colors\Cmyk\Decoders; use Intervention\Image\Colors\Cmyk\Color; use Intervention\Image\Colors\Cmyk\Decoders\StringColorDecoder; +use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Tests\TestCase; /** @@ -29,9 +30,15 @@ class StringColorDecoderTest extends TestCase $this->assertInstanceOf(Color::class, $result); $this->assertEquals([0, 100, 100, 0], $result->toArray()); - $result = $decoder->decode('cmyk(0%, 100%, 100%, 0%)'); $this->assertInstanceOf(Color::class, $result); $this->assertEquals([0, 100, 100, 0], $result->toArray()); } + + public function testDecodeInvalid(): void + { + $decoder = new StringColorDecoder(); + $this->expectException(DecoderException::class); + $decoder->decode(null); + } } diff --git a/tests/Drivers/Gd/Modifiers/QuantizeColorsModifierTest.php b/tests/Drivers/Gd/Modifiers/QuantizeColorsModifierTest.php index 8d0435ec..8343b40d 100644 --- a/tests/Drivers/Gd/Modifiers/QuantizeColorsModifierTest.php +++ b/tests/Drivers/Gd/Modifiers/QuantizeColorsModifierTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Tests\Drivers\Gd\Modifiers; +use Intervention\Image\Exceptions\InputException; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Modifiers\QuantizeColorsModifier; use Intervention\Image\Tests\TestCase; @@ -26,6 +27,21 @@ class QuantizeColorsModifierTest extends TestCase $this->assertColorCount(4, $image); } + public function testNoColorReduction(): void + { + $image = $this->readTestImage('gradient.bmp'); + $this->assertColorCount(15, $image); + $image->modify(new QuantizeColorsModifier(150)); + $this->assertColorCount(15, $image); + } + + public function testInvalidColorInput(): void + { + $image = $this->readTestImage('gradient.bmp'); + $this->expectException(InputException::class); + $image->modify(new QuantizeColorsModifier(0)); + } + private function assertColorCount(int $count, ImageInterface $image): void { $colors = []; diff --git a/tests/Drivers/Gd/Modifiers/RemoveAnimationModifierTest.php b/tests/Drivers/Gd/Modifiers/RemoveAnimationModifierTest.php index f46950da..ea190c6a 100644 --- a/tests/Drivers/Gd/Modifiers/RemoveAnimationModifierTest.php +++ b/tests/Drivers/Gd/Modifiers/RemoveAnimationModifierTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Tests\Drivers\Gd\Modifiers; +use Intervention\Image\Exceptions\InputException; use Intervention\Image\Modifiers\RemoveAnimationModifier; use Intervention\Image\Tests\TestCase; use Intervention\Image\Tests\Traits\CanCreateGdTestImage; @@ -34,4 +35,11 @@ class RemoveAnimationModifierTest extends TestCase $this->assertEquals(1, count($image)); $this->assertEquals(1, count($result)); } + + public function testApplyInvalid(): void + { + $image = $this->readTestImage('animation.gif'); + $this->expectException(InputException::class); + $image->modify(new RemoveAnimationModifier('test')); + } } diff --git a/tests/Drivers/Imagick/Modifiers/QuantizeColorsModifierTest.php b/tests/Drivers/Imagick/Modifiers/QuantizeColorsModifierTest.php index cf0e860b..29bc62ef 100644 --- a/tests/Drivers/Imagick/Modifiers/QuantizeColorsModifierTest.php +++ b/tests/Drivers/Imagick/Modifiers/QuantizeColorsModifierTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Tests\Drivers\Imagick\Modifiers; +use Intervention\Image\Exceptions\InputException; use Intervention\Image\Modifiers\QuantizeColorsModifier; use Intervention\Image\Tests\TestCase; use Intervention\Image\Tests\Traits\CanCreateImagickTestImage; @@ -24,4 +25,19 @@ class QuantizeColorsModifierTest extends TestCase $image->modify(new QuantizeColorsModifier(4)); $this->assertEquals(4, $image->core()->native()->getImageColors()); } + + public function testNoColorReduction(): void + { + $image = $this->readTestImage('gradient.bmp'); + $this->assertEquals(15, $image->core()->native()->getImageColors()); + $image->modify(new QuantizeColorsModifier(150)); + $this->assertEquals(15, $image->core()->native()->getImageColors()); + } + + public function testInvalidColorInput(): void + { + $image = $this->readTestImage('gradient.bmp'); + $this->expectException(InputException::class); + $image->modify(new QuantizeColorsModifier(0)); + } } diff --git a/tests/Drivers/Imagick/Modifiers/RemoveAnimationModifierTest.php b/tests/Drivers/Imagick/Modifiers/RemoveAnimationModifierTest.php index 9ca4c126..c12fb96e 100644 --- a/tests/Drivers/Imagick/Modifiers/RemoveAnimationModifierTest.php +++ b/tests/Drivers/Imagick/Modifiers/RemoveAnimationModifierTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Intervention\Image\Tests\Drivers\Imagick\Modifiers; +use Intervention\Image\Exceptions\InputException; use Intervention\Image\Modifiers\RemoveAnimationModifier; use Intervention\Image\Tests\TestCase; use Intervention\Image\Tests\Traits\CanCreateImagickTestImage; @@ -34,4 +35,11 @@ class RemoveAnimationModifierTest extends TestCase $this->assertEquals(1, count($image)); $this->assertEquals(1, count($result)); } + + public function testApplyInvalid(): void + { + $image = $this->readTestImage('animation.gif'); + $this->expectException(InputException::class); + $image->modify(new RemoveAnimationModifier('test')); + } }