summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-01-24 09:25:56 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-01-24 09:25:56 +0000
commit16bdb8776708f401d085c29222a88a2ae7667ced (patch)
tree9e76b1b75c8b85340e5a029887ec18d82ffb1472 /tests
parent27eaaca1fb0e26115374260bcbc86615f8c4be3c (diff)
downloadzetacomponents-graph-16bdb8776708f401d085c29222a88a2ae7667ced.zip
zetacomponents-graph-16bdb8776708f401d085c29222a88a2ae7667ced.tar.gz
- Move existing background tests to own test case
Diffstat (limited to 'tests')
-rw-r--r--tests/background_test.php217
-rw-r--r--tests/chart_test.php60
-rw-r--r--tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithBackgroundBottomCenter.svg (renamed from tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithBackgroundBottomCenter.svg)0
-rw-r--r--tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithBackgroundBottomRight.svg (renamed from tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChartWithBackgroundBottomRight.svg)0
-rw-r--r--tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithHorizontalTextureBackground.svg (renamed from tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithHorizontalTextureBackground.svg)0
-rw-r--r--tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithTextureBackground.svg (renamed from tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChartWithTextureBackground.svg)0
-rw-r--r--tests/renderer_2d_test.php52
-rw-r--r--tests/renderer_3d_test.php55
-rw-r--r--tests/suite.php2
9 files changed, 219 insertions, 167 deletions
diff --git a/tests/background_test.php b/tests/background_test.php
new file mode 100644
index 0000000..f16b5bb
--- /dev/null
+++ b/tests/background_test.php
@@ -0,0 +1,217 @@
+<?php
+/**
+ * ezcGraphBackgroundTest
+ *
+ * @package Graph
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+require_once dirname( __FILE__ ) . '/test_case.php';
+
+/**
+ * Tests for ezcGraph class.
+ *
+ * @package ImageAnalysis
+ * @subpackage Tests
+ */
+class ezcGraphBackgroundTest extends ezcGraphTestCase
+{
+ protected $testFiles = array(
+ 'jpeg' => 'jpeg.jpg',
+ 'nonexistant' => 'nonexisting.jpg',
+ 'invalid' => 'text.txt',
+ );
+
+ public static function suite()
+ {
+ return new PHPUnit_Framework_TestSuite( "ezcGraphBackgroundTest" );
+ }
+
+ protected function setUp()
+ {
+ static $i = 0;
+
+ $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
+ $this->basePath = dirname( __FILE__ ) . '/data/';
+ }
+
+ protected function tearDown()
+ {
+ if ( !$this->hasFailed() )
+ {
+ $this->removeTempDir();
+ }
+ }
+
+ public function testSetOptionsInvalidBackgroundImage()
+ {
+ try
+ {
+ $pieChart = new ezcGraphPieChart();
+ $pieChart->background->image = $this->basePath . $this->testFiles['invalid'];
+ }
+ catch ( ezcGraphInvalidImageFileException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphInvalidImageFileException' );
+ }
+
+ public function testSetOptionsNonexistantBackgroundImage()
+ {
+ try
+ {
+ $pieChart = new ezcGraphPieChart();
+ $pieChart->background->image = $this->basePath . $this->testFiles['nonexistant'];
+ }
+ catch ( ezcBaseFileNotFoundException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseFileNotFoundException' );
+ }
+
+ public function testSetOptionsBackground()
+ {
+ $pieChart = new ezcGraphPieChart();
+ $pieChart->background->color = '#FF0000';
+
+ $this->assertEquals(
+ ezcGraphColor::fromHex( 'FF0000' ),
+ $pieChart->background->color
+ );
+ }
+
+ public function testSetOptionsBorder()
+ {
+ $pieChart = new ezcGraphPieChart();
+ $pieChart->background->border = '#FF0000';
+
+ $this->assertEquals(
+ ezcGraphColor::fromHex( 'FF0000' ),
+ $pieChart->background->border
+ );
+ }
+
+ public function testSetOptionsBorderWidth()
+ {
+ $pieChart = new ezcGraphPieChart();
+ $pieChart->background->borderWidth = 3;
+
+ $this->assertSame( 3, $pieChart->background->borderWidth );
+ }
+
+ public function testRenderPieChartWithBackgroundBottomRight()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphPieChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->background->color = '#FFFFFFDD';
+ $chart->background->image = dirname( __FILE__ ) . '/data/ez.png';
+ $chart->background->position = ezcGraph::BOTTOM | ezcGraph::RIGHT;
+
+ $chart->driver = new ezcGraphSvgDriver();
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testRenderPieChartWithTextureBackground()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphPieChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->background->color = '#FFFFFFDD';
+ $chart->background->image = dirname( __FILE__ ) . '/data/texture.png';
+ $chart->background->repeat = ezcGraph::HORIZONTAL | ezcGraph::VERTICAL;
+
+ $chart->driver = new ezcGraphSvgDriver();
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testRenderPieChartWithBackgroundBottomCenter()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphPieChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->background->color = '#FFFFFFDD';
+ $chart->background->image = dirname( __FILE__ ) . '/data/ez.png';
+ $chart->background->position = ezcGraph::BOTTOM | ezcGraph::CENTER;
+
+ $chart->driver = new ezcGraphSvgDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testRenderPieChartWithHorizontalTextureBackground()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphPieChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ ) );
+
+ $chart->background->color = '#FFFFFFDD';
+ $chart->background->image = dirname( __FILE__ ) . '/data/texture.png';
+ $chart->background->repeat = ezcGraph::HORIZONTAL;
+ $chart->background->position = ezcGraph::BOTTOM;
+
+ $chart->driver = new ezcGraphSvgDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+}
+?>
diff --git a/tests/chart_test.php b/tests/chart_test.php
index 829663b..02b6cac 100644
--- a/tests/chart_test.php
+++ b/tests/chart_test.php
@@ -50,66 +50,6 @@ class ezcGraphChartTest extends ezcTestCase
);
}
- public function testSetOptionsInvalidBackgroundImage()
- {
- try
- {
- $pieChart = new ezcGraphPieChart();
- $pieChart->background->image = $this->basePath . $this->testFiles['invalid'];
- }
- catch ( ezcGraphInvalidImageFileException $e )
- {
- return true;
- }
-
- $this->fail( 'Expected ezcGraphInvalidImageFileException' );
- }
-
- public function testSetOptionsNonexistantBackgroundImage()
- {
- try
- {
- $pieChart = new ezcGraphPieChart();
- $pieChart->background->image = $this->basePath . $this->testFiles['nonexistant'];
- }
- catch ( ezcBaseFileNotFoundException $e )
- {
- return true;
- }
-
- $this->fail( 'Expected ezcBaseFileNotFoundException' );
- }
-
- public function testSetOptionsBackground()
- {
- $pieChart = new ezcGraphPieChart();
- $pieChart->background->color = '#FF0000';
-
- $this->assertEquals(
- ezcGraphColor::fromHex( 'FF0000' ),
- $pieChart->background->color
- );
- }
-
- public function testSetOptionsBorder()
- {
- $pieChart = new ezcGraphPieChart();
- $pieChart->background->border = '#FF0000';
-
- $this->assertEquals(
- ezcGraphColor::fromHex( 'FF0000' ),
- $pieChart->background->border
- );
- }
-
- public function testSetOptionsBorderWidth()
- {
- $pieChart = new ezcGraphPieChart();
- $pieChart->background->borderWidth = 3;
-
- $this->assertSame( 3, $pieChart->background->borderWidth );
- }
-
public function testSetOptionsUnknown()
{
try
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithBackgroundBottomCenter.svg b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithBackgroundBottomCenter.svg
index cfdb537..cfdb537 100644
--- a/tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithBackgroundBottomCenter.svg
+++ b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithBackgroundBottomCenter.svg
diff --git a/tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChartWithBackgroundBottomRight.svg b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithBackgroundBottomRight.svg
index ed882f8..ed882f8 100644
--- a/tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChartWithBackgroundBottomRight.svg
+++ b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithBackgroundBottomRight.svg
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithHorizontalTextureBackground.svg b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithHorizontalTextureBackground.svg
index 5bc5008..5bc5008 100644
--- a/tests/data/compare/ezcGraphRenderer3dTest_testRenderPieChartWithHorizontalTextureBackground.svg
+++ b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithHorizontalTextureBackground.svg
diff --git a/tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChartWithTextureBackground.svg b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithTextureBackground.svg
index 3065c57..3065c57 100644
--- a/tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChartWithTextureBackground.svg
+++ b/tests/data/compare/ezcGraphBackgroundTest_testRenderPieChartWithTextureBackground.svg
diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php
index 9113502..f48de8c 100644
--- a/tests/renderer_2d_test.php
+++ b/tests/renderer_2d_test.php
@@ -1729,58 +1729,6 @@ class ezcGraphRenderer2dTest extends ezcGraphTestCase
);
}
- public function testRenderPieChartWithBackgroundBottomRight()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.svg';
-
- $chart = new ezcGraphPieChart();
- $chart->data['sample'] = new ezcGraphArrayDataSet( array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- ) );
-
- $chart->background->color = '#FFFFFFDD';
- $chart->background->image = dirname( __FILE__ ) . '/data/ez.png';
- $chart->background->position = ezcGraph::BOTTOM | ezcGraph::RIGHT;
-
- $chart->driver = new ezcGraphSvgDriver();
- $chart->render( 500, 200, $filename );
-
- $this->compare(
- $filename,
- $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
- );
- }
-
- public function testRenderPieChartWithTextureBackground()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.svg';
-
- $chart = new ezcGraphPieChart();
- $chart->data['sample'] = new ezcGraphArrayDataSet( array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- ) );
-
- $chart->background->color = '#FFFFFFDD';
- $chart->background->image = dirname( __FILE__ ) . '/data/texture.png';
- $chart->background->repeat = ezcGraph::HORIZONTAL | ezcGraph::VERTICAL;
-
- $chart->driver = new ezcGraphSvgDriver();
- $chart->render( 500, 200, $filename );
-
- $this->compare(
- $filename,
- $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
- );
- }
-
public function testRenderPieChartWithOffset()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
diff --git a/tests/renderer_3d_test.php b/tests/renderer_3d_test.php
index 493663a..3334d9b 100644
--- a/tests/renderer_3d_test.php
+++ b/tests/renderer_3d_test.php
@@ -1125,61 +1125,6 @@ class ezcGraphRenderer3dTest extends ezcGraphTestCase
);
}
- public function testRenderPieChartWithBackgroundBottomCenter()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.svg';
-
- $chart = new ezcGraphPieChart();
- $chart->data['sample'] = new ezcGraphArrayDataSet( array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- ) );
-
- $chart->background->color = '#FFFFFFDD';
- $chart->background->image = dirname( __FILE__ ) . '/data/ez.png';
- $chart->background->position = ezcGraph::BOTTOM | ezcGraph::CENTER;
-
- $chart->driver = new ezcGraphSvgDriver();
- $chart->renderer = new ezcGraphRenderer3d();
- $chart->render( 500, 200, $filename );
-
- $this->compare(
- $filename,
- $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
- );
- }
-
- public function testRenderPieChartWithHorizontalTextureBackground()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.svg';
-
- $chart = new ezcGraphPieChart();
- $chart->data['sample'] = new ezcGraphArrayDataSet( array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- ) );
-
- $chart->background->color = '#FFFFFFDD';
- $chart->background->image = dirname( __FILE__ ) . '/data/texture.png';
- $chart->background->repeat = ezcGraph::HORIZONTAL;
- $chart->background->position = ezcGraph::BOTTOM;
-
- $chart->driver = new ezcGraphSvgDriver();
- $chart->renderer = new ezcGraphRenderer3d();
- $chart->render( 500, 200, $filename );
-
- $this->compare(
- $filename,
- $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
- );
- }
-
public function testRenderPieChartWithOffset()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
diff --git a/tests/suite.php b/tests/suite.php
index 3c37cc9..ce8a09c 100644
--- a/tests/suite.php
+++ b/tests/suite.php
@@ -21,6 +21,7 @@ require_once 'dataset_average_test.php';
require_once 'dataset_numeric_test.php';
require_once 'element_options_test.php';
require_once 'legend_test.php';
+require_once 'background_test.php';
require_once 'text_test.php';
require_once 'numeric_axis_test.php';
require_once 'labeled_axis_test.php';
@@ -64,6 +65,7 @@ class ezcGraphSuite extends PHPUnit_Framework_TestSuite
$this->addTest( ezcGraphNumericDataSetTest::suite() );
$this->addTest( ezcGraphElementOptionsTest::suite() );
$this->addTest( ezcGraphLegendTest::suite() );
+ $this->addTest( ezcGraphBackgroundTest::suite() );
$this->addTest( ezcGraphNumericAxisTest::suite() );
$this->addTest( ezcGraphLabeledAxisTest::suite() );
$this->addTest( ezcGraphLogarithmicalAxisTest::suite() );
OpenPOWER on IntegriCloud