diff --git a/tests/Drivers/Gd/CoreTest.php b/tests/Drivers/Gd/CoreTest.php index 8afc5e5f..69e63a37 100644 --- a/tests/Drivers/Gd/CoreTest.php +++ b/tests/Drivers/Gd/CoreTest.php @@ -5,6 +5,7 @@ namespace Intervention\Image\Tests\Drivers\Gd; use GdImage; use Intervention\Image\Drivers\Gd\Core; use Intervention\Image\Drivers\Gd\Frame; +use Intervention\Image\Exceptions\AnimationException; use Intervention\Image\Tests\TestCase; class CoreTest extends TestCase @@ -46,6 +47,8 @@ class CoreTest extends TestCase ]); $this->assertInstanceOf(Frame::class, $core->frame(0)); $this->assertInstanceOf(Frame::class, $core->frame(1)); + $this->expectException(AnimationException::class); + $core->frame(10); } public function testSetGetLoops(): void @@ -59,4 +62,15 @@ class CoreTest extends TestCase $this->assertInstanceOf(Core::class, $result); $this->assertEquals(12, $core->loops()); } + + public function testLast(): void + { + $core = new Core([ + new Frame(imagecreatetruecolor(3, 2)), + new Frame(imagecreatetruecolor(3, 2)), + ]); + + $result = $core->last(); + $this->assertInstanceOf(Frame::class, $result); + } } diff --git a/tests/Drivers/Imagick/CoreTest.php b/tests/Drivers/Imagick/CoreTest.php index 073db232..5784450f 100644 --- a/tests/Drivers/Imagick/CoreTest.php +++ b/tests/Drivers/Imagick/CoreTest.php @@ -139,4 +139,25 @@ class CoreTest extends TestCase $this->assertEquals(2, $core->count()); $this->assertEquals(2, $result->count()); } + + public function testLast(): void + { + $imagick = new Imagick(); + + $im = new Imagick(); + $im->newImage(10, 10, new ImagickPixel('red')); + $imagick->addImage($im); + + $im = new Imagick(); + $im->newImage(10, 10, new ImagickPixel('green')); + $imagick->addImage($im); + + $im = new Imagick(); + $im->newImage(10, 10, new ImagickPixel('blue')); + $imagick->addImage($im); + + $core = new Core($imagick); + $result = $core->last(); + $this->assertInstanceOf(Frame::class, $result); + } }