diff --git a/tests/Drivers/Gd/Decoders/Base64ImageDecoderTest.php b/tests/Drivers/Gd/Decoders/Base64ImageDecoderTest.php new file mode 100644 index 00000000..ae92fed2 --- /dev/null +++ b/tests/Drivers/Gd/Decoders/Base64ImageDecoderTest.php @@ -0,0 +1,22 @@ +decode( + base64_encode($this->getTestImageData('blue.gif')) + ); + $this->assertInstanceOf(Image::class, $result); + } +} diff --git a/tests/Drivers/Gd/Decoders/DataUriImageDecoderTest.php b/tests/Drivers/Gd/Decoders/DataUriImageDecoderTest.php new file mode 100644 index 00000000..fccc146d --- /dev/null +++ b/tests/Drivers/Gd/Decoders/DataUriImageDecoderTest.php @@ -0,0 +1,22 @@ +decode( + sprintf('data:image/jpeg;base64,%s', base64_encode($this->getTestImageData('blue.gif'))) + ); + $this->assertInstanceOf(Image::class, $result); + } +} diff --git a/tests/Drivers/Gd/Decoders/FilePathImageDecoderTest.php b/tests/Drivers/Gd/Decoders/FilePathImageDecoderTest.php new file mode 100644 index 00000000..840063b2 --- /dev/null +++ b/tests/Drivers/Gd/Decoders/FilePathImageDecoderTest.php @@ -0,0 +1,22 @@ +decode( + $this->getTestImagePath() + ); + $this->assertInstanceOf(Image::class, $result); + } +} diff --git a/tests/Drivers/Gd/Decoders/HexColorDecoderTest.php b/tests/Drivers/Gd/Decoders/HexColorDecoderTest.php new file mode 100644 index 00000000..37732117 --- /dev/null +++ b/tests/Drivers/Gd/Decoders/HexColorDecoderTest.php @@ -0,0 +1,26 @@ +decode('ccc'); + $this->assertInstanceOf(Color::class, $result); + + $result = $decoder->decode('#ccc'); + $this->assertInstanceOf(Color::class, $result); + + $result = $decoder->decode('cccccc'); + $this->assertInstanceOf(Color::class, $result); + + $result = $decoder->decode('#cccccc'); + $this->assertInstanceOf(Color::class, $result); + } +} diff --git a/tests/Traits/CanCreateGdTestImage.php b/tests/Traits/CanCreateGdTestImage.php index f9f4238e..e2e5d81a 100644 --- a/tests/Traits/CanCreateGdTestImage.php +++ b/tests/Traits/CanCreateGdTestImage.php @@ -9,10 +9,20 @@ use Intervention\Image\Drivers\Gd\Image; trait CanCreateGdTestImage { + public function getTestImagePath($filename = 'test.jpg'): string + { + return sprintf('%s/../images/%s', __DIR__, $filename); + } + + public function getTestImageData($filename = 'test.jpg'): string + { + return file_get_contents($this->getTestImagePath($filename)); + } + public function createTestImage($filename = 'test.jpg'): Image { return $this->testImageDecoder()->handle( - sprintf('%s/../images/%s', __DIR__, $filename) + $this->getTestImagePath($filename) ); }