summaryrefslogtreecommitdiffstats
path: root/tests/element_options_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-10-26 14:08:20 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-10-26 14:08:20 +0000
commitb6069cc0bfb2a7baaf2e79263cfc9c222d9e8299 (patch)
treea59d5e0b75fefd08ece3c927211f6f6e965e7933 /tests/element_options_test.php
parent7e56dbbe610469d173133cc6f2d19da5039079bb (diff)
downloadzetacomponents-graph-b6069cc0bfb2a7baaf2e79263cfc9c222d9e8299.zip
zetacomponents-graph-b6069cc0bfb2a7baaf2e79263cfc9c222d9e8299.tar.gz
- Added some more tests for read and write accesss on properties
Diffstat (limited to 'tests/element_options_test.php')
-rw-r--r--tests/element_options_test.php702
1 files changed, 702 insertions, 0 deletions
diff --git a/tests/element_options_test.php b/tests/element_options_test.php
new file mode 100644
index 0000000..60c1b25
--- /dev/null
+++ b/tests/element_options_test.php
@@ -0,0 +1,702 @@
+<?php
+/**
+ * ezcGraphElementOptionsTest
+ *
+ * @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 ezcGraphElementOptionsTest extends ezcImageTestCase
+{
+
+ public static function suite()
+ {
+ return new PHPUnit_Framework_TestSuite( "ezcGraphElementOptionsTest" );
+ }
+
+
+ public function testChartElementPropertyTitle()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ false,
+ $options->title,
+ 'Wrong default value for property title in class ezcGraphChartElementBackground'
+ );
+
+ $options->title = 'Title';
+ $this->assertSame(
+ 'Title',
+ $options->title,
+ 'Setting property value did not work for property title in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementPropertyBackground()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ false,
+ $options->background,
+ 'Wrong default value for property background in class ezcGraphChartElementBackground'
+ );
+
+ $options->background = $color = ezcGraphColor::fromHex( '#FFFFFF' );
+ $this->assertSame(
+ $color,
+ $options->background,
+ 'Setting property value did not work for property background in class ezcGraphChartElementBackground'
+ );
+
+ try
+ {
+ $options->background = false;
+ }
+ catch( ezcGraphUnknownColorDefinitionException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphUnknownColorDefinitionException.' );
+ }
+
+ public function testChartElementPropertyBoundings()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ 'ezcGraphBoundings',
+ get_class( $options->boundings ),
+ 'Wrong default value for property boundings in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementPropertyBorder()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ false,
+ $options->border,
+ 'Wrong default value for property border in class ezcGraphChartElementBackground'
+ );
+
+ $options->border = $color = ezcGraphColor::fromHex( '#FFFFFF' );
+ $this->assertSame(
+ $color,
+ $options->border,
+ 'Setting property value did not work for property border in class ezcGraphChartElementBackground'
+ );
+
+ try
+ {
+ $options->border = false;
+ }
+ catch( ezcGraphUnknownColorDefinitionException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphUnknownColorDefinitionException.' );
+ }
+
+ public function testChartElementPropertyPadding()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ 0,
+ $options->padding,
+ 'Wrong default value for property padding in class ezcGraphChartElementBackground'
+ );
+
+ $options->padding = 1;
+ $this->assertSame(
+ 1,
+ $options->padding,
+ 'Setting property value did not work for property padding in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementPropertyMargin()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ 0,
+ $options->margin,
+ 'Wrong default value for property margin in class ezcGraphChartElementBackground'
+ );
+
+ $options->margin = 1;
+ $this->assertSame(
+ 1,
+ $options->margin,
+ 'Setting property value did not work for property margin in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementPropertyBorderWidth()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ 0,
+ $options->borderWidth,
+ 'Wrong default value for property borderWidth in class ezcGraphChartElementBackground'
+ );
+
+ $options->borderWidth = 1;
+ $this->assertSame(
+ 1,
+ $options->borderWidth,
+ 'Setting property value did not work for property borderWidth in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementPropertyPosition()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ ezcGraph::LEFT,
+ $options->position,
+ 'Wrong default value for property position in class ezcGraphChartElementBackground'
+ );
+
+ $options->position = ezcGraph::RIGHT;
+ $this->assertSame(
+ ezcGraph::RIGHT,
+ $options->position,
+ 'Setting property value did not work for property position in class ezcGraphChartElementBackground'
+ );
+
+ try
+ {
+ $options->position = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testChartElementPropertyMaxTitleHeight()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ 16,
+ $options->maxTitleHeight,
+ 'Wrong default value for property maxTitleHeight in class ezcGraphChartElementBackground'
+ );
+
+ $options->maxTitleHeight = 20;
+ $this->assertSame(
+ 20,
+ $options->maxTitleHeight,
+ 'Setting property value did not work for property maxTitleHeight in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementPropertyPortraitTitleSize()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ .15,
+ $options->portraitTitleSize,
+ 'Wrong default value for property portraitTitleSize in class ezcGraphChartElementBackground'
+ );
+
+ $options->portraitTitleSize = .5;
+ $this->assertSame(
+ .5,
+ $options->portraitTitleSize,
+ 'Setting property value did not work for property portraitTitleSize in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementPropertyLandscapeTitleSize()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ .2,
+ $options->landscapeTitleSize,
+ 'Wrong default value for property landscapeTitleSize in class ezcGraphChartElementBackground'
+ );
+
+ $options->landscapeTitleSize = .5;
+ $this->assertSame(
+ .5,
+ $options->landscapeTitleSize,
+ 'Setting property value did not work for property landscapeTitleSize in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementPropertyFont()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ 'ezcGraphFontOptions',
+ get_class( $options->font ),
+ 'Wrong default value for property font in class ezcGraphChartElementBackground'
+ );
+
+ $fontOptions = new ezcGraphFontOptions();
+ $fontOptions->path = dirname( __FILE__ ) . '/data/font2.ttf';
+
+ $options->font = $fontOptions;
+ $this->assertSame(
+ $fontOptions,
+ $options->font,
+ 'Setting property value did not work for property font in class ezcGraphChartElementBackground'
+ );
+
+ try
+ {
+ $options->font = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testChartElementPropertyFontCloned()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ false,
+ $options->fontCloned,
+ 'Wrong default value for property fontCloned in class ezcGraphChartElementBackground'
+ );
+ }
+
+ public function testChartElementBackgroundPropertyImage()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ false,
+ $options->image,
+ 'Wrong default value for property image in class ezcGraphChartElementBackground'
+ );
+
+ $options->image = $file = dirname( __FILE__ ) . '/data/gif.gif';
+ $this->assertSame(
+ $file,
+ $options->image,
+ 'Setting property value did not work for property image in class ezcGraphChartElementBackground'
+ );
+
+ try
+ {
+ $options->image = false;
+ }
+ catch( ezcBaseFileNotFoundException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseFileNotFoundException.' );
+ }
+
+ public function testChartElementBackgroundPropertyRepeat()
+ {
+ $options = new ezcGraphChartElementBackground();
+
+ $this->assertSame(
+ ezcGraph::NO_REPEAT,
+ $options->repeat,
+ 'Wrong default value for property repeat in class ezcGraphChartElementBackground'
+ );
+
+ $options->repeat = ezcGraph::VERTICAL;
+ $this->assertSame(
+ ezcGraph::VERTICAL,
+ $options->repeat,
+ 'Setting property value did not work for property repeat in class ezcGraphChartElementBackground'
+ );
+
+ try
+ {
+ $options->repeat = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testChartElementLegendPropertyPortraitSize()
+ {
+ $options = new ezcGraphChartElementLegend();
+
+ $this->assertSame(
+ .2,
+ $options->portraitSize,
+ 'Wrong default value for property portraitSize in class ezcGraphChartElementLegend'
+ );
+
+ $options->portraitSize = .5;
+ $this->assertSame(
+ .5,
+ $options->portraitSize,
+ 'Setting property value did not work for property portraitSize in class ezcGraphChartElementLegend'
+ );
+ }
+
+ public function testChartElementLegendPropertyLandscapeSize()
+ {
+ $options = new ezcGraphChartElementLegend();
+
+ $this->assertSame(
+ .1,
+ $options->landscapeSize,
+ 'Wrong default value for property landscapeSize in class ezcGraphChartElementLegend'
+ );
+
+ $options->landscapeSize = .5;
+ $this->assertSame(
+ .5,
+ $options->landscapeSize,
+ 'Setting property value did not work for property landscapeSize in class ezcGraphChartElementLegend'
+ );
+ }
+
+ public function testChartElementLegendPropertySymbolSize()
+ {
+ $options = new ezcGraphChartElementLegend();
+
+ $this->assertSame(
+ 14,
+ $options->symbolSize,
+ 'Wrong default value for property symbolSize in class ezcGraphChartElementLegend'
+ );
+
+ $options->symbolSize = 20;
+ $this->assertSame(
+ 20,
+ $options->symbolSize,
+ 'Setting property value did not work for property symbolSize in class ezcGraphChartElementLegend'
+ );
+ }
+
+ public function testChartElementLegendPropertyMinimumSymbolSize()
+ {
+ $options = new ezcGraphChartElementLegend();
+
+ $this->assertSame(
+ .05,
+ $options->minimumSymbolSize,
+ 'Wrong default value for property minimumSymbolSize in class ezcGraphChartElementLegend'
+ );
+
+ $options->minimumSymbolSize = .1;
+ $this->assertSame(
+ .1,
+ $options->minimumSymbolSize,
+ 'Setting property value did not work for property minimumSymbolSize in class ezcGraphChartElementLegend'
+ );
+ }
+
+ public function testChartElementLegendPropertySpacing()
+ {
+ $options = new ezcGraphChartElementLegend();
+
+ $this->assertSame(
+ 2,
+ $options->spacing,
+ 'Wrong default value for property spacing in class ezcGraphChartElementLegend'
+ );
+
+ $options->spacing = 5;
+ $this->assertSame(
+ 5,
+ $options->spacing,
+ 'Setting property value did not work for property spacing in class ezcGraphChartElementLegend'
+ );
+ }
+
+ public function testChartElementAxisPropertyNullPosition()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ false,
+ $options->nullPosition,
+ 'Wrong default value for property nullPosition in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->nullPosition = .5;
+ $this->assertSame(
+ .5,
+ $options->nullPosition,
+ 'Setting property value did not work for property nullPosition in class ezcGraphChartElementNumericAxis'
+ );
+ }
+
+ public function testChartElementAxisPropertyAxisSpace()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ .1,
+ $options->axisSpace,
+ 'Wrong default value for property axisSpace in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->axisSpace = .2;
+ $this->assertSame(
+ .2,
+ $options->axisSpace,
+ 'Setting property value did not work for property axisSpace in class ezcGraphChartElementNumericAxis'
+ );
+ }
+
+ public function testChartElementAxisPropertyMajorGrid()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ false,
+ $options->majorGrid,
+ 'Wrong default value for property majorGrid in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->majorGrid = $color = ezcGraphColor::fromHex( '#FFFFFF' );
+ $this->assertSame(
+ $color,
+ $options->majorGrid,
+ 'Setting property value did not work for property majorGrid in class ezcGraphChartElementNumericAxis'
+ );
+
+ try
+ {
+ $options->majorGrid = false;
+ }
+ catch( ezcGraphUnknownColorDefinitionException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphUnknownColorDefinitionException.' );
+ }
+
+ public function testChartElementAxisPropertyMinorGrid()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ false,
+ $options->minorGrid,
+ 'Wrong default value for property minorGrid in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->minorGrid = $color = ezcGraphColor::fromHex( '#FFFFFF' );
+ $this->assertSame(
+ $color,
+ $options->minorGrid,
+ 'Setting property value did not work for property minorGrid in class ezcGraphChartElementNumericAxis'
+ );
+
+ try
+ {
+ $options->minorGrid = false;
+ }
+ catch( ezcGraphUnknownColorDefinitionException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphUnknownColorDefinitionException.' );
+ }
+
+ public function testChartElementAxisPropertyMajorStep()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ false,
+ $options->majorStep,
+ 'Wrong default value for property majorStep in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->majorStep = 1.;
+ $this->assertSame(
+ 1.,
+ $options->majorStep,
+ 'Setting property value did not work for property majorStep in class ezcGraphChartElementNumericAxis'
+ );
+
+ try
+ {
+ $options->majorStep = -1.;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testChartElementAxisPropertyMinorStep()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ false,
+ $options->minorStep,
+ 'Wrong default value for property minorStep in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->minorStep = 1.;
+ $this->assertSame(
+ 1.,
+ $options->minorStep,
+ 'Setting property value did not work for property minorStep in class ezcGraphChartElementNumericAxis'
+ );
+
+ try
+ {
+ $options->minorStep = -1.;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testChartElementAxisPropertyFormatString()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ '%s',
+ $options->formatString,
+ 'Wrong default value for property formatString in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->formatString = '[%s]';
+ $this->assertSame(
+ '[%s]',
+ $options->formatString,
+ 'Setting property value did not work for property formatString in class ezcGraphChartElementNumericAxis'
+ );
+ }
+
+ public function testChartElementAxisPropertyLabel()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ false,
+ $options->label,
+ 'Wrong default value for property label in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->label = 'Axis';
+ $this->assertSame(
+ 'Axis',
+ $options->label,
+ 'Setting property value did not work for property label in class ezcGraphChartElementNumericAxis'
+ );
+ }
+
+ public function testChartElementAxisPropertyLabelSize()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ 14,
+ $options->labelSize,
+ 'Wrong default value for property labelSize in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->labelSize = 20;
+ $this->assertSame(
+ 20,
+ $options->labelSize,
+ 'Setting property value did not work for property labelSize in class ezcGraphChartElementNumericAxis'
+ );
+ }
+
+ public function testChartElementAxisPropertyLabelMargin()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ 2,
+ $options->labelMargin,
+ 'Wrong default value for property labelMargin in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->labelMargin = 1;
+ $this->assertSame(
+ 1,
+ $options->labelMargin,
+ 'Setting property value did not work for property labelMargin in class ezcGraphChartElementNumericAxis'
+ );
+ }
+
+ public function testChartElementAxisPropertyMaxArrowHeadSize()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ 8,
+ $options->maxArrowHeadSize,
+ 'Wrong default value for property maxArrowHeadSize in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->maxArrowHeadSize = 10;
+ $this->assertSame(
+ 10,
+ $options->maxArrowHeadSize,
+ 'Setting property value did not work for property maxArrowHeadSize in class ezcGraphChartElementNumericAxis'
+ );
+ }
+
+ public function testChartElementTextPropertyMaxHeight()
+ {
+ $options = new ezcGraphChartElementText();
+
+ $this->assertSame(
+ 0.1,
+ $options->maxHeight,
+ 'Wrong default value for property maxHeight in class ezcGraphChartElementText'
+ );
+
+ $options->maxHeight = .2;
+ $this->assertSame(
+ .2,
+ $options->maxHeight,
+ 'Setting property value did not work for property maxHeight in class ezcGraphChartElementText'
+ );
+ }
+}
+?>
OpenPOWER on IntegriCloud