summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/driver/gd.php2
-rw-r--r--tests/driver_gd_test.php23
2 files changed, 25 insertions, 0 deletions
diff --git a/src/driver/gd.php b/src/driver/gd.php
index 1662a1d..be2da37 100644
--- a/src/driver/gd.php
+++ b/src/driver/gd.php
@@ -1182,6 +1182,8 @@ class ezcGraphGdDriver extends ezcGraphDriver
case IMG_JPEG:
imagejpeg( $image, $file, $this->options->jpegQuality );
break;
+ default:
+ throw new ezcGraphGdDriverUnsupportedImageTypeException( $this->options->imageFormat );
}
}
}
diff --git a/tests/driver_gd_test.php b/tests/driver_gd_test.php
index eb44084..c037bda 100644
--- a/tests/driver_gd_test.php
+++ b/tests/driver_gd_test.php
@@ -121,6 +121,29 @@ class ezcGraphGdDriverTest extends ezcTestImageCase
);
}
+ public function testRenderUnhandledFormat() {
+ $filename = $this->tempDir . __FUNCTION__ . '.jpeg';
+
+ $this->driver->options->imageFormat = IMG_GIF;
+ $this->driver->drawLine(
+ new ezcGraphCoordinate( 12, 45 ),
+ new ezcGraphCoordinate( 134, 12 ),
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ try
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.jpeg';
+ $this->driver->render( $filename );
+ }
+ catch ( ezcGraphGdDriverUnsupportedImageTypeException $e )
+ {
+ return;
+ }
+
+ $this->fail( 'Expected ezcGraphGdDriverUnsupportedImageTypeException.' );
+ }
+
public function testDrawLine()
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
OpenPOWER on IntegriCloud