diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-04-12 12:45:42 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-04-12 12:45:42 +0000 |
commit | e3c691c66bc360caae052a7387a258ac8af0c2a1 (patch) | |
tree | eda7c4184d615f590e20bf142b7dcd24bbe7f20c /tests/numeric_axis_test.php | |
parent | 40b5444276af768209c8a6b0df633b150da86ac8 (diff) | |
download | zetacomponents-graph-e3c691c66bc360caae052a7387a258ac8af0c2a1.zip zetacomponents-graph-e3c691c66bc360caae052a7387a258ac8af0c2a1.tar.gz |
- Added feature #10470: Add support for format callback functions on all axis
Diffstat (limited to 'tests/numeric_axis_test.php')
-rw-r--r-- | tests/numeric_axis_test.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php index defd8f2..96652cb 100644 --- a/tests/numeric_axis_test.php +++ b/tests/numeric_axis_test.php @@ -739,5 +739,69 @@ class ezcGraphNumericAxisTest extends ezcTestCase $this->fail( 'Expected ezcBaseValueException.' ); } + + public function testRenderedLabels() + { + try + { + $chart = new ezcGraphLineChart(); + $chart->data['sampleData'] = new ezcGraphArrayDataSet( array( 'sample 1' => 234, 'sample 2' => -21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1) ); + $chart->render( 500, 200 ); + } + catch ( ezcGraphFontRenderingException $e ) + { + // Ignore + } + + $steps = $chart->yAxis->getSteps(); + + $expectedLabels = array( + '-100', '0', '100', '200', '300', '400', + ); + + foreach ( $steps as $nr => $step ) + { + $this->assertEquals( + $step->label, + $expectedLabels[$nr], + 'Label not as expected' + ); + } + } + + public function testRenderedLabelsWithLabelFormattingCallback() + { + try + { + $chart = new ezcGraphLineChart(); + + $chart->yAxis->labelCallback = create_function( + '$label', + 'return "*$label*";' + ); + + $chart->data['sampleData'] = new ezcGraphArrayDataSet( array( 'sample 1' => 234, 'sample 2' => -21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1) ); + $chart->render( 500, 200 ); + } + catch ( ezcGraphFontRenderingException $e ) + { + // Ignore + } + + $steps = $chart->yAxis->getSteps(); + + $expectedLabels = array( + '*-100*', '*0*', '*100*', '*200*', '*300*', '*400*', + ); + + foreach ( $steps as $nr => $step ) + { + $this->assertSame( + $step->label, + $expectedLabels[$nr], + 'Label not as expected' + ); + } + } } ?> |