summaryrefslogtreecommitdiffstats
path: root/tests/renderer_2d_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-05-29 11:28:30 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-05-29 11:28:30 +0000
commit2942447b30b3be16ec869a40087ed6e79ed330e0 (patch)
tree762f8a0f86296ced69d23581623092f09af3b91d /tests/renderer_2d_test.php
parent89a8010b0b0869d07cb1d433351a1334bf232c57 (diff)
downloadzetacomponents-graph-2942447b30b3be16ec869a40087ed6e79ed330e0.zip
zetacomponents-graph-2942447b30b3be16ec869a40087ed6e79ed330e0.tar.gz
- Added basic 2d renderer test
- Implemented tested 2d renderer functions
Diffstat (limited to 'tests/renderer_2d_test.php')
-rw-r--r--tests/renderer_2d_test.php225
1 files changed, 225 insertions, 0 deletions
diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php
new file mode 100644
index 0000000..9be5df6
--- /dev/null
+++ b/tests/renderer_2d_test.php
@@ -0,0 +1,225 @@
+<?php
+/**
+ * ezcGraphRenderer2dTest
+ *
+ * @package Graph
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Tests for ezcGraph class.
+ *
+ * @package ImageAnalysis
+ * @subpackage Tests
+ */
+class ezcGraphRenderer2dTest extends ezcTestCase
+{
+
+ protected $renderer;
+
+ protected $driver;
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcGraphRenderer2dTest" );
+ }
+
+ /**
+ * setUp
+ *
+ * @access public
+ */
+ public function setUp()
+ {
+ try
+ {
+ $this->renderer = new ezcGraphRenderer2D();
+
+ $this->driver = $this->getMock( 'ezcGraphGdDriver', array(
+ 'drawPolygon',
+ 'drawLine',
+ 'drawTextBox',
+ 'drawCircleSector',
+ 'drawCircularArc',
+ 'drawCircle',
+ 'drawImage',
+ ) );
+ $this->renderer->setDriver( $this->driver );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+ }
+
+ /**
+ * tearDown
+ *
+ * @access public
+ */
+ public function tearDown()
+ {
+ $this->driver->verify();
+ }
+
+ public function testRenderLine()
+ {
+ $this->driver
+ ->expects( $this->once() )
+ ->method( 'drawLine' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 100, 100 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 113, 157 ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) )
+ );
+
+ $this->renderer->drawLine(
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( 100, 100 ),
+ new ezcGraphCoordinate( 113, 157 )
+ );
+ }
+
+ public function testRenderTextBox()
+ {
+ $this->driver
+ ->expects( $this->once() )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( 'Drawing TextBox' ),
+ $this->equalTo( new ezcGraphCoordinate( 100, 100 ) ),
+ $this->equalTo( 100 ),
+ $this->equalTo( 50 ),
+ $this->equalTo( ezcGraph::LEFT )
+ );
+
+ $this->renderer->drawTextBox(
+ new ezcGraphCoordinate( 100, 100 ),
+ 'Drawing TextBox',
+ 100,
+ 50
+ );
+ }
+
+ public function testRenderSymbolNone()
+ {
+ $this->driver
+ ->expects( $this->once() )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 100, 100 ),
+ new ezcGraphCoordinate( 120, 100 ),
+ new ezcGraphCoordinate( 120, 120 ),
+ new ezcGraphCoordinate( 100, 120 ),
+ ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ true
+ );
+
+ $this->renderer->drawSymbol(
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( 100, 100 ),
+ 20,
+ 20
+ );
+ }
+
+ public function testRenderSymbolDiamond()
+ {
+ $this->driver
+ ->expects( $this->once() )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 110, 100 ),
+ new ezcGraphCoordinate( 120, 110 ),
+ new ezcGraphCoordinate( 110, 120 ),
+ new ezcGraphCoordinate( 100, 110 ),
+ ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ true
+ );
+
+ $this->renderer->drawSymbol(
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( 100, 100 ),
+ 20,
+ 20,
+ ezcGraph::DIAMOND
+ );
+ }
+
+ public function testRenderSymbolBullet()
+ {
+ $this->driver
+ ->expects( $this->once() )
+ ->method( 'drawCircle' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 110, 110 ) ),
+ $this->equalTo( 20 ),
+ $this->equalTo( 20 ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( true )
+ );
+
+ $this->renderer->drawSymbol(
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( 100, 100 ),
+ 20,
+ 20,
+ ezcGraph::BULLET
+ );
+ }
+
+ public function testRenderSymbolCircle()
+ {
+ $this->driver
+ ->expects( $this->once() )
+ ->method( 'drawCircle' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 110, 110 ) ),
+ $this->equalTo( 20 ),
+ $this->equalTo( 20 ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ $this->equalTo( false )
+ );
+
+ $this->renderer->drawSymbol(
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( 100, 100 ),
+ 20,
+ 20,
+ ezcGraph::CIRCLE
+ );
+ }
+
+ public function testRenderBackground()
+ {
+ $this->driver
+ ->expects( $this->once() )
+ ->method( 'drawPolygon' )
+ ->with(
+ $this->equalTo( array(
+ new ezcGraphCoordinate( 100, 100 ),
+ new ezcGraphCoordinate( 150, 100 ),
+ new ezcGraphCoordinate( 150, 150 ),
+ new ezcGraphCoordinate( 100, 150 ),
+ ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
+ true
+ );
+
+ $this->renderer->drawBackground(
+ ezcGraphColor::fromHex( '#FF0000' ),
+ new ezcGraphCoordinate( 100, 100 ),
+ 50,
+ 50
+ );
+ }
+}
+?>
+
OpenPOWER on IntegriCloud