diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2008-06-18 12:14:33 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2008-06-18 12:14:33 +0000 |
commit | 75b08433266050d20cd6125b7e139605639c8186 (patch) | |
tree | dd51057325f6b1bdb05159e250e9987f72dd3785 /tests/axis_exact_renderer_test.php | |
parent | 5632023751fcbd0c8fecd0d665ebf918b3a798b6 (diff) | |
download | zetacomponents-graph-75b08433266050d20cd6125b7e139605639c8186.zip zetacomponents-graph-75b08433266050d20cd6125b7e139605639c8186.tar.gz |
- Implemented feature #11981: Provide option for exact axis label renderer to
put last value outside of the normal label boundings
Diffstat (limited to 'tests/axis_exact_renderer_test.php')
-rw-r--r-- | tests/axis_exact_renderer_test.php | 101 |
1 files changed, 100 insertions, 1 deletions
diff --git a/tests/axis_exact_renderer_test.php b/tests/axis_exact_renderer_test.php index 6b5c301..d16f462 100644 --- a/tests/axis_exact_renderer_test.php +++ b/tests/axis_exact_renderer_test.php @@ -9,18 +9,24 @@ * @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 ezcGraphAxisExactRendererTest extends ezcTestCase +class ezcGraphAxisExactRendererTest extends ezcGraphTestCase { + protected $basePath; + protected $renderer; protected $driver; + protected $tempDir; + public static function suite() { return new PHPUnit_Framework_TestSuite( "ezcGraphAxisExactRendererTest" ); @@ -28,10 +34,23 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase protected function setUp() { + static $i = 0; + if ( version_compare( phpversion(), '5.1.3', '<' ) ) { $this->markTestSkipped( "This test requires PHP 5.1.3 or later." ); } + + $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/'; + $this->basePath = dirname( __FILE__ ) . '/data/'; + } + + protected function tearDown() + { + if ( !$this->hasFailed() ) + { + $this->removeTempDir(); + } } public function testDetermineCuttingPoint() @@ -874,5 +893,85 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase $this->fail( 'Expected ezcBaseValueException.' ); } + + public function testAxisExactLabelRendererPropertyRenderLastOutside() + { + $options = new ezcGraphAxisExactLabelRenderer(); + + $this->assertSame( + false, + $options->renderLastOutside, + 'Wrong default value for property renderLastOutside in class ezcGraphAxisExactLabelRenderer' + ); + + $options->renderLastOutside = true; + $this->assertSame( + true, + $options->renderLastOutside, + 'Setting property value did not work for property renderLastOutside in class ezcGraphAxisExactLabelRenderer' + ); + + try + { + $options->renderLastOutside = 42; + } + catch ( ezcBaseValueException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBaseValueException.' ); + } + + public function testOutsideLabelsBottomLeft() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $graph = new ezcGraphLineChart(); + $graph->legend = false; + + $graph->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); + $graph->xAxis->axisLabelRenderer->renderLastOutside = true; + $graph->yAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); + $graph->yAxis->axisLabelRenderer->renderLastOutside = true; + + $graph->data['sample'] = new ezcGraphArrayDataSet( + array( 1, 4, 6, 8, 2 ) + ); + + $graph->render( 560, 250, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } + + public function testOutsideLabelsTopRight() + { + $filename = $this->tempDir . __FUNCTION__ . '.svg'; + + $graph = new ezcGraphLineChart(); + $graph->legend = false; + + $graph->xAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); + $graph->xAxis->axisLabelRenderer->renderLastOutside = true; + $graph->xAxis->position = ezcGraph::RIGHT; + $graph->yAxis->axisLabelRenderer = new ezcGraphAxisExactLabelRenderer(); + $graph->yAxis->axisLabelRenderer->renderLastOutside = true; + $graph->yAxis->position = ezcGraph::TOP; + + $graph->data['sample'] = new ezcGraphArrayDataSet( + array( 1, 4, 6, 8, 2 ) + ); + + $graph->render( 560, 250, $filename ); + + $this->compare( + $filename, + $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg' + ); + } } + ?> |