summaryrefslogtreecommitdiffstats
path: root/tests/axis_space_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2009-07-21 11:25:18 +0000
committerKore Nordmann <github@kore-nordmann.de>2009-07-21 11:25:18 +0000
commit73061d5af4bcddd2df8169dccca17dfea5bb8477 (patch)
treedd1a19fe8c644a3f53d5f276ef5facfd5c6b57d6 /tests/axis_space_test.php
parent9ce834beee81194e02525a6cb836516dc379eeb7 (diff)
downloadzetacomponents-graph-73061d5af4bcddd2df8169dccca17dfea5bb8477.zip
zetacomponents-graph-73061d5af4bcddd2df8169dccca17dfea5bb8477.tar.gz
- Implemented: #15133: Better configurable axis spaces.
# Large number of tests added. Had to go through all sensible combinations of # axis and axis spaces to ensure it works correctly.
Diffstat (limited to 'tests/axis_space_test.php')
-rw-r--r--tests/axis_space_test.php150
1 files changed, 150 insertions, 0 deletions
diff --git a/tests/axis_space_test.php b/tests/axis_space_test.php
new file mode 100644
index 0000000..431116b
--- /dev/null
+++ b/tests/axis_space_test.php
@@ -0,0 +1,150 @@
+<?php
+/**
+ * ezcGraphAxisBoxedRendererTest
+ *
+ * @package Graph
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005-2009 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 Graph
+ * @subpackage Tests
+ */
+class ezcGraphAxisSpaceTest extends ezcGraphTestCase
+{
+ protected $basePath;
+
+ protected $tempDir;
+
+ protected static $i = 0;
+
+ public static function suite()
+ {
+ return new PHPUnit_Framework_TestSuite( __CLASS__ );
+ }
+
+ protected function setUp()
+ {
+ $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++self::$i ) ) . '/';
+ $this->basePath = dirname( __FILE__ ) . '/data/';
+ }
+
+ protected function tearDown()
+ {
+ if ( !$this->hasFailed() )
+ {
+ $this->removeTempDir();
+ }
+ }
+
+ public static function getAxisConfiguration()
+ {
+ $axisLabelRenderer = array(
+ new ezcGraphAxisCenteredLabelRenderer(),
+ new ezcGraphAxisExactLabelRenderer(),
+ new ezcGraphAxisBoxedLabelRenderer(),
+ new ezcGraphAxisRotatedLabelRenderer(),
+ );
+
+ $axisSpaces = array(
+ .1,
+ .2,
+ );
+
+ $outerSpaces = array(
+ .05,
+ .1,
+ );
+
+ $xAlignements = array(
+ ezcGraph::LEFT,
+ ezcGraph::RIGHT,
+ );
+
+ $yAlignements = array(
+ ezcGraph::BOTTOM,
+ ezcGraph::TOP,
+ );
+
+ $calls = array();
+ foreach ( $axisLabelRenderer as $xRenderer )
+ {
+ foreach ( $axisLabelRenderer as $yRenderer )
+ {
+ if ( $xRenderer === $yRenderer )
+ {
+ continue;
+ }
+
+ foreach ( $axisSpaces as $xSpace )
+ {
+ foreach ( $axisSpaces as $ySpace )
+ {
+ if ( $xSpace === $ySpace )
+ {
+ continue;
+ }
+
+ foreach ( $outerSpaces as $outerSpace )
+ {
+ foreach ( $xAlignements as $xAlign )
+ {
+ foreach ( $yAlignements as $yAlign )
+ {
+ $calls[] = array(
+ $xRenderer,
+ $yRenderer,
+ $xSpace,
+ $ySpace,
+ $outerSpace,
+ $xAlign,
+ $yAlign,
+ );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $calls;
+ }
+
+ /**
+ * @dataProvider getAxisConfiguration
+ */
+ public function testAxisSpaceConfiguration( ezcGraphAxisLabelRenderer $xRenderer, ezcGraphAxisLabelRenderer $yRenderer, $xSpace, $ySpace, $outerSpace, $xAlign, $yAlign )
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '_' . self::$i . '.svg';
+
+ $chart = new ezcGraphLineChart();
+ $chart->palette = new ezcGraphPaletteBlack();
+
+ $chart->xAxis->axisLabelRenderer = $xRenderer;
+ $chart->xAxis->axisSpace = $xSpace;
+ $chart->xAxis->outerAxisSpace = $outerSpace;
+ $chart->xAxis->position = $xAlign;
+
+ $chart->yAxis->axisLabelRenderer = $yRenderer;
+ $chart->yAxis->axisSpace = $ySpace;
+ $chart->yAxis->outerAxisSpace = $outerSpace;
+ $chart->yAxis->position = $yAlign;
+
+ $chart->data['sampleData'] = new ezcGraphArrayDataSet( array( 'sample 1' => 250, 'sample 2' => 250, 'sample 3' => 0, 'sample 4' => 0, 'sample 5' => 500, 'sample 6' => 500) );
+
+ $chart->render( 560, 250, $filename );
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '_' . self::$i . '.svg'
+ );
+ }
+}
+?>
OpenPOWER on IntegriCloud