diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-05-10 07:01:41 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-05-10 07:01:41 +0000 |
commit | 897f5b6fbedba0716cf7488cf8abb51ab53b77b4 (patch) | |
tree | 8274a7c29b1398579752a80dd1b2c8785a0581cf /tests/radar_axis_test.php | |
parent | 98ff576c569c8a9c82d56fd22916d61f540c2cb9 (diff) | |
download | zetacomponents-graph-897f5b6fbedba0716cf7488cf8abb51ab53b77b4.zip zetacomponents-graph-897f5b6fbedba0716cf7488cf8abb51ab53b77b4.tar.gz |
- Added tests for axis in multiple directions
# Includes tests for issues #10745, #10744, #10747
- Added tests for different rotation axis
Diffstat (limited to 'tests/radar_axis_test.php')
-rw-r--r-- | tests/radar_axis_test.php | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/tests/radar_axis_test.php b/tests/radar_axis_test.php new file mode 100644 index 0000000..5ff4c32 --- /dev/null +++ b/tests/radar_axis_test.php @@ -0,0 +1,209 @@ +<?php +/** + * ezcGraphRadarChartAxisTest + * + * @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 ezcGraphRadarChartAxisTest extends ezcGraphTestCase +{ + protected $basePath; + + protected $tempDir; + + public static function suite() + { + return new PHPUnit_Framework_TestSuite( "ezcGraphRadarChartAxisTest" ); + } + + 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(); + } + } + + protected function getRandomData( $count, $min = 0, $max = 1000, $randomize = 23 ) + { + // Make data reproducible + mt_srand( $randomize ); + + for ( $i = 0; $i < $count; ++$i ) + { + $data[] = mt_rand( $min, $max ); + } + + return $data; + } + + public function testCenteredMultipleDirections() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphRadarChart(); + $chart->palette = new ezcGraphPaletteEzBlue(); + $chart->legend = false; + $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) ); + + $chart->axis->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer(); + + $chart->render( 500, 500, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testBoxedMultipleDirections() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphRadarChart(); + $chart->palette = new ezcGraphPaletteEzBlue(); + $chart->legend = false; + $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) ); + + $chart->axis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer(); + + $chart->render( 500, 500, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testExactMultipleDirections() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphRadarChart(); + $chart->palette = new ezcGraphPaletteEzBlue(); + $chart->legend = false; + $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 13 ) ); + + $chart->axis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); + $chart->axis->axisLabelRenderer->showLastValue = false; + + $chart->render( 500, 500, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testDateRotationAxis() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphRadarChart(); + $chart->palette = new ezcGraphPaletteEzBlue(); + $chart->legend = false; + $chart->data['sample'] = new ezcGraphArrayDataSet( array( + strtotime( '2006-10-16' ) => 7.78507871321, + strtotime( '2006-10-30' ) => 7.52224503765, + strtotime( '2006-11-20' ) => 7.29226557153, + strtotime( '2006-11-28' ) => 7.06228610541, + strtotime( '2006-12-05' ) => 6.66803559206, + strtotime( '2006-12-11' ) => 6.37234770705, + strtotime( '2006-12-28' ) => 6.04517453799, + ) ); + + $chart->rotationAxis = new ezcGraphChartElementDateAxis(); + + $chart->render( 400, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testNumericRotationAxis() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphRadarChart(); + $chart->palette = new ezcGraphPaletteEzBlue(); + $chart->legend = false; + $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 9 ) ); + + $chart->rotationAxis = new ezcGraphChartElementNumericAxis(); + + $chart->render( 400, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testLabeledRotationAxis() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphRadarChart(); + $chart->palette = new ezcGraphPaletteEzBlue(); + $chart->legend = false; + $chart->data['sample'] = new ezcGraphArrayDataSet( $this->getRandomData( 9 ) ); + + $chart->rotationAxis = new ezcGraphChartElementLabeledAxis(); + + $chart->render( 400, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testLogarithmicalRotationAxis() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $chart = new ezcGraphRadarChart(); + $chart->palette = new ezcGraphPaletteEzBlue(); + $chart->legend = false; + $chart->data['sample'] = new ezcGraphArrayDataSet( array( + 1 => 12, + 5 => 7, + 10 => 234, + 132 => 34, + 1125 => 12, + 12346 => 6, + 140596 => 1, + ) ); + + $chart->rotationAxis = new ezcGraphChartElementLogarithmicalAxis(); + + $chart->render( 400, 200, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } +} +?> |