From 63b5d5f3f2dee22c890d219aeb8e4cc7fd228f41 Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Tue, 8 Aug 2006 13:44:15 +0000 Subject: - Added svg rendering options - Made line ending style for svg configurable --- src/driver/svg.php | 23 +- src/options/svg_driver.php | 107 ++++++ .../ezcGraphSvgDriverTest_testDrawCircleFilled.svg | 2 + ...cGraphSvgDriverTest_testDrawCircleNonFilled.svg | 2 + ...raphSvgDriverTest_testDrawCircleSectorAcute.svg | 2 + ...iverTest_testDrawCircleSectorAcuteNonFilled.svg | 2 + ...DriverTest_testDrawCircleSectorAcuteReverse.svg | 2 + ...aphSvgDriverTest_testDrawCircleSectorObtuse.svg | 2 + ...GraphSvgDriverTest_testDrawCircularArcAcute.svg | 2 + ...gDriverTest_testDrawCircularArcAcuteReverse.svg | 2 + ...raphSvgDriverTest_testDrawCircularArcObtuse.svg | 2 + .../compare/ezcGraphSvgDriverTest_testDrawLine.svg | 2 + ...raphSvgDriverTest_testDrawPolygonFivePoints.svg | 2 + ...DriverTest_testDrawPolygonThreePointsFilled.svg | 2 + ...verTest_testDrawPolygonThreePointsNotFilled.svg | 2 + ...vgDriverTest_testDrawStringWithSpecialChars.svg | 2 + ...gDriverTest_testDrawTextBoxLongSpacedString.svg | 2 + ...rTest_testDrawTextBoxLongSpacedStringCenter.svg | 2 + ...testDrawTextBoxLongSpacedStringCenterBottom.svg | 2 + ...erTest_testDrawTextBoxLongSpacedStringRight.svg | 2 + ..._testDrawTextBoxLongSpacedStringRightMiddle.svg | 2 + ...raphSvgDriverTest_testDrawTextBoxLongString.svg | 2 + ...aphSvgDriverTest_testDrawTextBoxManualBreak.svg | 2 + ...aphSvgDriverTest_testDrawTextBoxShortString.svg | 2 + ...phSvgDriverTest_testDrawTextBoxStringCenter.svg | 2 + ...riverTest_testDrawTextBoxStringCenterMiddle.svg | 2 + ...aphSvgDriverTest_testDrawTextBoxStringRight.svg | 2 + ...DriverTest_testDrawTextBoxStringRightBottom.svg | 2 + ...DriverTest_testDrawTextBoxStringSampleRight.svg | 2 + tests/driver_svg_test.php | 375 +++++++-------------- 30 files changed, 290 insertions(+), 269 deletions(-) create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleFilled.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleNonFilled.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcute.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcuteNonFilled.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcuteReverse.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorObtuse.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcAcute.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcAcuteReverse.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcObtuse.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawLine.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonFivePoints.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsFilled.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsNotFilled.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawStringWithSpecialChars.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedString.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringCenter.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringRight.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongString.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxManualBreak.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxShortString.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringCenter.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringCenterMiddle.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringRight.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringRightBottom.svg create mode 100644 tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringSampleRight.svg diff --git a/src/driver/svg.php b/src/driver/svg.php index e567188..3f4ccef 100644 --- a/src/driver/svg.php +++ b/src/driver/svg.php @@ -72,6 +72,9 @@ class ezcGraphSvgDriver extends ezcGraphDriver $this->elements = $this->dom->createElement( 'g' ); $this->elements->setAttribute( 'id', 'chart' ); + $this->elements->setAttribute( 'color-rendering', $this->options->colorRendering ); + $this->elements->setAttribute( 'shape-rendering', $this->options->shapeRendering ); + $this->elements->setAttribute( 'text-rendering', $this->options->textRendering ); $this->elements = $svg->appendChild( $this->elements ); } } @@ -122,12 +125,13 @@ class ezcGraphSvgDriver extends ezcGraphDriver { $path->setAttribute( 'style', - sprintf( 'fill: none; stroke: #%02x%02x%02x; stroke-width: %d; stroke-opacity: %.2f;', + sprintf( 'fill: none; stroke: #%02x%02x%02x; stroke-width: %d; stroke-opacity: %.2f; stroke-linecap: %s;', $color->red, $color->green, $color->blue, $thickness, - 1 - ( $color->alpha / 255 ) + 1 - ( $color->alpha / 255 ), + $this->options->strokeLineCap ) ); } @@ -158,12 +162,13 @@ class ezcGraphSvgDriver extends ezcGraphDriver $path->setAttribute( 'd', $pointString ); $path->setAttribute( 'style', - sprintf( 'fill: none; stroke: #%02x%02x%02x; stroke-width: %d; stroke-opacity: %.2f;', + sprintf( 'fill: none; stroke: #%02x%02x%02x; stroke-width: %d; stroke-opacity: %.2f; stroke-linecap: %s;', $color->red, $color->green, $color->blue, $thickness, - 1 - ( $color->alpha / 255 ) + 1 - ( $color->alpha / 255 ), + $this->options->strokeLineCap ) ); @@ -401,12 +406,13 @@ class ezcGraphSvgDriver extends ezcGraphDriver { $arc->setAttribute( 'style', - sprintf( 'fill: none; stroke: #%02x%02x%02x; stroke-width: %d; stroke-opacity: %.2f;', + sprintf( 'fill: none; stroke: #%02x%02x%02x; stroke-width: %d; stroke-opacity: %.2f; stroke-linecap: %s;', $color->red, $color->green, $color->blue, 1, // Line Thickness - 1 - ( $color->alpha / 255 ) + 1 - ( $color->alpha / 255 ), + $this->options->strokeLineCap ) ); } @@ -521,12 +527,13 @@ class ezcGraphSvgDriver extends ezcGraphDriver { $ellipse->setAttribute( 'style', - sprintf( 'fill: none; stroke: #%02x%02x%02x; stroke-width: %d; stroke-opacity: %.2f;', + sprintf( 'fill: none; stroke: #%02x%02x%02x; stroke-width: %d; stroke-opacity: %.2f; stroke-linecap: %s;', $color->red, $color->green, $color->blue, 1, // Line Thickness - 1 - ( $color->alpha / 255 ) + 1 - ( $color->alpha / 255 ), + $this->options->strokeLineCap ) ); } diff --git a/src/options/svg_driver.php b/src/options/svg_driver.php index b07664e..6bd4ff8 100644 --- a/src/options/svg_driver.php +++ b/src/options/svg_driver.php @@ -23,6 +23,43 @@ class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions protected $assumedCharacterWidth = .55; /** + * This specifies the shape to be used at the end of open subpaths when + * they are stroked. + * + * @var string + */ + protected $strokeLineCap = 'round'; + + /** + * "The creator of SVG content might want to provide a hint to the + * implementation about what tradeoffs to make as it renders vector + * graphics elements such as 'path' elements and basic shapes such as + * circles and rectangles." + * + * @var string + */ + protected $shapeRendering = 'geometricPrecision'; + + /** + * "The creator of SVG content might want to provide a hint to the + * implementation about how to make speed vs. quality tradeoffs as it + * performs color interpolation and compositing. The 'color-rendering' + * property provides a hint to the SVG user agent about how to optimize + * its color interpolation and compositing operations." + * + * @var string + */ + protected $colorRendering = 'optimizeQuality'; + + /** + * "The creator of SVG content might want to provide a hint to the + * implementation about what tradeoffs to make as it renders text." + * + * @var string + */ + protected $textRendering = 'optimizeLegibility'; + + /** * Set an option value * * @param string $propertyName @@ -38,6 +75,76 @@ class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions case 'assumedCharacterWidth': $this->assumedCharacterWidth = min( 1, max( 0, (float) $propertyValue ) ); break; + case 'strokeLineCap': + $values = array( + 'round', + 'butt', + 'square', + 'inherit', + ); + + if ( in_array( $propertyValue, $values, true ) ) + { + $this->strokeLineCap = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); + } + break; + case 'shapeRendering': + $values = array( + 'auto', + 'optimizeSpeed', + 'crispEdges', + 'geometricPrecision', + 'inherit', + ); + + if ( in_array( $propertyValue, $values, true ) ) + { + $this->shapeRendering = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); + } + break; + case 'colorRendering': + $values = array( + 'auto', + 'optimizeSpeed', + 'optimizeQuality', + 'inherit', + ); + + if ( in_array( $propertyValue, $values, true ) ) + { + $this->colorRendering = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); + } + break; + case 'textRendering': + $values = array( + 'auto', + 'optimizeSpeed', + 'optimizeLegibility', + 'geometricPrecision', + 'inherit', + ); + + if ( in_array( $propertyValue, $values, true ) ) + { + $this->textRendering = $propertyValue; + } + else + { + throw new ezcBaseValueException( $propertyName, $propertyValue, implode( $values, ', ' ) ); + } + break; default: parent::__set( $propertyName, $propertyValue ); break; diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleFilled.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleFilled.svg new file mode 100644 index 0000000..0b281aa --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleFilled.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleNonFilled.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleNonFilled.svg new file mode 100644 index 0000000..1975640 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleNonFilled.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcute.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcute.svg new file mode 100644 index 0000000..4fc15bb --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcute.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcuteNonFilled.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcuteNonFilled.svg new file mode 100644 index 0000000..7922681 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcuteNonFilled.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcuteReverse.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcuteReverse.svg new file mode 100644 index 0000000..4fc15bb --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorAcuteReverse.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorObtuse.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorObtuse.svg new file mode 100644 index 0000000..cdea425 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircleSectorObtuse.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcAcute.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcAcute.svg new file mode 100644 index 0000000..5b643ad --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcAcute.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcAcuteReverse.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcAcuteReverse.svg new file mode 100644 index 0000000..5b643ad --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcAcuteReverse.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcObtuse.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcObtuse.svg new file mode 100644 index 0000000..d56dc89 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawCircularArcObtuse.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawLine.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawLine.svg new file mode 100644 index 0000000..280bb01 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawLine.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonFivePoints.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonFivePoints.svg new file mode 100644 index 0000000..67075aa --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonFivePoints.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsFilled.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsFilled.svg new file mode 100644 index 0000000..32080fa --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsFilled.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsNotFilled.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsNotFilled.svg new file mode 100644 index 0000000..de5f160 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawPolygonThreePointsNotFilled.svg @@ -0,0 +1,2 @@ + + diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawStringWithSpecialChars.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawStringWithSpecialChars.svg new file mode 100644 index 0000000..168e3d0 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawStringWithSpecialChars.svg @@ -0,0 +1,2 @@ + +Safari (13.8%) diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedString.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedString.svg new file mode 100644 index 0000000..5fdb2ba --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedString.svg @@ -0,0 +1,2 @@ + +This Is A PrettyLong String diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringCenter.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringCenter.svg new file mode 100644 index 0000000..2d0b357 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringCenter.svg @@ -0,0 +1,2 @@ + +This Is A PrettyLong String diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.svg new file mode 100644 index 0000000..3061ec0 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.svg @@ -0,0 +1,2 @@ + +This Is A PrettyLong String diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringRight.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringRight.svg new file mode 100644 index 0000000..87b508e --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringRight.svg @@ -0,0 +1,2 @@ + +This Is A PrettyLong String diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.svg new file mode 100644 index 0000000..66314af --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.svg @@ -0,0 +1,2 @@ + +This Is A PrettyLong String diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongString.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongString.svg new file mode 100644 index 0000000..6b8c5ec --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxLongString.svg @@ -0,0 +1,2 @@ + +ThisIsAPrettyLongString diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxManualBreak.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxManualBreak.svg new file mode 100644 index 0000000..5693413 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxManualBreak.svg @@ -0,0 +1,2 @@ + +New Line diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxShortString.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxShortString.svg new file mode 100644 index 0000000..ce282db --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxShortString.svg @@ -0,0 +1,2 @@ + +Short diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringCenter.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringCenter.svg new file mode 100644 index 0000000..82d078f --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringCenter.svg @@ -0,0 +1,2 @@ + +ThisIsAPrettyLongString diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringCenterMiddle.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringCenterMiddle.svg new file mode 100644 index 0000000..91a3664 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringCenterMiddle.svg @@ -0,0 +1,2 @@ + +ThisIsAPrettyLongString diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringRight.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringRight.svg new file mode 100644 index 0000000..da86a65 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringRight.svg @@ -0,0 +1,2 @@ + +ThisIsAPrettyLongString diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringRightBottom.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringRightBottom.svg new file mode 100644 index 0000000..06f0f8d --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringRightBottom.svg @@ -0,0 +1,2 @@ + +ThisIsAPrettyLongString diff --git a/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringSampleRight.svg b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringSampleRight.svg new file mode 100644 index 0000000..77eba16 --- /dev/null +++ b/tests/data/compare/ezcGraphSvgDriverTest_testDrawTextBoxStringSampleRight.svg @@ -0,0 +1,2 @@ + +sample 4 diff --git a/tests/driver_svg_test.php b/tests/driver_svg_test.php index d0594da..36a87db 100644 --- a/tests/driver_svg_test.php +++ b/tests/driver_svg_test.php @@ -62,6 +62,33 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->removeTempDir(); } + /** + * Compares a generated image with a stored file + * + * @param string $generated Filename of generated image + * @param string $compare Filename of stored image + * @return void + */ + protected function compare( $generated, $compare ) + { + $this->assertTrue( + file_exists( $generated ), + 'No image file has been created.' + ); + + $this->assertTrue( + file_exists( $compare ), + 'Comparision image does not exist.' + ); + + if ( md5_file( $generated ) !== md5_file( $compare ) ) + { + // Adding a diff makes no sense here, because created XML uses + // only two lines + $this->fail( 'Rendered image is not correct.'); + } + } + public function testDrawLine() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; @@ -74,15 +101,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '53b4c2d537fe72e0f02d3c79649071a9', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -102,15 +123,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '0560d69e0a473521009ebb353a8d619a', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -130,15 +145,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '805da20cc5bfa362014f48f6a9e7dadc', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -160,15 +169,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '68fe9d21539e371fdac779cdc8b6bf7f', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -187,15 +190,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'bb333f8f9aa563cbd79f238ed444dd49', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -215,15 +212,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '9bcbb9f0076861e15a9f426923f9e64e', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -242,15 +233,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'bb333f8f9aa563cbd79f238ed444dd49', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -269,15 +254,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '5425f0e9c0a1b101749eede1e8426e96', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -297,15 +276,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '7cc7bca87ad13efe8310826199854240', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -325,15 +298,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '7cc7bca87ad13efe8310826199854240', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -353,15 +320,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '5bd2450976479e57f1cf74f7e6345a5b', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -378,15 +339,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'c748cd3c8720b98cbf8724296a7bd9c4', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -404,15 +359,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'bad8083fa82cb61db55f401fbc876037', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -429,15 +378,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'broken', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -454,15 +397,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'broken', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -490,15 +427,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '21ad413d4b34220ce2dadf25fdfe93aa', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -526,15 +457,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '58da91a8541e65abcd0ea3d170f53cef', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -562,15 +487,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'ec91b1b2a65ccd8619f441c45b680ded', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -598,15 +517,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'c4131ce32ed143c3b13749b13555151f', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -634,15 +547,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '172d4886684c5868ae3c2be95f187c1e', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -670,15 +577,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'a514061b35ba6ea8bbae39d59ecb263d', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -706,15 +607,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '5672013761efc0a1e28a17a96b0f05fb', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -742,15 +637,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'be283e77d2527507374daec5668f0c93', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -778,15 +667,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'dde4bc623ba3ccfa6d5da72432381e90', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -814,15 +697,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '9c95e975d06a7dab5131d5ac4f859d52', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -850,15 +727,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - 'b1dfba96a96380b91056cf22b539d521', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -886,15 +757,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '856506208598ed3ec05e4009fda19fdc', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -922,15 +787,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '72001c5cec1fc3432bc71577a49b2d1f', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } @@ -958,15 +817,9 @@ class ezcGraphSvgDriverTest extends ezcTestCase $this->driver->render( $filename ); - $this->assertTrue( - file_exists( $filename ), - 'No image was generated.' - ); - - $this->assertEquals( - '1bd0c084899d5025da3f66224c4cdef9', - md5_file( $filename ), - 'Incorrect image rendered.' + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' ); } } -- cgit v1.1