diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-06-08 16:00:09 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-06-08 16:00:09 +0000 |
commit | f98ef3a072c9469d99d6f78c7b0fc33f74cccda5 (patch) | |
tree | 3bf725e75408adb9794c090ee86f9c9dad508a2a /tests | |
parent | a06f707fb0f0721d42c1c603423def575161aca2 (diff) | |
download | zetacomponents-graph-f98ef3a072c9469d99d6f78c7b0fc33f74cccda5.zip zetacomponents-graph-f98ef3a072c9469d99d6f78c7b0fc33f74cccda5.tar.gz |
- Added grids to line charts (tests & implementation)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/labeled_axis_test.php | 53 | ||||
-rw-r--r-- | tests/line_test.php | 2 | ||||
-rw-r--r-- | tests/numeric_axis_test.php | 90 |
3 files changed, 144 insertions, 1 deletions
diff --git a/tests/labeled_axis_test.php b/tests/labeled_axis_test.php index 767cbe3..c5736a6 100644 --- a/tests/labeled_axis_test.php +++ b/tests/labeled_axis_test.php @@ -392,6 +392,59 @@ class ezcGraphLabeledAxisTest extends ezcTestCase $chart->render( 500, 200 ); } + public function testRenderNumericAxisMajorGrid() + { + $chart = ezcGraph::create( 'Line' ); + $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 ); + $chart->X_axis->grid = '#BBBBBB'; + + $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array( + 'drawLine', + ) ); + + // X-Axis + $mockedRenderer + ->expects( $this->at( 1 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 120, 0 ) ), + $this->equalTo( new ezcGraphCoordinate( 120, 200 ) ), + $this->equalTo( false ) + ); + $mockedRenderer + ->expects( $this->at( 3 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 240, 0 ) ), + $this->equalTo( new ezcGraphCoordinate( 240, 200 ) ), + $this->equalTo( false ) + ); + $mockedRenderer + ->expects( $this->at( 5 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 361, 0 ) ), + $this->equalTo( new ezcGraphCoordinate( 361, 200 ) ), + $this->equalTo( false ) + ); + $mockedRenderer + ->expects( $this->at( 7 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 481, 0 ) ), + $this->equalTo( new ezcGraphCoordinate( 481, 200 ) ), + $this->equalTo( false ) + ); + + $chart->renderer = $mockedRenderer; + + $chart->render( 500, 200 ); + } + public function testRenderLabeledAxisLabels() { $chart = ezcGraph::create( 'Line' ); diff --git a/tests/line_test.php b/tests/line_test.php index bf7a817..11f3214 100644 --- a/tests/line_test.php +++ b/tests/line_test.php @@ -237,7 +237,7 @@ class ezcGraphLineChartTest extends ezcTestCase ); $this->assertEquals( - '3e25cf259cb609c55f225ef1f5e3ed22', + '00ada6588d0974ecd7a73e96877d659e', md5_file( $filename ), 'Incorrect image rendered.' ); diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php index 4f94bd8..d0f0229 100644 --- a/tests/numeric_axis_test.php +++ b/tests/numeric_axis_test.php @@ -623,6 +623,50 @@ class ezcGraphNumericAxisTest extends ezcTestCase $chart->render( 500, 200 ); } + public function testRenderNumericAxisMajorGrid() + { + $chart = ezcGraph::create( 'Line' ); + $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 ); + $chart->Y_axis->grid = ezcGraphColor::fromHex( '#BBBBBB' ); + + $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array( + 'drawLine', + ) ); + + // Y-Axis + $mockedRenderer + ->expects( $this->at( 6 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 100, 190 ) ), + $this->equalTo( new ezcGraphCoordinate( 500, 190 ) ), + $this->equalTo( false ) + ); + $mockedRenderer + ->expects( $this->at( 8 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 100, 154 ) ), + $this->equalTo( new ezcGraphCoordinate( 500, 154 ) ), + $this->equalTo( false ) + ); + $mockedRenderer + ->expects( $this->at( 16 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 100, 10 ) ), + $this->equalTo( new ezcGraphCoordinate( 500, 10 ) ), + $this->equalTo( false ) + ); + + $chart->renderer = $mockedRenderer; + + $chart->render( 500, 200 ); + } + public function testRenderNumericAxisMinor() { $chart = ezcGraph::create( 'Line' ); @@ -679,6 +723,52 @@ class ezcGraphNumericAxisTest extends ezcTestCase $chart->render( 500, 200 ); } + public function testRenderNumericAxisMinorGrid() + { + $chart = ezcGraph::create( 'Line' ); + $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 ); + $chart->Y_axis->minorGrid = '#BBBBBB'; + + $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array( + 'drawLine', + ) ); + + // Y-Axis + $mockedRenderer + ->expects( $this->at( 12 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 100, 190 ) ), + $this->equalTo( new ezcGraphCoordinate( 500, 190 ) ), + $this->equalTo( false ) + ); + $mockedRenderer + ->expects( $this->at( 14 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 100, 181 ) ), + $this->equalTo( new ezcGraphCoordinate( 500, 181 ) ), + $this->equalTo( false ) + ); + + // Last minor step + $mockedRenderer + ->expects( $this->at( 50 ) ) + ->method( 'drawLine' ) + ->with( + $this->equalTo( ezcGraphColor::fromHex( '#BBBBBB' ) ), + $this->equalTo( new ezcGraphCoordinate( 100, 19 ) ), + $this->equalTo( new ezcGraphCoordinate( 500, 19 ) ), + $this->equalTo( false ) + ); + + $chart->renderer = $mockedRenderer; + + $chart->render( 500, 200 ); + } + public function testRenderNumericAxisLabels() { $chart = ezcGraph::create( 'Line' ); |