summaryrefslogtreecommitdiffstats
path: root/tests/text_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-06-02 15:20:41 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-06-02 15:20:41 +0000
commit0ddff83b14071fb8694f0179de023d700952cb32 (patch)
tree3584f944972f6ebd85477b5e913a014d04e71ef4 /tests/text_test.php
parentb6efb38bbd2ef8d9f9ac110b852ac36711b8c7a7 (diff)
downloadzetacomponents-graph-0ddff83b14071fb8694f0179de023d700952cb32.zip
zetacomponents-graph-0ddff83b14071fb8694f0179de023d700952cb32.tar.gz
- Added tests and implementation for text elements eg. chart title
Diffstat (limited to 'tests/text_test.php')
-rw-r--r--tests/text_test.php118
1 files changed, 118 insertions, 0 deletions
diff --git a/tests/text_test.php b/tests/text_test.php
new file mode 100644
index 0000000..08bad2a
--- /dev/null
+++ b/tests/text_test.php
@@ -0,0 +1,118 @@
+<?php
+/**
+ * ezcGraphTextTest
+ *
+ * @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 ezcGraphTextTest extends ezcTestCase
+{
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcGraphTextTest" );
+ }
+
+ /**
+ * setUp
+ *
+ * @access public
+ */
+ public function setUp()
+ {
+ }
+
+ /**
+ * tearDown
+ *
+ * @access public
+ */
+ public function tearDown()
+ {
+ }
+
+ public function testRenderTextTop()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 'foo' => 1, 'bar' => 10 );
+ $chart->sample->color = '#FF0000';
+
+ $chart->title = 'Title of a chart';
+
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ 'drawTextBox',
+ ) );
+
+ // Y-Axis
+ $mockedRenderer
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 2, 2 ) ),
+ $this->equalTo( 'Title of a chart' ),
+ $this->equalTo( 496 ),
+ $this->equalTo( 16 ),
+ $this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
+ );
+
+ $chart->renderer = $mockedRenderer;
+
+ $chart->render( 500, 200 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+ }
+
+ public function testRenderTextBottom()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 'foo' => 1, 'bar' => 10 );
+ $chart->sample->color = '#FF0000';
+
+ $chart->title = 'Title of a chart';
+ $chart->title->position = ezcGraph::BOTTOM;
+
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ 'drawTextBox',
+ ) );
+
+ // Y-Axis
+ $mockedRenderer
+ ->expects( $this->at( 0 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 2, 182 ) ),
+ $this->equalTo( 'Title of a chart' ),
+ $this->equalTo( 496 ),
+ $this->equalTo( 16 ),
+ $this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
+ );
+
+ $chart->renderer = $mockedRenderer;
+
+ $chart->render( 500, 200 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+ }
+}
+
+?>
OpenPOWER on IntegriCloud