summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-06-28 13:23:00 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-06-28 13:23:00 +0000
commit6ed7f3a9b1814879c8fed5f55db1ae409797f76c (patch)
treef69295bc766e04744f43a8811574c69836049dc0 /tests
parentd6bae028524a0fc548080d7b8ae1d8fa38102248 (diff)
downloadzetacomponents-graph-6ed7f3a9b1814879c8fed5f55db1ae409797f76c.zip
zetacomponents-graph-6ed7f3a9b1814879c8fed5f55db1ae409797f76c.tar.gz
- Added SVG driver
Diffstat (limited to 'tests')
-rw-r--r--tests/driver_svg_test.php974
-rw-r--r--tests/suite.php2
2 files changed, 976 insertions, 0 deletions
diff --git a/tests/driver_svg_test.php b/tests/driver_svg_test.php
new file mode 100644
index 0000000..00c1ed4
--- /dev/null
+++ b/tests/driver_svg_test.php
@@ -0,0 +1,974 @@
+<?php
+/**
+ * ezcGraphSvgDriverTest
+ *
+ * @package Graph
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Tests for ezcGraph class.
+ *
+ * @package ImageAnalysis
+ * @subpackage Tests
+ */
+class ezcGraphSvgDriverTest extends ezcTestCase
+{
+
+ protected $driver;
+
+ protected $tempDir;
+
+ protected $basePath;
+
+ protected $testFiles = array(
+ 'jpeg' => 'jpeg.jpg',
+ 'png' => 'png.png',
+ );
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcGraphSvgDriverTest" );
+ }
+
+ /**
+ * setUp
+ *
+ * @access public
+ */
+ public function setUp()
+ {
+ static $i = 0;
+ $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
+ $this->basePath = dirname( __FILE__ ) . '/data/';
+
+ $this->driver = new ezcGraphSvgDriver();
+ $this->driver->options->width = 200;
+ $this->driver->options->height = 100;
+ $this->driver->options->font->font = $this->basePath . 'font.ttf';
+ }
+
+ /**
+ * tearDown
+ *
+ * @access public
+ */
+ public function tearDown()
+ {
+ unset( $this->driver );
+ $this->removeTempDir();
+ }
+
+ public function testDrawLine()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawLine(
+ new ezcGraphCoordinate( 12, 45 ),
+ new ezcGraphCoordinate( 134, 12 ),
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '9688d589680400999be566227dbe9c29',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawPolygonThreePointsFilled()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 45, 12 ),
+ new ezcGraphCoordinate( 122, 34 ),
+ new ezcGraphCoordinate( 12, 71 ),
+ ),
+ ezcGraphColor::fromHex( '#3465A4' ),
+ true
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '6a41f0c473bbe30915e695bd91b7d6a6',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawPolygonThreePointsNotFilled()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 45, 12 ),
+ new ezcGraphCoordinate( 122, 34 ),
+ new ezcGraphCoordinate( 12, 71 ),
+ ),
+ ezcGraphColor::fromHex( '#3465A4' ),
+ false
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '57e1fd8237f9759f56ee5e7ee31a43da',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawPolygonFivePoints()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 45, 12 ),
+ new ezcGraphCoordinate( 122, 34 ),
+ new ezcGraphCoordinate( 12, 71 ),
+ new ezcGraphCoordinate( 3, 45 ),
+ new ezcGraphCoordinate( 60, 32 ),
+ ),
+ ezcGraphColor::fromHex( '#3465A4' ),
+ true
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'c69c00899b27d6805e4a4e632ec5bdd1',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircleSectorAcute()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ 12.5,
+ 25,
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '89480548f0f4ad16fa2b62ed8a1b405d',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircleSectorAcuteNonFilled()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ 12.5,
+ 45,
+ ezcGraphColor::fromHex( '#3465A4' ),
+ false
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'f00974c80a296ea96667e97d8a593d20',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircleSectorAcuteReverse()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ 25,
+ 12.5,
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '89480548f0f4ad16fa2b62ed8a1b405d',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircleSectorObtuse()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircleSector(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ 25,
+ 273,
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'c96a934640494f4e5003eb2782bd387d',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircularArcAcute()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircularArc(
+ new ezcGraphCoordinate( 100, 50 ),
+ 150,
+ 80,
+ 10,
+ 12.5,
+ 55,
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'aecde1739b7672b092038132d11a14d7',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircularArcAcuteReverse()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircularArc(
+ new ezcGraphCoordinate( 100, 50 ),
+ 150,
+ 80,
+ 10,
+ 55,
+ 12.5,
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'aecde1739b7672b092038132d11a14d7',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircularArcObtuse()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircularArc(
+ new ezcGraphCoordinate( 100, 50 ),
+ 150,
+ 80,
+ 10,
+ 25,
+ 300,
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '9ff612c20a94890d1a29c9dae7a13fed',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircleFilled()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircle(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ ezcGraphColor::fromHex( '#3465A4' )
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'b0601d6c18f937f64b1dc2da6f402459',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawCircleNonFilled()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawCircle(
+ new ezcGraphCoordinate( 100, 50 ),
+ 80,
+ 40,
+ ezcGraphColor::fromHex( '#3465A4' ),
+ false
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '501214a894f024d6efea307f51dda85b',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawImageJpeg()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawImage(
+ $this->basePath . $this->testFiles['jpeg'],
+ new ezcGraphCoordinate( 10, 10 ),
+ 100,
+ 50
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '827ab338a7919bbc5e0e45ddeb517854',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawImagePng()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawImage(
+ $this->basePath . $this->testFiles['png'],
+ new ezcGraphCoordinate( 10, 10 ),
+ 100,
+ 50
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'c22c66d4137b36e8bc80a6ed80361d70',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxShortString()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'Short',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'c9deeb042648025df8a07aeafc14597f',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxLongString()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'ThisIsAPrettyLongString',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '32bf93e9173859c287fac43367af03e0',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxLongSpacedString()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'This Is A Pretty Long String',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '808caa0b01a73fd7a4fe7fb139543f48',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxManualBreak()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ "New\nLine",
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '99d9d57e9c8ed9f993201be063f3a103',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxStringSampleRight()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 20, 20 ),
+ new ezcGraphCoordinate( 110, 20 ),
+ new ezcGraphCoordinate( 110, 30 ),
+ new ezcGraphCoordinate( 20, 30 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'sample 4',
+ new ezcGraphCoordinate( 21, 21 ),
+ 88,
+ 8,
+ ezcGraph::RIGHT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'f20714a112bf26d9f2bcc237024a3fc0',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxStringRight()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'ThisIsAPrettyLongString',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::RIGHT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '566f6da9a6caa44d66b9e8a9ddd440c0',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxLongSpacedStringRight()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'This Is A Pretty Long String',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::RIGHT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'df370e94a8954fa4df90c883acbc40a5',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxStringCenter()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'ThisIsAPrettyLongString',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::CENTER
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'f366d4f787105c526254055a50e3efe8',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxLongSpacedStringCenter()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'This Is A Pretty Long String',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::CENTER
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '3d6129e9c6ef35c1308e289297720a44',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxStringRightBottom()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'ThisIsAPrettyLongString',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::RIGHT | ezcGraph::BOTTOM
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '232aa98c989cb534d25b44b725c977b8',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxLongSpacedStringRightMiddle()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'This Is A Pretty Long String',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::RIGHT | ezcGraph::MIDDLE
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '4b470dcfcc9f386ae47a856cd0c3249b',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxStringCenterMiddle()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'ThisIsAPrettyLongString',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::CENTER | ezcGraph::MIDDLE
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'a70d08ade2d9e723edd042e5f6e19f9c',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawTextBoxLongSpacedStringCenterBottom()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 10, 10 ),
+ new ezcGraphCoordinate( 160, 10 ),
+ new ezcGraphCoordinate( 160, 80 ),
+ new ezcGraphCoordinate( 10, 80 ),
+ ),
+ ezcGraphColor::fromHex( '#eeeeec' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'This Is A Pretty Long String',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::CENTER | ezcGraph::BOTTOM
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ '9a8d85f51a8bf29ff22ab80f42f6dc80',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+
+ public function testDrawStringWithSpecialChars()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 47, 54 ),
+ new ezcGraphCoordinate( 47, 84 ),
+ new ezcGraphCoordinate( 99, 84 ),
+ new ezcGraphCoordinate( 99, 54 ),
+ ),
+ ezcGraphColor::fromHex( '#DDDDDD' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'Safari (13.8%)',
+ new ezcGraphCoordinate( 47, 54 ),
+ 52,
+ 30,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertEquals(
+ 'b99c805e3bef27128614220ebde1dc87',
+ md5_file( $filename ),
+ 'Incorrect image rendered.'
+ );
+ }
+}
+
+?>
diff --git a/tests/suite.php b/tests/suite.php
index 0cd4e11..3c924de 100644
--- a/tests/suite.php
+++ b/tests/suite.php
@@ -28,6 +28,7 @@ require_once 'numeric_axis_test.php';
require_once 'labeled_axis_test.php';
require_once 'renderer_2d_test.php';
require_once 'driver_gd_test.php';
+require_once 'driver_svg_test.php';
require_once 'font_test.php';
require_once 'palette_test.php';
require_once 'background_image_test.php';
@@ -56,6 +57,7 @@ class ezcGraphSuite extends ezcTestSuite
$this->addTest( ezcGraphLabeledAxisTest::suite() );
$this->addTest( ezcGraphRenderer2dTest::suite() );
$this->addTest( ezcGraphGdDriverTest::suite() );
+ $this->addTest( ezcGraphSvgDriverTest::suite() );
$this->addTest( ezcGraphFontTest::suite() );
$this->addTest( ezcGraphTextTest::suite() );
$this->addTest( ezcGraphPaletteTest::suite() );
OpenPOWER on IntegriCloud