From 59a435366163c57a2b294fbeca1dd89b7840ce94 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Thu, 7 Dec 2023 15:33:15 +0100 Subject: [PATCH] Add tests --- .../Drivers/Gd/Modifiers/ResizeCanvasModifierTest.php | 11 +++++++++++ .../Imagick/Modifiers/ResizeCanvasModifierTest.php | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/Drivers/Gd/Modifiers/ResizeCanvasModifierTest.php b/tests/Drivers/Gd/Modifiers/ResizeCanvasModifierTest.php index d01cfec5..6632b1d3 100644 --- a/tests/Drivers/Gd/Modifiers/ResizeCanvasModifierTest.php +++ b/tests/Drivers/Gd/Modifiers/ResizeCanvasModifierTest.php @@ -41,4 +41,15 @@ class ResizeCanvasModifierTest extends TestCase $this->assertColor(255, 255, 0, 255, $image->pickColor(17, 17)); $this->assertTransparency($image->pickColor(12, 1)); } + + public function testModifyEdge(): void + { + $image = $this->createTestImage(1, 1); + $this->assertColor(255, 0, 0, 255, $image->pickColor(0, 0)); + $image->modify(new ResizeCanvasModifier(null, 2, 'ff0', 'top')); + $this->assertEquals(1, $image->width()); + $this->assertEquals(2, $image->height()); + $this->assertColor(255, 255, 0, 255, $image->pickColor(0, 0)); + $this->assertColor(255, 0, 0, 255, $image->pickColor(0, 1)); + } } diff --git a/tests/Drivers/Imagick/Modifiers/ResizeCanvasModifierTest.php b/tests/Drivers/Imagick/Modifiers/ResizeCanvasModifierTest.php index 0b3d64aa..216c450d 100644 --- a/tests/Drivers/Imagick/Modifiers/ResizeCanvasModifierTest.php +++ b/tests/Drivers/Imagick/Modifiers/ResizeCanvasModifierTest.php @@ -41,4 +41,15 @@ class ResizeCanvasModifierTest extends TestCase $this->assertColor(255, 255, 0, 255, $image->pickColor(17, 17)); $this->assertTransparency($image->pickColor(12, 1)); } + + public function testModifyEdge(): void + { + $image = $this->createTestImage(1, 1); + $this->assertColor(255, 0, 0, 255, $image->pickColor(0, 0)); + $image->modify(new ResizeCanvasModifier(null, 2, 'ff0', 'top')); + $this->assertEquals(1, $image->width()); + $this->assertEquals(2, $image->height()); + $this->assertColor(255, 255, 0, 255, $image->pickColor(0, 0)); + $this->assertColor(255, 0, 0, 255, $image->pickColor(0, 1)); + } }