Author: Kore Nordmann
Date: 2006-06-12 10:12:00 +0200 (Mon, 12 Jun 2006)
New Revision: 3113
Log:
- Added missing exception to autoload file
- Added test for UnsupportedImageType exception
Added:
trunk/Graph/src/exceptions/unsupported_image_type.php
Modified:
trunk/Graph/src/driver/gd.php
trunk/Graph/src/graph_autoload.php
trunk/Graph/tests/driver_gd_test.php
Modified: trunk/Graph/src/driver/gd.php
===================================================================
--- trunk/Graph/src/driver/gd.php 2006-06-12 07:52:44 UTC (rev 3112)
+++ trunk/Graph/src/driver/gd.php 2006-06-12 08:12:00 UTC (rev 3113)
@@ -108,7 +108,7 @@
'image' => imagecreatefrompng( $file )
);
default:
- throw new ezcGraphGdDriverUnsupportedImageFormatException(
$data[2] );
+ throw new ezcGraphGdDriverUnsupportedImageTypeException(
$data[2] );
}
}
Added: trunk/Graph/src/exceptions/unsupported_image_type.php
===================================================================
--- trunk/Graph/src/exceptions/unsupported_image_type.php 2006-06-12
07:52:44 UTC (rev 3112)
+++ trunk/Graph/src/exceptions/unsupported_image_type.php 2006-06-12
08:12:00 UTC (rev 3113)
@@ -0,0 +1,54 @@
+<?php
+/**
+ * File containing the ezcGraphGdDriverUnsupportedImageTypeException class
+ *
+ * @package Graph
+ * @version //autogen//
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * ezcGraphUnknownChartTypeException is the exception which is thrown when the
+ * factory method tries to return an instance of an unknown chart type
+ *
+ * @package Graph
+ * @version //autogen//
+ */
+class ezcGraphGdDriverUnsupportedImageTypeException extends ezcBaseException
+{
+ public function __construct( $type )
+ {
+ $typeName = array(
+ 1 => 'GIF',
+ 2 => 'Jpeg',
+ 3 => 'PNG',
+ 4 => 'SWF',
+ 5 => 'PSD',
+ 6 => 'BMP',
+ 7 => 'TIFF (intel)',
+ 8 => 'TIFF (motorola)',
+ 9 => 'JPC',
+ 10 => 'JP2',
+ 11 => 'JPX',
+ 12 => 'JB2',
+ 13 => 'SWC',
+ 14 => 'IFF',
+ 15 => 'WBMP',
+ 16 => 'XBM',
+
+ );
+
+ if ( isset( $typeName[$type] ) )
+ {
+ $type = $typeName[$type];
+ }
+ else
+ {
+ $type = 'Unknown';
+ }
+
+ parent::__construct( "Unsupported image format <{$type}>." );
+ }
+}
+
+?>
Property changes on: trunk/Graph/src/exceptions/unsupported_image_type.php
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/Graph/src/graph_autoload.php
===================================================================
--- trunk/Graph/src/graph_autoload.php 2006-06-12 07:52:44 UTC (rev 3112)
+++ trunk/Graph/src/graph_autoload.php 2006-06-12 08:12:00 UTC (rev 3113)
@@ -32,6 +32,7 @@
'ezcGraphGdDriver' => 'Graph/driver/gd.php',
'ezcGraphGdDriverOptions' =>
'Graph/options/gd_driver.php',
'ezcGraphGdDriverInvalidFontException' =>
'Graph/exceptions/invalid_font.php',
+ 'ezcGraphGdDriverUnsupportedImageTypeException' =>
'Graph/exceptions/unsupported_image_type.php',
'ezcGraphSVGDriver' => 'Graph/driver/svg.php',
'ezcGraphSvgDriverOptions' =>
'Graph/options/svg_driver.php',
'ezcGraphInvalidDriverException' =>
'Graph/exceptions/invalid_driver.php',
Modified: trunk/Graph/tests/driver_gd_test.php
===================================================================
--- trunk/Graph/tests/driver_gd_test.php 2006-06-12 07:52:44 UTC (rev
3112)
+++ trunk/Graph/tests/driver_gd_test.php 2006-06-12 08:12:00 UTC (rev
3113)
@@ -27,6 +27,7 @@
protected $testFiles = array(
'jpeg' => 'jpeg.jpg',
'png' => 'png.png',
+ 'text' => 'text.txt',
);
public static function suite()
@@ -414,6 +415,26 @@
);
}
+ public function testDrawImageInvalideFileType()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ try {
+ $this->driver->drawImage(
+ $this->basePath . $this->testFiles['text'],
+ new ezcGraphCoordinate( 10, 10 ),
+ 100,
+ 50
+ );
+ }
+ catch ( ezcGraphGdDriverUnsupportedImageTypeException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphGdDriverUnsupportedImageTypeException.'
);
+ }
+
public function testDrawImagePng()
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components