diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-10-27 13:05:22 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-10-27 13:05:22 +0000 |
commit | 454b96f54673bbd3e35100e6683fa781808ebd4b (patch) | |
tree | fc99830f6bdc4a0f8921fb12998fd7df6e8a4477 /tests | |
parent | 1d0cc07e07709c1bc59bbbf591c23b846d4fce57 (diff) | |
download | zetacomponents-graph-454b96f54673bbd3e35100e6683fa781808ebd4b.zip zetacomponents-graph-454b96f54673bbd3e35100e6683fa781808ebd4b.tar.gz |
- Added missing tests for axis
Diffstat (limited to 'tests')
-rw-r--r-- | tests/date_axis_test.php | 37 | ||||
-rw-r--r-- | tests/labeled_axis_test.php | 47 |
2 files changed, 84 insertions, 0 deletions
diff --git a/tests/date_axis_test.php b/tests/date_axis_test.php index 3063d0c..9133630 100644 --- a/tests/date_axis_test.php +++ b/tests/date_axis_test.php @@ -408,6 +408,43 @@ class ezcGraphDateAxisTest extends ezcTestCase .05 ); } + + public function testStrToTimeLabelConvertion() + { + $this->chart->data['some data'] = new ezcGraphArrayDataSet( array( + '1.1.2001' => 324, + '1.1.2002' => 324, + '1.1.2003' => 324, + '1.1.2004' => 324, + ) ); + + try + { + $this->chart->render( 500, 200 ); + } + catch ( ezcGraphFontRenderingException $e ) + { + // Ignore + } + + $this->assertEquals( + 'Mon, 01 Jan 2001 01:00:00 +0100', + date( 'r', $this->chart->xAxis->startDate ), + 'Wrong starting date. ' + ); + + $this->assertEquals( + 'Thu, 01 Jan 2004 01:00:00 +0100', + date( 'r', $this->chart->xAxis->endDate ), + 'Wrong end date. ' + ); + + $this->assertEquals( + 31536000, + $this->chart->xAxis->interval, + 'Wrong interval. ' + ); + } } ?> diff --git a/tests/labeled_axis_test.php b/tests/labeled_axis_test.php index c8e7450..6d8bc41 100644 --- a/tests/labeled_axis_test.php +++ b/tests/labeled_axis_test.php @@ -260,6 +260,53 @@ class ezcGraphLabeledAxisTest extends ezcTestCase .05 ); } + + public function testAutomaticLabelingWithLotsOfLabels() + { + $chart = new ezcGraphLineChart(); + $chart->data['sample'] = new ezcGraphArrayDataSet( array( 2000 => 1045, 1300, 1012, 1450, 341, 421, 452, 1203, 540, 1104, 1503, 1204, 1402, 652, 972, 230, 1502, 1305, 983, 872, 934, 1423 ) ); + $chart->render( 500, 200 ); + + $this->assertEquals( + array( + 2000, + 2003, + 2006, + 2009, + 2012, + 2015, + 2018, + 2021, + ), + $this->getAttribute( $chart->xAxis, 'displayedLabels' ) + ); + } + + public function testGetLabel() + { + $chart = new ezcGraphLineChart(); + $chart->data['sample'] = new ezcGraphArrayDataSet( array( 2000 => 1045, 1300, 1012, 1450 ) ); + $chart->render( 500, 200 ); + + $this->assertSame( + '2001', + $chart->xAxis->getLabel( 1 ), + 'Wrong label returned for step.' + ); + } + + public function testGetNonexistantLabel() + { + $chart = new ezcGraphLineChart(); + $chart->data['sample'] = new ezcGraphArrayDataSet( array( 2000 => 1045, 1300, 1012, 1450 ) ); + $chart->render( 500, 200 ); + + $this->assertSame( + false, + $chart->xAxis->getLabel( 5 ), + 'Wrong label returned for nonexisting step.' + ); + } } ?> |