diff options
30 files changed, 290 insertions, 269 deletions
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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><ellipse cx="100" cy="50" rx="40" ry="20" style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><ellipse cx="100" cy="50" rx="40" ry="20" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d="M 100.00,50.00 L 139.05,54.33 A 40.00,20.000000 0 0,1 136.25,58.45 z" style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d="M 100.00,50.00 L 139.05,54.33 A 40.00,20.000000 0 0,1 128.28,64.14 z" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d="M 100.00,50.00 L 139.05,54.33 A 40.00,20.000000 0 0,1 136.25,58.45 z" style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d="M 100.00,50.00 L 136.25,58.45 A 40.00,20.000000 0 1,1 102.09,30.03 z" style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 143.02,92.77 A 75.00,40.000000 0 0,0 173.22,68.66 L 173.22,58.66 A 75.00,40.000000 0 0,1 143.02,82.77 z" style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 143.02,92.77 A 75.00,40.000000 0 0,0 173.22,68.66 L 173.22,58.66 A 75.00,40.000000 0 0,1 143.02,82.77 z" style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 137.50,25.36 A 75.00,40.000000 0 1,0 167.97,76.90 L 167.97,66.90 A 75.00,40.000000 0 1,1 137.50,15.36 z" style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 12.0000,45.0000 L 134.0000,12.0000" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 60.0000,32.0000 L 45.0000,12.0000 L 122.0000,34.0000 L 12.0000,71.0000 L 3.0000,45.0000 L 60.0000,32.0000 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 12.0000,71.0000 L 45.0000,12.0000 L 122.0000,34.0000 L 12.0000,71.0000 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 12.0000,71.0000 L 45.0000,12.0000 L 122.0000,34.0000 L 12.0000,71.0000 z " style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round;"/></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 99.0000,54.0000 L 47.0000,54.0000 L 47.0000,84.0000 L 99.0000,84.0000 L 99.0000,54.0000 z " style="fill: #dddddd; fill-opacity: 1.00; stroke: none;"/><text x="47" text-length="46.2px" y="60" style="font-size: 6px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Safari (13.8%)</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="10" text-length="149.6px" y="27" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">This Is A Pretty</text><text x="10" text-length="102.85px" y="45.7" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Long String</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="10.2" text-length="149.6px" y="27" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">This Is A Pretty</text><text x="33.575" text-length="102.85px" y="45.7" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Long String</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="10.2" text-length="149.6px" y="62.9" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">This Is A Pretty</text><text x="33.575" text-length="102.85px" y="81.6" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Long String</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="10.4" text-length="149.6px" y="27" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">This Is A Pretty</text><text x="57.15" text-length="102.85px" y="45.7" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Long String</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="10.4" text-length="149.6px" y="44.95" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">This Is A Pretty</text><text x="57.15" text-length="102.85px" y="63.65" style="font-size: 17px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Long String</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="10" text-length="139.15px" y="21" style="font-size: 11px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">ThisIsAPrettyLongString</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="10" text-length="149.6px" y="44" style="font-size: 34px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">New Line</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="10" text-length="148.5px" y="64" style="font-size: 54px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">Short</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="15.425" text-length="139.15px" y="21" style="font-size: 11px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">ThisIsAPrettyLongString</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="15.425" text-length="139.15px" y="50.5" style="font-size: 11px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">ThisIsAPrettyLongString</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="20.85" text-length="139.15px" y="21" style="font-size: 11px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">ThisIsAPrettyLongString</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 10.0000,80.0000 L 10.0000,10.0000 L 160.0000,10.0000 L 160.0000,80.0000 L 10.0000,80.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="20.85" text-length="139.15px" y="80" style="font-size: 11px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">ThisIsAPrettyLongString</text></g></svg> 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 @@ +<?xml version="1.0"?> +<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.0" id="ezcGraph"><defs/><g id="chart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 20.0000,30.0000 L 20.0000,20.0000 L 110.0000,20.0000 L 110.0000,30.0000 L 20.0000,30.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><text x="73.8" text-length="35.2px" y="29" style="font-size: 8px; font-family: sans-serif; fill: #000000; fill-opacity: 1.00; stroke: none;">sample 4</text></g></svg> 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' ); } } |