From 0c80b0f8ebf6c47237c9c99ea9f54248f1223df6 Mon Sep 17 00:00:00 2001 From: Kore Nordmann Date: Mon, 7 Aug 2006 08:17:12 +0000 Subject: - Removed factory methods and replaced them with direct class instantiation. --- design/design.txt | 4 +- src/graph.php | 47 --------------------- src/interfaces/chart.php | 4 +- tests/axis_centered_renderer_test.php | 56 ++++++++++++------------- tests/axis_exact_renderer_test.php | 56 ++++++++++++------------- tests/chart_test.php | 24 +++++------ tests/dataset_test.php | 34 +++++++-------- tests/font_test.php | 8 ++-- tests/graph_test.php | 78 ----------------------------------- tests/labeled_axis_test.php | 16 +++---- tests/legend_test.php | 10 ++--- tests/line_test.php | 12 +++--- tests/numeric_axis_test.php | 36 ++++++++-------- tests/palette_test.php | 46 ++++++++++----------- tests/pie_test.php | 8 ++-- tests/renderer_2d_test.php | 30 +++++++------- tests/renderer_3d_test.php | 38 ++++++++--------- tests/suite.php | 6 --- tests/text_test.php | 6 +-- 19 files changed, 194 insertions(+), 325 deletions(-) delete mode 100644 tests/graph_test.php diff --git a/design/design.txt b/design/design.txt index a4e0b05..267750c 100644 --- a/design/design.txt +++ b/design/design.txt @@ -96,7 +96,7 @@ The following example shows how to use the class: :: options->backgroundImage = 'background.png'; $pie->options->border->color = '#ff0000'; $pie->title = 'Apple Pie'; @@ -106,7 +106,7 @@ The following example shows how to use the class: :: $pie['humanoids']->highlight( 'monkey' ); // chart type dependent - $line = ezcGraph::create( 'Line' ); + $line = new ezcGraphLineChart(); $line->options->backgroundColor = 'pink'; $line['income'] = array( 1990 => 5, 5.1, 5.4, 5.3, 6.9 ); diff --git a/src/graph.php b/src/graph.php index a9e97ab..fa4555a 100644 --- a/src/graph.php +++ b/src/graph.php @@ -14,7 +14,6 @@ */ class ezcGraph { - const NO_SYMBOL = 0; const DIAMOND = 1; const BULLET = 2; @@ -30,52 +29,6 @@ class ezcGraph const RIGHT = 8; const CENTER = 16; const MIDDLE = 32; - - static protected $chartTypes = array( - 'pie' => 'ezcGraphPieChart', - 'line' => 'ezcGraphLineChart', - ); - - /** - * create - * - * @param string $type Type of chart to create - * @param array $options Options to create the chart with - * @throws ezcGraphUnknownChartTypeException - * @return ezcGraphChart - */ - static public function create( $type, $options = array() ) - { - $type = strtolower( $type ); - if ( isset( self::$chartTypes[$type] ) ) - { - $className = self::$chartTypes[$type]; - return new $className( $options ); - } - else - { - throw new ezcGraphUnknownChartTypeException($type); - } - } - - /** - * Creates a palette from given name - * - * @param string $name Name of the palette - * @return ezcGraphPalette Created palette - */ - static public function createPalette( $name ) - { - $className = 'ezcGraphPalette' . $name; - if ( class_exists( $className ) ) - { - return new $className(); - } - else - { - throw new ezcGraphUnknownPaletteException( $name ); - } - } } ?> diff --git a/src/interfaces/chart.php b/src/interfaces/chart.php index 0bef62b..ddcc184 100644 --- a/src/interfaces/chart.php +++ b/src/interfaces/chart.php @@ -66,7 +66,7 @@ abstract class ezcGraphChart implements ArrayAccess public function __construct( array $options = array() ) { - $this->__set( 'palette', 'Tango' ); + $this->__set( 'palette', new ezcGraphPaletteTango() ); // Add standard elements $this->addElement( 'title', new ezcGraphChartElementText() ); @@ -144,7 +144,7 @@ abstract class ezcGraphChart implements ArrayAccess } else { - $this->palette = ezcGraph::createPalette( $propertyValue ); + throw new ezcBaseValueException( "palette", $propertyValue, "instanceof ezcGraphPalette" ); } $this->setFromPalette( $this->palette ); diff --git a/tests/axis_centered_renderer_test.php b/tests/axis_centered_renderer_test.php index 010dc4c..2ae65ba 100644 --- a/tests/axis_centered_renderer_test.php +++ b/tests/axis_centered_renderer_test.php @@ -47,8 +47,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisGrid() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); @@ -81,8 +81,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisOuterGrid() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->outerGrid = true; @@ -116,8 +116,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisSteps() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); @@ -150,8 +150,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisOuterSteps() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->outerStep = true; @@ -185,8 +185,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisNoInnerSteps() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->innerStep = false; @@ -221,8 +221,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisNoSteps() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->innerStep = false; @@ -244,8 +244,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderTextBoxes() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); @@ -278,8 +278,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderTextBoxesWithZeroValue() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->showZeroValue = true; @@ -321,8 +321,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisGridFromRight() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->position = ezcGraph::RIGHT; @@ -356,8 +356,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisGridFromTop() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->position = ezcGraph::TOP; @@ -391,8 +391,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderAxisGridFromBottom() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->position = ezcGraph::BOTTOM; @@ -426,8 +426,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderTextBoxesFromRight() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->xAxis->position = ezcGraph::RIGHT; $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); @@ -461,8 +461,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderTextBoxesFromTop() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->position = ezcGraph::TOP; @@ -496,8 +496,8 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase public function testRenderTextBoxesFromBottom() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); $chart->yAxis->position = ezcGraph::BOTTOM; diff --git a/tests/axis_exact_renderer_test.php b/tests/axis_exact_renderer_test.php index 26de5aa..5e97d60 100644 --- a/tests/axis_exact_renderer_test.php +++ b/tests/axis_exact_renderer_test.php @@ -127,8 +127,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisGrid() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); @@ -161,8 +161,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisOuterGrid() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->outerGrid = true; @@ -196,8 +196,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisSteps() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); @@ -230,8 +230,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisOuterSteps() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->outerStep = true; @@ -265,8 +265,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisNoInnerSteps() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->innerStep = false; @@ -301,8 +301,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisNoSteps() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->innerStep = false; @@ -324,8 +324,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderTextBoxes() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); @@ -366,8 +366,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderTextBoxesWithoutLastLabel() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->axisLabelRenderer->showLastValue = false; @@ -409,8 +409,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisGridFromRight() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->xAxis->position = ezcGraph::RIGHT; @@ -444,8 +444,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisGridFromTop() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->position = ezcGraph::TOP; @@ -479,8 +479,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderAxisGridFromBottom() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->position = ezcGraph::BOTTOM; @@ -514,8 +514,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderTextBoxesFromRight() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->xAxis->position = ezcGraph::RIGHT; $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); @@ -557,8 +557,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderTextBoxesFromTop() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->position = ezcGraph::TOP; @@ -600,8 +600,8 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase public function testRenderTextBoxesFromBottom() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer(); $chart->yAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); $chart->yAxis->position = ezcGraph::BOTTOM; diff --git a/tests/chart_test.php b/tests/chart_test.php index 2173b72..10a9183 100644 --- a/tests/chart_test.php +++ b/tests/chart_test.php @@ -51,7 +51,7 @@ class ezcGraphChartTest extends ezcTestCase public function testSetTitle() { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->title = 'Test title'; $this->assertSame( @@ -66,7 +66,7 @@ class ezcGraphChartTest extends ezcTestCase public function testSetOptionsValidBackgroundImage() { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->options->backgroundImage = $this->basePath . $this->testFiles['jpeg']; $background = $this->getNonPublicProperty( $pieChart->options, 'backgroundImage' ); @@ -82,7 +82,7 @@ class ezcGraphChartTest extends ezcTestCase { try { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->options->backgroundImage = $this->basePath . $this->testFiles['invalid']; } catch ( ezcGraphInvalidImageFileException $e ) @@ -97,7 +97,7 @@ class ezcGraphChartTest extends ezcTestCase { try { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->options->backgroundImage = $this->basePath . $this->testFiles['nonexistant']; } catch ( ezcBaseFileNotFoundException $e ) @@ -110,7 +110,7 @@ class ezcGraphChartTest extends ezcTestCase public function testSetOptionsBackground() { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->options->background = '#FF0000'; $this->assertEquals( @@ -121,7 +121,7 @@ class ezcGraphChartTest extends ezcTestCase public function testSetOptionsBorder() { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->options->border = '#FF0000'; $this->assertEquals( @@ -132,7 +132,7 @@ class ezcGraphChartTest extends ezcTestCase public function testSetOptionsBorderWidth() { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->options->borderWidth = 3; $this->assertSame( 3, $this->getNonPublicProperty( $pieChart->options, 'borderWidth' ) ); @@ -142,7 +142,7 @@ class ezcGraphChartTest extends ezcTestCase { try { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->options->unknown = 'unknown'; } catch ( ezcBasePropertyNotFoundException $e ) @@ -155,7 +155,7 @@ class ezcGraphChartTest extends ezcTestCase public function testSetRenderer() { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $renderer = $pieChart->renderer = new ezcGraphRenderer2d(); $this->assertSame( @@ -168,7 +168,7 @@ class ezcGraphChartTest extends ezcTestCase { try { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->renderer = 'invalid'; } catch ( ezcGraphInvalidRendererException $e ) @@ -181,7 +181,7 @@ class ezcGraphChartTest extends ezcTestCase public function testSetDriver() { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $driver = $pieChart->driver = new ezcGraphGdDriver(); $this->assertSame( @@ -194,7 +194,7 @@ class ezcGraphChartTest extends ezcTestCase { try { - $pieChart = ezcGraph::create( 'Pie' ); + $pieChart = new ezcGraphPieChart(); $pieChart->driver = 'invalid'; } catch ( ezcGraphInvalidDriverException $e ) diff --git a/tests/dataset_test.php b/tests/dataset_test.php index 0ae5984..7af448c 100644 --- a/tests/dataset_test.php +++ b/tests/dataset_test.php @@ -43,7 +43,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testCreateDataSetFromArray() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['humanoids'] = array( 'monkey' => 54, 'ape' => 37, 'human' => 9 ); $datasets = $this->getNonPublicProperty( $chart, 'data' ); @@ -55,7 +55,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testGetDataSet() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['humanoids'] = array( 'monkey' => 54, 'ape' => 37, 'human' => 9 ); $this->assertTrue( @@ -66,7 +66,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetContent() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['example'] = array( 'monkey' => 54, 2001 => 37 ); $data = $this->getNonPublicProperty( $chart['example'], 'data' ); @@ -83,7 +83,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testCreateMultipleDataSetsFromArray() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['spending'] = array( 2000 => 2347.2, 2458.3, 2569.4 ); @@ -102,7 +102,7 @@ class ezcGraphDataSetTest extends ezcTestCase { try { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['spending'] = array( 2000 => 2347.2, 2458.3, 2569.4 ); } @@ -116,7 +116,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetLabel() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $this->assertEquals( @@ -127,7 +127,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetSetLabel() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income']->label = 'Income Label'; @@ -139,7 +139,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetSetColor() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income']->color = '#FF0000'; @@ -151,7 +151,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetSetHighlight() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income']->highlight = true; @@ -163,7 +163,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetGetHighlight() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $this->assertEquals( @@ -179,7 +179,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetSetHighlightSingle() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income']->highlight[2001] = true; @@ -196,7 +196,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetSetSingleColor() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income']->color[2001] = '#FF0000'; @@ -208,7 +208,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetSetSingleSymbol() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income']->symbol[2001] = ezcGraph::DIAMOND; @@ -220,7 +220,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetPropertyValueFallback() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income']->symbol = ezcGraph::DIAMOND; @@ -234,7 +234,7 @@ class ezcGraphDataSetTest extends ezcTestCase { try { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income']->symbol[2006] = ezcGraph::DIAMOND; } @@ -248,7 +248,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetGetSingleData() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $this->assertSame( @@ -259,7 +259,7 @@ class ezcGraphDataSetTest extends ezcTestCase public function testDataSetSetSingleData() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['income'][2005] = 234.21; diff --git a/tests/font_test.php b/tests/font_test.php index 8d6795c..9a06edd 100644 --- a/tests/font_test.php +++ b/tests/font_test.php @@ -46,7 +46,7 @@ class ezcGraphFontTest extends ezcTestCase public function testSetGeneralFont() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart->options->font = $this->basePath . 'font.ttf'; $this->assertTrue( @@ -69,7 +69,7 @@ class ezcGraphFontTest extends ezcTestCase public function testGetGeneralFontForElement() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart->options->font = $this->basePath . 'font.ttf'; $this->assertTrue( @@ -86,7 +86,7 @@ class ezcGraphFontTest extends ezcTestCase public function testSetFontForElement() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart->options->font = $this->basePath . 'font.ttf'; $chart->legend->font = $this->basePath . 'font2.ttf'; @@ -116,7 +116,7 @@ class ezcGraphFontTest extends ezcTestCase public function testSetFontForElementWithRendering() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart->options->font = $this->basePath . 'font.ttf'; $chart->legend->font = $this->basePath . 'font2.ttf'; diff --git a/tests/graph_test.php b/tests/graph_test.php deleted file mode 100644 index 4c25c33..0000000 --- a/tests/graph_test.php +++ /dev/null @@ -1,78 +0,0 @@ -assertTrue( - $pieChart instanceof ezcGraphPieChart, - 'ezcGraph::create did not return a ezcGraphPieChart' - ); - } - - public function testFactoryLineChart() - { - $lineChart = ezcGraph::create( 'Line' ); - - $this->assertTrue( - $lineChart instanceof ezcGraphLineChart, - 'ezcGraph::create did not return a ezcGraphLineChart' - ); - } - - public function testFactoryUnknownChart() - { - try - { - $unknownChart = ezcGraph::create( 'Unknown' ); - } - catch ( ezcGraphUnknownChartTypeException $e ) - { - return true; - } - - $this->fail( 'Expected ezcGraphUnknownChartTypeException' ); - } -} -?> diff --git a/tests/labeled_axis_test.php b/tests/labeled_axis_test.php index 0a92895..7de876b 100644 --- a/tests/labeled_axis_test.php +++ b/tests/labeled_axis_test.php @@ -43,7 +43,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase public function testFactoryLabeledAxis() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertTrue( $chart->xAxis instanceof ezcGraphChartElementLabeledAxis @@ -52,7 +52,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase public function testAutomaticLabelingSingle() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 20, 70, 12, 130 ); $chart->render( 500, 200 ); @@ -69,7 +69,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase public function testAutomaticLabelingMultiple() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart['sample2'] = array( 2002 => 1270, 1170, 1610, 1370 ); $chart->render( 500, 200 ); @@ -89,7 +89,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase public function testAutomaticLabelingMultipleMixed() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 2001 => 1300, 2004 => 1012, 2006 => 1450 ); $chart['sample2'] = array( 2001 => 1270, 1170, 1610, 1370, 1559 ); $chart->render( 500, 200 ); @@ -110,7 +110,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase public function testPositionLeft() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->xAxis->position = ezcGraph::LEFT; $chart->render( 500, 200 ); @@ -153,7 +153,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase public function testPositionRight() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->xAxis->position = ezcGraph::RIGHT; $chart->render( 500, 200 ); @@ -196,7 +196,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase public function testPositionTop() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->xAxis->position = ezcGraph::TOP; $chart->render( 500, 200 ); @@ -239,7 +239,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase public function testPositionBottom() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->xAxis->position = ezcGraph::BOTTOM; $chart->render( 500, 200 ); diff --git a/tests/legend_test.php b/tests/legend_test.php index bd125de..2396d4c 100644 --- a/tests/legend_test.php +++ b/tests/legend_test.php @@ -55,7 +55,7 @@ class ezcGraphLegendTest extends ezcTestCase public function testFactoryLegend() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $this->assertTrue( $chart->legend instanceof ezcGraphChartElementLegend @@ -64,7 +64,7 @@ class ezcGraphLegendTest extends ezcTestCase public function testLegendSetBackground() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart->legend->background = '#FF0000'; $this->assertEquals( @@ -80,7 +80,7 @@ class ezcGraphLegendTest extends ezcTestCase public function testLegendSetBorder() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart->legend->border = '#FF0000'; $this->assertEquals( @@ -96,7 +96,7 @@ class ezcGraphLegendTest extends ezcTestCase public function testLegendSetBorderWidth() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart->legend->borderWidth = 1; $this->assertEquals( @@ -112,7 +112,7 @@ class ezcGraphLegendTest extends ezcTestCase public function testLegendSetPosition() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart->legend->position = ezcGraph::LEFT; $this->assertEquals( diff --git a/tests/line_test.php b/tests/line_test.php index 0e8dd3a..5363db0 100644 --- a/tests/line_test.php +++ b/tests/line_test.php @@ -58,7 +58,7 @@ class ezcGraphLineChartTest extends ezcTestCase public function testElementGenerationLegend() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->addSampleData( $chart ); $chart->render( 500, 200 ); @@ -97,7 +97,7 @@ class ezcGraphLineChartTest extends ezcTestCase public function testRenderChartLines() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1 ); $chart['sampleData']->color = '#CC0000'; $chart['sampleData']->symbol = ezcGraph::DIAMOND; @@ -184,9 +184,9 @@ class ezcGraphLineChartTest extends ezcTestCase public function testRenderChartFilledLines() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => -46, 'sample 4' => 120, 'sample 5' => 100 ); - $chart->palette = 'Black'; + $chart->palette = new ezcGraphPaletteBlack(); $chart->options->fillLines = 100; $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array( @@ -243,8 +243,8 @@ class ezcGraphLineChartTest extends ezcTestCase public function testRenderChartSymbols() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['sampleData']->symbol = ezcGraph::DIAMOND; $chart['sampleData']->symbol['sample 3'] = ezcGraph::CIRCLE; diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php index e9a7d9a..1b6428d 100644 --- a/tests/numeric_axis_test.php +++ b/tests/numeric_axis_test.php @@ -43,7 +43,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testFactoryNumericAxis() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertTrue( $chart->yAxis instanceof ezcGraphChartElementNumericAxis @@ -52,7 +52,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testManualScaling() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart->yAxis->min = 10; $chart->yAxis->max = 50; $chart->yAxis->majorStep = 10; @@ -81,7 +81,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testManualScalingPublicProperties() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart->yAxis->min = 10; $chart->yAxis->max = 50; $chart->yAxis->majorStep = 10; @@ -114,7 +114,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testAutomagicScalingSingle() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 20, 70, 12, 130 ); $chart->render( 500, 200 ); @@ -145,7 +145,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testAutomagicScalingSingle2() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1, 4.3, .2, 3.82 ); $chart->render( 500, 200 ); @@ -176,7 +176,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testAutomagicScalingSingle3() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => -1.8, 4.3, .2, 3.82 ); $chart->render( 500, 200 ); @@ -207,7 +207,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testAutomagicScalingSingle4() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->render( 500, 200 ); @@ -238,7 +238,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testAutomagicScalingMultiple() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart['sample2'] = array( 2000 => 1270, 1170, 1610, 1370 ); $chart->render( 500, 200 ); @@ -270,7 +270,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testMixedAutomagicAndManualScaling() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->yAxis->majorStep = 50; $chart->render( 500, 200 ); @@ -302,7 +302,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testMixedAutomagicAndManualScaling2() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->yAxis->min = 0; $chart->render( 500, 200 ); @@ -334,7 +334,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testMixedAutomagicAndManualScaling3() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->yAxis->max = 2000; $chart->render( 500, 200 ); @@ -366,7 +366,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testMixedAutomagicAndManualScaling4() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->yAxis->min = 0; $chart->yAxis->max = 2000; @@ -399,7 +399,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testPositionLeft() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->yAxis->position = ezcGraph::LEFT; $chart->render( 500, 200 ); @@ -435,7 +435,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testPositionRight() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->yAxis->position = ezcGraph::RIGHT; $chart->render( 500, 200 ); @@ -471,7 +471,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testPositionTop() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->yAxis->position = ezcGraph::TOP; $chart->render( 500, 200 ); @@ -507,7 +507,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testPositionBottom() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => 1045, 1300, 1012, 1450 ); $chart->yAxis->position = ezcGraph::BOTTOM; $chart->render( 500, 200 ); @@ -543,7 +543,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testPositionLeftNegativMinimum() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 2000 => -300, 1300, 1012, 1450 ); $chart->yAxis->majorStep = 500; $chart->yAxis->position = ezcGraph::LEFT; @@ -580,7 +580,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase public function testNullPositionMultipleDataSets() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => -21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['moreData'] = array( 'sample 1' => 112, 'sample 2' => 54, 'sample 3' => 12, 'sample 4' => -167, 'sample 5' => 329); $chart['evenMoreData'] = array( 'sample 1' => 300, 'sample 2' => -30, 'sample 3' => 220, 'sample 4' => 67, 'sample 5' => 450); diff --git a/tests/palette_test.php b/tests/palette_test.php index c1ee41d..1223653 100644 --- a/tests/palette_test.php +++ b/tests/palette_test.php @@ -43,7 +43,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testDefaultPalette() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertTrue( $chart->palette instanceof ezcGraphPalette, @@ -58,8 +58,8 @@ class ezcGraphPaletteTest extends ezcTestCase public function testChangePalette() { - $chart = ezcGraph::create( 'Line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $this->assertTrue( $chart->palette instanceof ezcGraphPalette, @@ -76,12 +76,12 @@ class ezcGraphPaletteTest extends ezcTestCase { try { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); // Silenced, because this throws an E_WARNING in devel mode, // caused by the non existing class ezcGraphPaletteUndefined @$chart->palette = 'Undefined'; } - catch ( ezcGraphUnknownPaletteException $e ) + catch ( ezcBaseValueException $e ) { return true; } @@ -91,7 +91,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testChartBackgroundColor() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( ezcGraphColor::fromHex( '#EEEEEC' ), @@ -102,7 +102,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testElementBackgroundColor() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( ezcGraphColor::fromHex( '#000000FF' ), @@ -113,7 +113,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testAxisColor() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( ezcGraphColor::fromHex( '#2E3436' ), @@ -124,7 +124,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testDataSetColor() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( ezcGraphColor::fromHex( '#3465A4' ), @@ -183,7 +183,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testDataSetSymbol() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( ezcGraph::NO_SYMBOL, @@ -200,7 +200,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testFontFace() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( 'Vera.ttf', @@ -211,7 +211,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testFontColor() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( ezcGraphColor::fromHex( '#2E3436' ), @@ -222,7 +222,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testChartBorderColor() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( ezcGraphColor::fromHex( '#000000FF' ), @@ -233,7 +233,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testChartBorderWidth() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( 0, @@ -244,7 +244,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testElementBorderColor() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( ezcGraphColor::fromHex( '#000000FF' ), @@ -255,7 +255,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testElementBorderWidth() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( 0, @@ -266,7 +266,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testPadding() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( 1, @@ -277,7 +277,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testMargin() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $this->assertEquals( 0, @@ -288,7 +288,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testDataSetAutomaticColorization() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['spending'] = array( 2000 => 2347.2, 2458.3, 2569.4 ); @@ -307,7 +307,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testChartBackground() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['spending'] = array( 2000 => 2347.2, 2458.3, 2569.4 ); @@ -320,7 +320,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testChartElementBorder() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['spending'] = array( 2000 => 2347.2, 2458.3, 2569.4 ); @@ -333,7 +333,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testChartElementBorderWidth() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['spending'] = array( 2000 => 2347.2, 2458.3, 2569.4 ); @@ -346,7 +346,7 @@ class ezcGraphPaletteTest extends ezcTestCase public function testChartElementAxisColor() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['income'] = array( 2000 => 2345.2, 2456.3, 2567.4 ); $chart['spending'] = array( 2000 => 2347.2, 2458.3, 2569.4 ); diff --git a/tests/pie_test.php b/tests/pie_test.php index bb9a3a4..ce0b343 100644 --- a/tests/pie_test.php +++ b/tests/pie_test.php @@ -51,7 +51,7 @@ class ezcGraphPieChartTest extends ezcImageTestCase public function testElementGenerationLegend() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart->render( 500, 200 ); @@ -84,7 +84,7 @@ class ezcGraphPieChartTest extends ezcImageTestCase public function testPieRenderPieSegments() { - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'Mozilla' => 4375, 'IE' => 345, @@ -163,7 +163,7 @@ class ezcGraphPieChartTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['Skien'] = array( 'Norwegian' => 10, 'Dutch' => 3, 'German' => 2, 'French' => 2, 'Hindi' => 1, 'Taiwanese' => 1, 'Brazilian' => 1, 'Venezuelan' => 1, 'Japanese' => 1, 'Czech' => 1, 'Hungarian' => 1, 'Romanian' => 1 ); $chart['Skien']->highlight['Norwegian'] = true; @@ -184,7 +184,7 @@ class ezcGraphPieChartTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['Skien'] = array( 'Norwegian' => 10, 'Dutch' => 3, 'German' => 2, 'French' => 2, 'Hindi' => 1, 'Taiwanese' => 1, 'Brazilian' => 1, 'Venezuelan' => 1, 'Japanese' => 1, 'Czech' => 1, 'Hungarian' => 1, 'Romanian' => 1 ); $chart['Skien']->highlight['Norwegian'] = true; diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php index f1e3c1d..cc2da38 100644 --- a/tests/renderer_2d_test.php +++ b/tests/renderer_2d_test.php @@ -1090,7 +1090,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase public function testRenderVerticalLegendSymbols() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['sampleData']->color = '#0000FF'; @@ -1157,7 +1157,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase public function testRenderVerticalLegendText() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['sampleData']->color = '#0000FF'; @@ -1215,7 +1215,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase public function testRenderHorizontalLegendSymbols() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['sampleData']->color = '#0000FF'; @@ -1283,7 +1283,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase public function testRenderHorizontalLegendText() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['sampleData']->color = '#0000FF'; @@ -1342,7 +1342,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase public function testRenderVerticalAxis() { - $chart = ezcGraph::create( 'line' ); + $chart = new ezcGraphLineChart(); $this->driver ->expects( $this->at( 0 ) ) @@ -1376,7 +1376,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase public function testRenderVerticalAxisReverse() { - $chart = ezcGraph::create( 'line' ); + $chart = new ezcGraphLineChart(); $this->driver ->expects( $this->at( 0 ) ) @@ -1410,7 +1410,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase public function testRenderHorizontalAxis() { - $chart = ezcGraph::create( 'line' ); + $chart = new ezcGraphLineChart(); $this->driver ->expects( $this->at( 0 ) ) @@ -1444,7 +1444,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase public function testRenderHorizontalAxisReverse() { - $chart = ezcGraph::create( 'line' ); + $chart = new ezcGraphLineChart(); $this->driver ->expects( $this->at( 0 ) ) @@ -1480,8 +1480,8 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613); @@ -1502,8 +1502,8 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->options->fillLines = 200; $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); @@ -1525,8 +1525,8 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->options->fillLines = 200; $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => -151, 'sample 3' => 324, 'sample 4' => -120, 'sample 5' => 1); @@ -1548,7 +1548,7 @@ class ezcGraphRenderer2dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'Mozilla' => 4375, 'IE' => 345, diff --git a/tests/renderer_3d_test.php b/tests/renderer_3d_test.php index f2c2c83..8e60116 100644 --- a/tests/renderer_3d_test.php +++ b/tests/renderer_3d_test.php @@ -53,7 +53,7 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'Mozilla' => 4375, 'IE' => 345, @@ -81,7 +81,7 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'label 1' => 20, 'label 2' => 20, @@ -118,7 +118,7 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'Mozilla' => 4375, 'IE' => 345, @@ -148,7 +148,7 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'Mozilla' => 4375, 'IE' => 345, @@ -178,7 +178,7 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'Mozilla' => 4375, 'IE' => 345, @@ -208,7 +208,7 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'Mozilla' => 4375, 'IE' => 345, @@ -238,7 +238,7 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'Pie' ); + $chart = new ezcGraphPieChart(); $chart['sample'] = array( 'Mozilla' => 4375, 'IE' => 345, @@ -268,8 +268,8 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613); @@ -291,8 +291,8 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->options->fillLines = 200; $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); @@ -315,8 +315,8 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart->options->fillLines = 200; $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => -151, 'sample 3' => 324, 'sample 4' => -120, 'sample 5' => 1); @@ -339,8 +339,8 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613); @@ -364,8 +364,8 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613); @@ -389,8 +389,8 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase { $filename = $this->tempDir . __FUNCTION__ . '.png'; - $chart = ezcGraph::create( 'line' ); - $chart->palette = 'Black'; + $chart = new ezcGraphLineChart(); + $chart->palette = new ezcGraphPaletteBlack(); $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1); $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613); diff --git a/tests/suite.php b/tests/suite.php index 9fc1a1a..ea08751 100644 --- a/tests/suite.php +++ b/tests/suite.php @@ -10,11 +10,6 @@ */ /** -* Require test suite for Graph class. -*/ -require_once 'graph_test.php'; - -/** * Require test suites. */ require_once 'color_test.php'; @@ -48,7 +43,6 @@ class ezcGraphSuite extends ezcTestSuite parent::__construct(); $this->setName( "Graph" ); - $this->addTest( ezcGraphTest::suite() ); $this->addTest( ezcGraphColorTest::suite() ); $this->addTest( ezcGraphChartTest::suite() ); $this->addTest( ezcGraphPieChartTest::suite() ); diff --git a/tests/text_test.php b/tests/text_test.php index de303b8..74ec76c 100644 --- a/tests/text_test.php +++ b/tests/text_test.php @@ -43,7 +43,7 @@ class ezcGraphTextTest extends ezcTestCase public function testRenderTextTop() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 'foo' => 1, 'bar' => 10 ); $chart->title = 'Title of a chart'; @@ -69,7 +69,7 @@ class ezcGraphTextTest extends ezcTestCase public function testRenderTextBottom() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 'foo' => 1, 'bar' => 10 ); $chart->title = 'Title of a chart'; @@ -96,7 +96,7 @@ class ezcGraphTextTest extends ezcTestCase public function testRenderTextTopMargin() { - $chart = ezcGraph::create( 'Line' ); + $chart = new ezcGraphLineChart(); $chart['sample'] = array( 'foo' => 1, 'bar' => 10 ); $chart->title = 'Title of a chart'; -- cgit v1.1