summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-11-02 16:05:45 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-11-02 16:05:45 +0000
commit5bdf51ead2a5e1dfb683c56df48e3d887e743472 (patch)
tree7e39889aca43eff30617df44f5bb567be94035f9
parent39d55ef60b9074920a1a3fc3d0c0f8d51f303760 (diff)
downloadzetacomponents-graph-5bdf51ead2a5e1dfb683c56df48e3d887e743472.zip
zetacomponents-graph-5bdf51ead2a5e1dfb683c56df48e3d887e743472.tar.gz
- Throw ezcBaseValueExceptions instead of typecasting
- Do range checks instead of converting numbers using min and max - Extended testcases to test for ezcBaseValueExceptions
-rw-r--r--src/axis/numeric.php38
-rw-r--r--src/colors/color.php15
-rw-r--r--src/colors/radial_gradient.php21
-rw-r--r--src/datasets/average.php14
-rw-r--r--src/element/axis.php45
-rw-r--r--src/element/legend.php51
-rw-r--r--src/element/text.php9
-rw-r--r--src/interfaces/axis_label_renderer.php50
-rw-r--r--src/interfaces/chart.php5
-rw-r--r--src/interfaces/element.php50
-rw-r--r--src/interfaces/palette.php10
-rw-r--r--src/options/chart.php20
-rw-r--r--src/options/driver.php38
-rw-r--r--src/options/font.php48
-rw-r--r--src/options/gd_driver.php38
-rw-r--r--src/options/line_chart.php37
-rw-r--r--src/options/ming_driver.php13
-rw-r--r--src/options/pie_chart.php23
-rw-r--r--src/options/renderer.php103
-rw-r--r--src/options/renderer_2d.php17
-rw-r--r--src/options/renderer_3d.php73
-rw-r--r--src/options/svg_driver.php16
-rw-r--r--src/renderer/axis_label_centered.php5
-rw-r--r--src/renderer/axis_label_exact.php5
-rw-r--r--tests/axis_centered_renderer_test.php29
-rw-r--r--tests/axis_exact_renderer_test.php261
-rw-r--r--tests/color_test.php195
-rw-r--r--tests/dataset_average_test.php62
-rw-r--r--tests/driver_gd_test.php55
-rw-r--r--tests/driver_ming_test.php22
-rw-r--r--tests/driver_options_test.php48
-rw-r--r--tests/driver_svg_test.php22
-rw-r--r--tests/element_options_test.php176
-rw-r--r--tests/font_test.php77
-rw-r--r--tests/line_test.php73
-rw-r--r--tests/numeric_axis_test.php59
-rw-r--r--tests/palette_test.php130
-rw-r--r--tests/pie_test.php33
-rw-r--r--tests/renderer_2d_test.php247
-rw-r--r--tests/renderer_3d_test.php125
40 files changed, 2165 insertions, 193 deletions
diff --git a/src/axis/numeric.php b/src/axis/numeric.php
index bd4ae58..bb62ff1 100644
--- a/src/axis/numeric.php
+++ b/src/axis/numeric.php
@@ -19,10 +19,10 @@
* Minimum value of displayed scale on axis.
* @property float $max
* Maximum value of displayed scale on axis.
- * @property float $minValue
- * Minimum Value to display on this axis.
- * @property float $maxValue
- * Maximum value to display on this axis.
+ * @property-read float $minValue
+ * Minimum Value to display on this axis.
+ * @property-read float $maxValue
+ * Maximum value to display on this axis.
*
* @package Graph
*/
@@ -50,10 +50,10 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
*/
public function __construct( array $options = array() )
{
- $this->properties['min'] = false;
- $this->properties['max'] = false;
- $this->properties['minValue'] = false;
- $this->properties['maxValue'] = false;
+ $this->properties['min'] = null;
+ $this->properties['max'] = null;
+ $this->properties['minValue'] = null;
+ $this->properties['maxValue'] = null;
parent::__construct( $options );
}
@@ -75,9 +75,19 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
switch ( $propertyName )
{
case 'min':
+ if ( !is_numeric( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float' );
+ }
+
$this->properties['min'] = (float) $propertyValue;
break;
case 'max':
+ if ( !is_numeric( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float' );
+ }
+
$this->properties['max'] = (float) $propertyValue;
break;
default:
@@ -192,13 +202,13 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
{
foreach ( $values as $value )
{
- if ( $this->properties['minValue'] === false ||
+ if ( $this->properties['minValue'] === null ||
$value < $this->properties['minValue'] )
{
$this->properties['minValue'] = $value;
}
- if ( $this->properties['maxValue'] === false ||
+ if ( $this->properties['maxValue'] === null ||
$value > $this->properties['maxValue'] )
{
$this->properties['maxValue'] = $value;
@@ -230,12 +240,12 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
}
// Use custom minimum and maximum if available
- if ( $this->properties['min'] !== false )
+ if ( $this->properties['min'] !== null )
{
$this->properties['minValue'] = $this->properties['min'];
}
- if ( $this->properties['max'] !== false )
+ if ( $this->properties['max'] !== null )
{
$this->properties['maxValue'] = $this->properties['max'];
}
@@ -251,12 +261,12 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
$this->calculateMinorStep( $this->properties['minValue'], $this->properties['maxValue'] );
}
- if ( $this->properties['min'] === false )
+ if ( $this->properties['min'] === null )
{
$this->calculateMinimum( $this->properties['minValue'], $this->properties['maxValue'] );
}
- if ( $this->properties['max'] === false )
+ if ( $this->properties['max'] === null )
{
$this->calculateMaximum( $this->properties['minValue'], $this->properties['maxValue'] );
}
diff --git a/src/colors/color.php b/src/colors/color.php
index 688621c..ef4c14e 100644
--- a/src/colors/color.php
+++ b/src/colors/color.php
@@ -65,7 +65,14 @@ class ezcGraphColor extends ezcBaseOptions
case 'green':
case 'blue':
case 'alpha':
- $this->properties[$propertyName] = max( 0, min( 255, (int) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 255 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 255' );
+ }
+
+ $this->properties[$propertyName] = (int) $propertyValue;
break;
default:
throw new ezcBasePropertyNotFoundException( $propertyName );
@@ -250,9 +257,9 @@ class ezcGraphColor extends ezcBaseOptions
$color = clone $this;
$value = 1 - $value;
- $color->red = (int) round( $this->red * $value );
- $color->green = (int) round( $this->green * $value );
- $color->blue = (int) round( $this->blue * $value );
+ $color->red = min( 255, max( 0, (int) round( $this->red * $value ) ) );
+ $color->green = min( 255, max( 0, (int) round( $this->green * $value ) ) );
+ $color->blue = min( 255, max( 0, (int) round( $this->blue * $value ) ) );
return $color;
}
diff --git a/src/colors/radial_gradient.php b/src/colors/radial_gradient.php
index bbc28c2..f7157f9 100644
--- a/src/colors/radial_gradient.php
+++ b/src/colors/radial_gradient.php
@@ -77,13 +77,32 @@ class ezcGraphRadialGradient extends ezcGraphColor
}
break;
case 'width':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
$this->properties['width'] = (float) $propertyValue;
break;
case 'height':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
$this->properties['height'] = (float) $propertyValue;
break;
case 'offset':
- $this->properties['offset'] = min( 1., max( 0., (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['offset'] = $propertyValue;
break;
case 'startColor':
$this->properties['startColor'] = ezcGraphColor::create( $propertyValue );
diff --git a/src/datasets/average.php b/src/datasets/average.php
index 33dfa71..0f4e4f1 100644
--- a/src/datasets/average.php
+++ b/src/datasets/average.php
@@ -96,11 +96,23 @@ class ezcGraphDataSetAveragePolynom extends ezcGraphDataSet
{
switch ( $propertyName ) {
case 'polynomOrder':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int > 0' );
+ }
+
$this->properties['polynomOrder'] = (int) $propertyValue;
$this->polynom = false;
break;
case 'resolution':
- $this->properties['resolution'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int > 1' );
+ }
+
+ $this->properties['resolution'] = (int) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
diff --git a/src/element/axis.php b/src/element/axis.php
index edcefb1..cdcd26c 100644
--- a/src/element/axis.php
+++ b/src/element/axis.php
@@ -110,7 +110,14 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
$this->properties['nullPosition'] = (float) $propertyValue;
break;
case 'axisSpace':
- $this->properties['axisSpace'] = min( 1, max( 0, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['axisSpace'] = (float) $propertyValue;
break;
case 'majorGrid':
$this->properties['majorGrid'] = ezcGraphColor::create( $propertyValue );
@@ -119,17 +126,21 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
$this->properties['minorGrid'] = ezcGraphColor::create( $propertyValue );
break;
case 'majorStep':
- if ( $propertyValue <= 0 )
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
{
- throw new ezcBaseValueException( 'majorStep', $propertyValue, 'float > 0' );
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
+
$this->properties['majorStep'] = (float) $propertyValue;
break;
case 'minorStep':
- if ( $propertyValue <= 0 )
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
{
- throw new ezcBaseValueException( 'minorStep', $propertyValue, 'float > 0' );
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
}
+
$this->properties['minorStep'] = (float) $propertyValue;
break;
case 'formatString':
@@ -139,13 +150,31 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
$this->properties['label'] = (string) $propertyValue;
break;
case 'labelSize':
- $this->properties['labelSize'] = max( 6, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 6 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 6' );
+ }
+
+ $this->properties['labelSize'] = (int) $propertyValue;
break;
case 'labelMargin':
- $this->properties['labelMargin'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['labelMargin'] = (int) $propertyValue;
break;
case 'maxArrowHeadSize':
- $this->properties['maxArrowHeadSize'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['maxArrowHeadSize'] = (int) $propertyValue;
break;
case 'axisLabelRenderer':
if ( $propertyValue instanceof ezcGraphAxisLabelRenderer )
diff --git a/src/element/legend.php b/src/element/legend.php
index d9953b5..95e9cae 100644
--- a/src/element/legend.php
+++ b/src/element/legend.php
@@ -80,22 +80,61 @@ class ezcGraphChartElementLegend extends ezcGraphChartElement
switch ( $propertyName )
{
case 'padding':
- $this->properties['padding'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['padding'] = (int) $propertyValue;
break;
case 'symbolSize':
- $this->properties['symbolSize'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['symbolSize'] = (int) $propertyValue;
break;
case 'landscapeSize':
- $this->properties['landscapeSize'] = max( 0, min( 1, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 1' );
+ }
+
+ $this->properties['landscapeSize'] = (float) $propertyValue;
break;
case 'portraitSize':
- $this->properties['portraitSize'] = max( 0, min( 1, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 1' );
+ }
+
+ $this->properties['portraitSize'] = (float) $propertyValue;
break;
case 'minimumSymbolSize':
- $this->properties['minimumSymbolSize'] = max( 0, min( 1, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 1' );
+ }
+
+ $this->properties['minimumSymbolSize'] = (float) $propertyValue;
break;
case 'spacing':
- $this->properties['spacing'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['spacing'] = (int) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
diff --git a/src/element/text.php b/src/element/text.php
index 4792468..66b0b19 100644
--- a/src/element/text.php
+++ b/src/element/text.php
@@ -47,7 +47,14 @@ class ezcGraphChartElementText extends ezcGraphChartElement
switch ( $propertyName )
{
case 'maxHeight':
- $this->properties['maxHeight'] = min( 1, max( 0, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['maxHeight'] = (float) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
diff --git a/src/interfaces/axis_label_renderer.php b/src/interfaces/axis_label_renderer.php
index 1a8e295..8df4e27 100644
--- a/src/interfaces/axis_label_renderer.php
+++ b/src/interfaces/axis_label_renderer.php
@@ -88,26 +88,76 @@ abstract class ezcGraphAxisLabelRenderer extends ezcBaseOptions
}
break;
case 'majorStepCount':
+ if ( ( $propertyValue !== false ) &&
+ !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
$this->properties['majorStepCount'] = (int) $propertyValue;
break;
case 'minorStepCount':
+ if ( ( $propertyValue !== false ) &&
+ !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
$this->properties['minorStepCount'] = (int) $propertyValue;
break;
case 'majorStepSize':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
$this->properties['majorStepSize'] = (int) $propertyValue;
break;
case 'minorStepSize':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
$this->properties['minorStepSize'] = (int) $propertyValue;
break;
case 'innerStep':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
$this->properties['innerStep'] = (bool) $propertyValue;
break;
case 'outerStep':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
$this->properties['outerStep'] = (bool) $propertyValue;
break;
case 'outerGrid':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
$this->properties['outerGrid'] = (bool) $propertyValue;
break;
+ case 'labelPadding':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['labelPadding'] = (int) $propertyValue;
+ break;
default:
throw new ezcBasePropertyNotFoundException( $propertyName );
}
diff --git a/src/interfaces/chart.php b/src/interfaces/chart.php
index 12c8241..d33c086 100644
--- a/src/interfaces/chart.php
+++ b/src/interfaces/chart.php
@@ -134,6 +134,11 @@ abstract class ezcGraphChart
$this->renderElement['title'] = true;
break;
case 'legend':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'boolean' );
+ }
+
$this->renderElement['legend'] = (bool) $propertyValue;
break;
case 'renderer':
diff --git a/src/interfaces/element.php b/src/interfaces/element.php
index c78ff86..6ace63c 100644
--- a/src/interfaces/element.php
+++ b/src/interfaces/element.php
@@ -112,13 +112,31 @@ abstract class ezcGraphChartElement extends ezcBaseOptions
$this->properties['border'] = ezcGraphColor::create( $propertyValue );
break;
case 'padding':
- $this->properties['padding'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['padding'] = (int) $propertyValue;
break;
case 'margin':
- $this->properties['margin'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['margin'] = (int) $propertyValue;
break;
case 'borderWidth':
- $this->properties['borderWidth'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['borderWidth'] = (int) $propertyValue;
break;
case 'font':
if ( $propertyValue instanceof ezcGraphFontOptions )
@@ -158,13 +176,33 @@ abstract class ezcGraphChartElement extends ezcBaseOptions
}
break;
case 'maxTitleHeight':
- $this->properties['maxTitleHeight'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties['maxTitleHeight'] = (int) $propertyValue;
break;
case 'portraitTitleSize':
- $this->properties['portraitTitleSize'] = max( 0., min( 1., (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['portraitTitleSize'] = (float) $propertyValue;
break;
case 'landscapeTitleSize':
- $this->properties['landscapeTitleSize'] = max( 0., min( 1., (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['landscapeTitleSize'] = (float) $propertyValue;
break;
default:
throw new ezcBasePropertyNotFoundException( $propertyName );
diff --git a/src/interfaces/palette.php b/src/interfaces/palette.php
index 1cab18b..fdd0681 100644
--- a/src/interfaces/palette.php
+++ b/src/interfaces/palette.php
@@ -9,7 +9,7 @@
*/
/**
* Abstract class to contain pallet definitions
- *
+ *
* @package Graph
*/
abstract class ezcGraphPalette
@@ -253,7 +253,13 @@ abstract class ezcGraphPalette
case 'elementBorderWidth':
case 'padding':
case 'margin':
- $this->$propertyName = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->$propertyName = (int) $propertyValue;
break;
default:
diff --git a/src/options/chart.php b/src/options/chart.php
index 4d6139d..ae9bd9f 100644
--- a/src/options/chart.php
+++ b/src/options/chart.php
@@ -23,8 +23,8 @@ class ezcGraphChartOptions extends ezcBaseOptions
{
public function __construct( array $options = array() )
{
- $this->properties['width'] = false;
- $this->properties['height'] = false;
+ $this->properties['width'] = null;
+ $this->properties['height'] = null;
$this->properties['font'] = new ezcGraphFontOptions();
parent::__construct( $options );
@@ -44,10 +44,22 @@ class ezcGraphChartOptions extends ezcBaseOptions
switch ( $propertyName )
{
case 'width':
- $this->properties['width'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['width'] = (int) $propertyValue;
break;
case 'height':
- $this->properties['height'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['height'] = (int) $propertyValue;
break;
case 'font':
$this->properties['font']->path = $propertyValue;
diff --git a/src/options/driver.php b/src/options/driver.php
index d95b490..da6717a 100644
--- a/src/options/driver.php
+++ b/src/options/driver.php
@@ -34,8 +34,8 @@ abstract class ezcGraphDriverOptions extends ezcBaseOptions
*/
public function __construct( array $options = array() )
{
- $this->properties['width'] = false;
- $this->properties['height'] = false;
+ $this->properties['width'] = null;
+ $this->properties['height'] = null;
$this->properties['lineSpacing'] = .1;
$this->properties['shadeCircularArc'] = .5;
@@ -59,16 +59,42 @@ abstract class ezcGraphDriverOptions extends ezcBaseOptions
switch ( $propertyName )
{
case 'width':
- $this->properties['width'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['width'] = (int) $propertyValue;
break;
case 'height':
- $this->properties['height'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['height'] = (int) $propertyValue;
break;
case 'lineSpacing':
- $this->properties['lineSpacing'] = max( 0, min( 1, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['lineSpacing'] = (float) $propertyValue;
break;
case 'shadeCircularArc':
- $this->properties['shadeCircularArc'] = max( 0, min( 1, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['shadeCircularArc'] = (float) $propertyValue;
break;
case 'font':
if ( $propertyValue instanceof ezcGraphFontOptions )
diff --git a/src/options/font.php b/src/options/font.php
index 0a0f135..0f6a3d8 100644
--- a/src/options/font.php
+++ b/src/options/font.php
@@ -97,11 +97,16 @@ class ezcGraphFontOptions extends ezcBaseOptions
switch ( $propertyName )
{
case 'minFontSize':
- $this->properties['minFontSize'] = max( 1, (float) $propertyValue );
- break;
case 'maxFontSize':
- $this->properties['maxFontSize'] = max( 1, (float) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 1' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
+
case 'minimalUsedFont':
$propertyValue = (float) $propertyValue;
if ( $propertyValue < $this->minimalUsedFont )
@@ -109,34 +114,33 @@ class ezcGraphFontOptions extends ezcBaseOptions
$this->properties['minimalUsedFont'] = $propertyValue;
}
break;
- case 'color':
- $this->properties['color'] = ezcGraphColor::create( $propertyValue );
- break;
+ case 'color':
case 'background':
- $this->properties['background'] = ezcGraphColor::create( $propertyValue );
- break;
case 'border':
- $this->properties['border'] = ezcGraphColor::create( $propertyValue );
+ case 'textShadowColor':
+ $this->properties[$propertyName] = ezcGraphColor::create( $propertyValue );
break;
+
case 'borderWidth':
- $this->properties['borderWidth'] = (int) $propertyValue;
- break;
case 'padding':
- $this->properties['padding'] = (int) $propertyValue;
+ case 'textShadowOffset':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties[$propertyName] = (int) $propertyValue;
break;
+
case 'minimizeBorder':
- $this->properties['minimizeBorder'] = (bool) $propertyValue;
- break;
-
case 'textShadow':
- $this->properties['textShadow'] = (bool) $propertyValue;
- break;
- case 'textShadowOffset':
- $this->properties['textShadowOffset'] = max( 0, (int) $propertyValue );
- break;
- case 'textShadowColor':
- $this->properties['textShadowColor'] = ezcGraphColor::create( $propertyValue );
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+ $this->properties[$propertyName] = (bool) $propertyValue;
break;
case 'name':
diff --git a/src/options/gd_driver.php b/src/options/gd_driver.php
index f4eec06..37000f7 100644
--- a/src/options/gd_driver.php
+++ b/src/options/gd_driver.php
@@ -79,13 +79,32 @@ class ezcGraphGdDriverOptions extends ezcGraphDriverOptions
}
break;
case 'jpegQuality':
- $this->properties['jpegQuality'] = max( 0, min( 100, (int) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 100 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 100' );
+ }
+
+ $this->properties['jpegQuality'] = (int) $propertyValue;
break;
case 'detail':
- $this->properties['detail'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['detail'] = (int) $propertyValue;
break;
case 'supersampling':
- $this->properties['supersampling'] = (int) max( 1, $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['supersampling'] = (int) $propertyValue;
break;
case 'background':
if ( $propertyValue === false ||
@@ -109,10 +128,21 @@ class ezcGraphGdDriverOptions extends ezcGraphDriverOptions
}
break;
case 'forceNativeTTF':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
$this->properties['forceNativeTTF'] = (bool) $propertyValue;
break;
case 'imageMapResolution':
- $this->properties['imageMapResolution'] = max( 1, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
+ }
+
+ $this->properties['imageMapResolution'] = (int) $propertyValue;
break;
default:
parent::__set( $propertyName, $propertyValue );
diff --git a/src/options/line_chart.php b/src/options/line_chart.php
index c8497ac..197202a 100644
--- a/src/options/line_chart.php
+++ b/src/options/line_chart.php
@@ -64,20 +64,29 @@ class ezcGraphLineChartOptions extends ezcGraphChartOptions
switch ( $propertyName )
{
case 'lineThickness':
- $this->properties['lineThickness'] = max( 1, (int) $propertyValue );
- break;
- case 'fillLines':
- if ( $propertyValue === false )
+ case 'symbolSize':
+ case 'highlightSize':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 1 ) )
{
- $this->properties['fillLines'] = false;
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 1' );
}
- else
+
+ $this->properties[$propertyName] = (int) $propertyValue;
+ break;
+ case 'fillLines':
+ if ( ( $propertyValue !== false ) &&
+ !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 255 ) )
{
- $this->properties['fillLines'] = min( 255, max( 0, (int) $propertyValue ) );
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= int <= 255' );
}
- break;
- case 'symbolSize':
- $this->properties['symbolSize'] = max( 1, (int) $propertyValue );
+
+ $this->properties[$propertyName] = (
+ $propertyValue === false
+ ? false
+ : (int) $propertyValue );
break;
case 'highlightFont':
if ( $propertyValue instanceof ezcGraphFontOptions )
@@ -99,11 +108,15 @@ class ezcGraphLineChartOptions extends ezcGraphChartOptions
throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphFontOptions' );
}
break;
- case 'highlightSize':
$this->properties['highlightSize'] = max( 1, (int) $propertyValue );
break;
case 'highlightLines':
- $this->properties['highlightLines'] = (bool) $propertyValue;
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
+ $this->properties['highlightLines'] = $propertyValue;
break;
default:
return parent::__set( $propertyName, $propertyValue );
diff --git a/src/options/ming_driver.php b/src/options/ming_driver.php
index 4e5d1cd..78a9ade 100644
--- a/src/options/ming_driver.php
+++ b/src/options/ming_driver.php
@@ -51,9 +51,22 @@ class ezcGraphMingDriverOptions extends ezcGraphDriverOptions
switch ( $propertyName )
{
case 'compression':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 9 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= int <= 9' );
+ }
+
$this->properties['compression'] = max( 0, min( 9, (int) $propertyValue ) );
break;
case 'circleResolution':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
$this->properties['circleResolution'] = (float) $propertyValue;
break;
default:
diff --git a/src/options/pie_chart.php b/src/options/pie_chart.php
index 5974a2d..c52a173 100644
--- a/src/options/pie_chart.php
+++ b/src/options/pie_chart.php
@@ -82,13 +82,32 @@ class ezcGraphPieChartOptions extends ezcGraphChartOptions
}
break;
case 'sum':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
$this->properties['sum'] = (float) $propertyValue;
break;
case 'percentTreshHold':
- $this->properties['percentTreshHold'] = max( .0, (float) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['percentTreshHold'] = (float) $propertyValue;
break;
case 'absoluteTreshHold':
- $this->properties['absoluteTreshHold'] = max( .0, (float) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
+ $this->properties['absoluteTreshHold'] = (float) $propertyValue;
break;
case 'summarizeCaption':
$this->properties['summarizeCaption'] = (string) $propertyValue;
diff --git a/src/options/renderer.php b/src/options/renderer.php
index 0438730..4940026 100644
--- a/src/options/renderer.php
+++ b/src/options/renderer.php
@@ -103,63 +103,78 @@ class ezcGraphRendererOptions extends ezcGraphChartOptions
{
switch ( $propertyName )
{
- case 'maxLabelHeight':
- $this->properties['maxLabelHeight'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'symbolSize':
- $this->properties['symbolSize'] = (int) $propertyValue;
+ case 'dataBorder':
+ case 'pieChartGleam':
+ case 'legendSymbolGleam':
+ if ( $propertyValue !== false &&
+ !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= float <= 1' );
+ }
+
+ $this->properties[$propertyName] = (
+ $propertyValue === false
+ ? false
+ : (float) $propertyValue );
break;
+
+ case 'maxLabelHeight':
case 'moveOut':
- $this->properties['moveOut'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'showSymbol':
- $this->properties['showSymbol'] = (bool) $propertyValue;
+ case 'barMargin':
+ case 'barPadding':
+ case 'legendSymbolGleamSize':
+ case 'pieVerticalSize':
+ case 'pieHorizontalSize':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
+
+ case 'symbolSize':
case 'titlePosition':
- $this->properties['titlePosition'] = (int) $propertyValue;
- break;
case 'titleAlignement':
- $this->properties['titleAlignement'] = (int) $propertyValue;
- break;
- case 'dataBorder':
- $this->properties['dataBorder'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'barMargin':
- $this->properties['barMargin'] = min( 1., max( .0, (float) $propertyValue ) );
+ case 'pieChartGleamBorder':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'int >= 0' );
+ }
+
+ $this->properties[$propertyName] = (int) $propertyValue;
break;
- case 'barPadding':
- $this->properties['barPadding'] = min( 1., max( .0, (float) $propertyValue ) );
+
+ case 'showSymbol':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+ $this->properties['showSymbol'] = (bool) $propertyValue;
break;
+
case 'pieChartOffset':
- $this->properties['pieChartOffset'] = $propertyValue % 360;
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 360 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 360' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
+
case 'pieChartSymbolColor':
- $this->properties['pieChartSymbolColor'] = ezcGraphColor::create( $propertyValue );
- break;
- case 'pieChartGleam':
- $this->properties['pieChartGleam'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
case 'pieChartGleamColor':
- $this->properties['pieChartGleamColor'] = ezcGraphColor::create( $propertyValue );
- break;
- case 'pieChartGleamBorder':
- $this->properties['pieChartGleamBorder'] = max( 0, (int) $propertyValue );
- break;
- case 'legendSymbolGleam':
- $this->properties['legendSymbolGleam'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'legendSymbolGleamSize':
- $this->properties['legendSymbolGleamSize'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
case 'legendSymbolGleamColor':
- $this->properties['legendSymbolGleamColor'] = ezcGraphColor::create( $propertyValue );
- break;
- case 'pieVerticalSize':
- $this->properties['pieVerticalSize'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'pieHorizontalSize':
- $this->properties['pieHorizontalSize'] = min( 1., max( .0, (float) $propertyValue ) );
+ $this->properties[$propertyName] = ezcGraphColor::create( $propertyValue );
break;
+
default:
return parent::__set( $propertyName, $propertyValue );
}
diff --git a/src/options/renderer_2d.php b/src/options/renderer_2d.php
index 8539008..3235965 100644
--- a/src/options/renderer_2d.php
+++ b/src/options/renderer_2d.php
@@ -52,10 +52,23 @@ class ezcGraphRenderer2dOptions extends ezcGraphRendererOptions
switch ( $propertyName )
{
case 'pieChartShadowSize':
- $this->properties['pieChartShadowSize'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float >= 0' );
+ }
+
+ $this->properties['pieChartShadowSize'] = (int) $propertyValue;
break;
case 'pieChartShadowTransparency':
- $this->properties['pieChartShadowTransparency'] = min( 1, max( 0, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties['pieChartShadowTransparency'] = (float) $propertyValue;
break;
case 'pieChartShadowColor':
$this->properties['pieChartShadowColor'] = ezcGraphColor::create( $propertyValue );
diff --git a/src/options/renderer_3d.php b/src/options/renderer_3d.php
index ceb1ab6..0887ae2 100644
--- a/src/options/renderer_3d.php
+++ b/src/options/renderer_3d.php
@@ -54,7 +54,7 @@ class ezcGraphRenderer3dOptions extends ezcGraphRendererOptions
$this->properties['fillAxis'] = .8;
$this->properties['fillGrid'] = 0;
$this->properties['depth'] = .1;
- $this->properties['pieChartHeight'] = 10;
+ $this->properties['pieChartHeight'] = 10.;
$this->properties['pieChartRotation'] = .6;
$this->properties['pieChartShadowSize'] = 0;
$this->properties['pieChartShadowTransparency'] = .3;
@@ -82,45 +82,60 @@ class ezcGraphRenderer3dOptions extends ezcGraphRendererOptions
{
switch ( $propertyName )
{
- case 'depth':
- $this->properties['depth'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'seperateLines':
- $this->properties['seperateLines'] = (bool) $propertyValue;
- break;
case 'fillAxis':
- $this->properties['fillAxis'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
case 'fillGrid':
- $this->properties['fillGrid'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'dataBorder':
- $this->properties['dataBorder'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'pieChartHeight':
- $this->properties['pieChartHeight'] = (float) $propertyValue;
+ if ( $propertyValue !== false &&
+ !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'false OR 0 <= float <= 1' );
+ }
+
+ $this->properties[$propertyName] = (
+ $propertyValue === false
+ ? false
+ : (float) $propertyValue );
break;
+
+ case 'depth':
case 'pieChartRotation':
- $this->properties['pieChartRotation'] = min( 1., max( .0, (float) $propertyValue ) );
+ case 'pieChartShadowTransparency':
+ case 'barDarkenSide':
+ case 'barDarkenTop':
+ case 'barChartGleam':
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) ||
+ ( $propertyValue > 1 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, '0 <= float <= 1' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
+
+ case 'pieChartHeight':
case 'pieChartShadowSize':
- $this->properties['pieChartShadowSize'] = max( 0, (int) $propertyValue );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue <= 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
+ $this->properties[$propertyName] = (float) $propertyValue;
break;
- case 'pieChartShadowTransparency':
- $this->properties['pieChartShadowTransparency'] = min( 1., max( .0, (float) $propertyValue ) );
+
+ case 'seperateLines':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
+ $this->properties['seperateLines'] = $propertyValue;
break;
case 'pieChartShadowColor':
$this->properties['pieChartShadowColor'] = ezcGraphColor::create( $propertyValue );
break;
- case 'barDarkenSide':
- $this->properties['barDarkenSide'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'barDarkenTop':
- $this->properties['barDarkenTop'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
- case 'barChartGleam':
- $this->properties['barChartGleam'] = min( 1., max( .0, (float) $propertyValue ) );
- break;
default:
return parent::__set( $propertyName, $propertyValue );
}
diff --git a/src/options/svg_driver.php b/src/options/svg_driver.php
index 1a72f6e..27bc597 100644
--- a/src/options/svg_driver.php
+++ b/src/options/svg_driver.php
@@ -91,10 +91,22 @@ class ezcGraphSvgDriverOptions extends ezcGraphDriverOptions
switch ( $propertyName )
{
case 'assumedNumericCharacterWidth':
- $this->properties['assumedNumericCharacterWidth'] = min( 1, max( 0, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
+ $this->properties['assumedNumericCharacterWidth'] = (float) $propertyValue;
break;
case 'assumedTextCharacterWidth':
- $this->properties['assumedTextCharacterWidth'] = min( 1, max( 0, (float) $propertyValue ) );
+ if ( !is_numeric( $propertyValue ) ||
+ ( $propertyValue < 0 ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'float > 0' );
+ }
+
+ $this->properties['assumedTextCharacterWidth'] = (float) $propertyValue;
break;
case 'strokeLineJoin':
$values = array(
diff --git a/src/renderer/axis_label_centered.php b/src/renderer/axis_label_centered.php
index 0116857..0fd7438 100644
--- a/src/renderer/axis_label_centered.php
+++ b/src/renderer/axis_label_centered.php
@@ -51,6 +51,11 @@ class ezcGraphAxisCenteredLabelRenderer extends ezcGraphAxisLabelRenderer
switch ( $propertyName )
{
case 'showZeroValue':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
$this->properties['showZeroValue'] = (bool) $propertyValue;
break;
default:
diff --git a/src/renderer/axis_label_exact.php b/src/renderer/axis_label_exact.php
index b4b676f..e70c7b9 100644
--- a/src/renderer/axis_label_exact.php
+++ b/src/renderer/axis_label_exact.php
@@ -52,6 +52,11 @@ class ezcGraphAxisExactLabelRenderer extends ezcGraphAxisLabelRenderer
switch ( $propertyName )
{
case 'showLastValue':
+ if ( !is_bool( $propertyValue ) )
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'bool' );
+ }
+
$this->properties['showLastValue'] = (bool) $propertyValue;
break;
default:
diff --git a/tests/axis_centered_renderer_test.php b/tests/axis_centered_renderer_test.php
index eaa43a2..2610912 100644
--- a/tests/axis_centered_renderer_test.php
+++ b/tests/axis_centered_renderer_test.php
@@ -501,5 +501,34 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->render( 500, 200 );
}
+
+ public function testAxisCenteredLabelRendererPropertyShowZeroValue()
+ {
+ $options = new ezcGraphAxisCenteredLabelRenderer();
+
+ $this->assertSame(
+ false,
+ $options->showZeroValue,
+ 'Wrong default value for property showZeroValue in class ezcGraphAxisCenteredLabelRenderer'
+ );
+
+ $options->showZeroValue = true;
+ $this->assertSame(
+ true,
+ $options->showZeroValue,
+ 'Setting property value did not work for property showZeroValue in class ezcGraphAxisCenteredLabelRenderer'
+ );
+
+ try
+ {
+ $options->showZeroValue = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
}
?>
diff --git a/tests/axis_exact_renderer_test.php b/tests/axis_exact_renderer_test.php
index 79c30ec..720278a 100644
--- a/tests/axis_exact_renderer_test.php
+++ b/tests/axis_exact_renderer_test.php
@@ -613,5 +613,266 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->render( 500, 200 );
}
+
+ public function testAxisLabelRendererPropertyMajorStepCount()
+ {
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ false,
+ $axisLabelRenderer->majorStepCount,
+ 'Wrong default value for property majorStepCount in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $axisLabelRenderer->majorStepCount = 1;
+ $this->assertSame(
+ 1,
+ $axisLabelRenderer->majorStepCount,
+ 'Setting property value did not work for property majorStepCount in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $axisLabelRenderer->majorStepCount = true;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testAxisLabelRendererPropertyMinorStepCount()
+ {
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ false,
+ $axisLabelRenderer->minorStepCount,
+ 'Wrong default value for property minorStepCount in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $axisLabelRenderer->minorStepCount = 1;
+ $this->assertSame(
+ 1,
+ $axisLabelRenderer->minorStepCount,
+ 'Setting property value did not work for property minorStepCount in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $axisLabelRenderer->minorStepCount = true;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testAxisLabelRendererPropertyMajorStepSize()
+ {
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ 3,
+ $axisLabelRenderer->majorStepSize,
+ 'Wrong default value for property majorStepSize in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $axisLabelRenderer->majorStepSize = 1;
+ $this->assertSame(
+ 1,
+ $axisLabelRenderer->majorStepSize,
+ 'Setting property value did not work for property majorStepSize in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $axisLabelRenderer->majorStepSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testAxisLabelRendererPropertyMinorStepSize()
+ {
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ 1,
+ $axisLabelRenderer->minorStepSize,
+ 'Wrong default value for property minorStepSize in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $axisLabelRenderer->minorStepSize = 2;
+ $this->assertSame(
+ 2,
+ $axisLabelRenderer->minorStepSize,
+ 'Setting property value did not work for property minorStepSize in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $axisLabelRenderer->minorStepSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testAxisLabelRendererPropertyInnerStep()
+ {
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ true,
+ $axisLabelRenderer->innerStep,
+ 'Wrong default value for property innerStep in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $axisLabelRenderer->innerStep = false;
+ $this->assertSame(
+ false,
+ $axisLabelRenderer->innerStep,
+ 'Setting property value did not work for property innerStep in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $axisLabelRenderer->innerStep = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testAxisLabelRendererPropertyOuterStep()
+ {
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ false,
+ $axisLabelRenderer->outerStep,
+ 'Wrong default value for property outerStep in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $axisLabelRenderer->outerStep = true;
+ $this->assertSame(
+ true,
+ $axisLabelRenderer->outerStep,
+ 'Setting property value did not work for property outerStep in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $axisLabelRenderer->outerStep = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testAxisLabelRendererPropertyOuterGrid()
+ {
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ false,
+ $axisLabelRenderer->outerGrid,
+ 'Wrong default value for property outerGrid in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $axisLabelRenderer->outerGrid = true;
+ $this->assertSame(
+ true,
+ $axisLabelRenderer->outerGrid,
+ 'Setting property value did not work for property outerGrid in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $axisLabelRenderer->outerGrid = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testAxisLabelRendererPropertyLabelPadding()
+ {
+ $axisLabelRenderer = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ 2,
+ $axisLabelRenderer->labelPadding,
+ 'Wrong default value for property labelPadding in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $axisLabelRenderer->labelPadding = 1;
+ $this->assertSame(
+ 1,
+ $axisLabelRenderer->labelPadding,
+ 'Setting property value did not work for property labelPadding in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $axisLabelRenderer->labelPadding = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testAxisExactLabelRendererPropertyShowLastValue()
+ {
+ $options = new ezcGraphAxisExactLabelRenderer();
+
+ $this->assertSame(
+ true,
+ $options->showLastValue,
+ 'Wrong default value for property showLastValue in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ $options->showLastValue = false;
+ $this->assertSame(
+ false,
+ $options->showLastValue,
+ 'Setting property value did not work for property showLastValue in class ezcGraphAxisExactLabelRenderer'
+ );
+
+ try
+ {
+ $options->showLastValue = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
}
?>
diff --git a/tests/color_test.php b/tests/color_test.php
index 8a586e3..dc90f35 100644
--- a/tests/color_test.php
+++ b/tests/color_test.php
@@ -102,6 +102,122 @@ class ezcGraphColorTest extends ezcTestCase
$this->assertEquals( $color->alpha, 0, 'Wrong alpha color value' );
}
+ public function testColorPropertyRed()
+ {
+ $options = ezcGraphColor::create( '#00000000' );
+
+ $this->assertSame(
+ 0,
+ $options->red,
+ 'Wrong default value for property red in class ezcGraphColor'
+ );
+
+ $options->red = 1;
+ $this->assertSame(
+ 1,
+ $options->red,
+ 'Setting property value did not work for property red in class ezcGraphColor'
+ );
+
+ try
+ {
+ $options->red = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testColorPropertyGreen()
+ {
+ $options = ezcGraphColor::create( '#00000000' );
+
+ $this->assertSame(
+ 0,
+ $options->green,
+ 'Wrong default value for property green in class ezcGraphColor'
+ );
+
+ $options->green = 1;
+ $this->assertSame(
+ 1,
+ $options->green,
+ 'Setting property value did not work for property green in class ezcGraphColor'
+ );
+
+ try
+ {
+ $options->green = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testColorPropertyBlue()
+ {
+ $options = ezcGraphColor::create( '#00000000' );
+
+ $this->assertSame(
+ 0,
+ $options->blue,
+ 'Wrong default value for property blue in class ezcGraphColor'
+ );
+
+ $options->blue = 1;
+ $this->assertSame(
+ 1,
+ $options->blue,
+ 'Setting property value did not work for property blue in class ezcGraphColor'
+ );
+
+ try
+ {
+ $options->blue = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testColorPropertyAlpha()
+ {
+ $options = ezcGraphColor::create( '#00000000' );
+
+ $this->assertSame(
+ 0,
+ $options->alpha,
+ 'Wrong default value for property alpha in class ezcGraphColor'
+ );
+
+ $options->alpha = 1;
+ $this->assertSame(
+ 1,
+ $options->alpha,
+ 'Setting property value did not work for property alpha in class ezcGraphColor'
+ );
+
+ try
+ {
+ $options->alpha = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
public function testColorPropertyNotFoundException()
{
try
@@ -318,6 +434,74 @@ class ezcGraphColorTest extends ezcTestCase
$this->fail( 'Expected ezcBaseValueException.' );
}
+ public function testRadialGradientPropertyWidth()
+ {
+ $color = new ezcGraphRadialGradient(
+ new ezcGraphCoordinate( 0, 0 ),
+ 10, 20,
+ ezcGraphColor::fromHex( '#FFFFFF' ),
+ ezcGraphColor::fromHex( '#000000' )
+ );
+
+ $this->assertSame(
+ 10.,
+ $color->width,
+ 'Wrong default value for property width in class ezcGraphRadialGradient'
+ );
+
+ $color->width = 20;
+ $this->assertSame(
+ 20.,
+ $color->width,
+ 'Setting property value did not work for property width in class ezcGraphRadialGradient'
+ );
+
+ try
+ {
+ $color->width = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testRadialGradientPropertyHeight()
+ {
+ $color = new ezcGraphRadialGradient(
+ new ezcGraphCoordinate( 0, 0 ),
+ 10, 20,
+ ezcGraphColor::fromHex( '#FFFFFF' ),
+ ezcGraphColor::fromHex( '#000000' )
+ );
+
+ $this->assertSame(
+ 20.,
+ $color->height,
+ 'Wrong default value for property height in class ezcGraphRadialGradient'
+ );
+
+ $color->height = 30;
+ $this->assertSame(
+ 30.,
+ $color->height,
+ 'Setting property value did not work for property height in class ezcGraphRadialGradient'
+ );
+
+ try
+ {
+ $color->height = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
public function testRadialGradientPropertyOffset()
{
$color = new ezcGraphRadialGradient(
@@ -339,6 +523,17 @@ class ezcGraphColorTest extends ezcTestCase
$color->offset,
'Setting property value did not work for property offset in class ezcGraphRadialGradient'
);
+
+ try
+ {
+ $color->offset = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testLinearGradientSetProperties()
diff --git a/tests/dataset_average_test.php b/tests/dataset_average_test.php
index a2c9ae0..6ab21c6 100644
--- a/tests/dataset_average_test.php
+++ b/tests/dataset_average_test.php
@@ -294,7 +294,7 @@ class ezcGraphDataSetAverageTest extends ezcTestCase
$this->fail( 'Expected ezcGraphDatasetAverageInvalidKeysException.' );
}
- public function testPAverageDataSetIsset()
+ public function testAverageDataSetIsset()
{
$arrayDataSet = new ezcGraphArrayDataSet( array( -1 => 2, 1 => 2, 3 => 10 ) );
@@ -308,5 +308,65 @@ class ezcGraphDataSetAverageTest extends ezcTestCase
'Polygon not properly initialized.'
);
}
+
+ public function testDataSetAveragePolynomPropertyPolynomOrder()
+ {
+ $arrayDataSet = new ezcGraphArrayDataSet( array( -1 => 2, 1 => 2, 3 => 10 ) );
+ $dataset = new ezcGraphDataSetAveragePolynom( $arrayDataSet );
+
+ $this->assertSame(
+ 3,
+ $dataset->polynomOrder,
+ 'Wrong default value for property polynomOrder in class ezcGraphDataSetAveragePolynom'
+ );
+
+ $dataset->polynomOrder = 5;
+ $this->assertSame(
+ 5,
+ $dataset->polynomOrder,
+ 'Setting property value did not work for property polynomOrder in class ezcGraphDataSetAveragePolynom'
+ );
+
+ try
+ {
+ $dataset->polynomOrder = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testDataSetAveragePolynomPropertyResolution()
+ {
+ $arrayDataSet = new ezcGraphArrayDataSet( array( -1 => 2, 1 => 2, 3 => 10 ) );
+ $dataset = new ezcGraphDataSetAveragePolynom( $arrayDataSet );
+
+ $this->assertSame(
+ 100,
+ $dataset->resolution,
+ 'Wrong default value for property resolution in class ezcGraphDataSetAveragePolynom'
+ );
+
+ $dataset->resolution = 5;
+ $this->assertSame(
+ 5,
+ $dataset->resolution,
+ 'Setting property value did not work for property resolution in class ezcGraphDataSetAveragePolynom'
+ );
+
+ try
+ {
+ $dataset->resolution = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
}
?>
diff --git a/tests/driver_gd_test.php b/tests/driver_gd_test.php
index 9ab3e95..2a4bc59 100644
--- a/tests/driver_gd_test.php
+++ b/tests/driver_gd_test.php
@@ -1945,6 +1945,17 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
$options->jpegQuality,
'Setting property value did not work for property jpegQuality in class ezcGraphGdDriverOptions'
);
+
+ try
+ {
+ $options->jpegQuality = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testGdDriverOptionsPropertyDetail()
@@ -1963,6 +1974,17 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
$options->detail,
'Setting property value did not work for property detail in class ezcGraphGdDriverOptions'
);
+
+ try
+ {
+ $options->detail = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testGdDriverOptionsPropertySupersampling()
@@ -1981,6 +2003,17 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
$options->supersampling,
'Setting property value did not work for property supersampling in class ezcGraphGdDriverOptions'
);
+
+ try
+ {
+ $options->supersampling = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testGdDriverOptionsPropertyBackground()
@@ -2057,6 +2090,17 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
$options->forceNativeTTF,
'Setting property value did not work for property forceNativeTTF in class ezcGraphGdDriverOptions'
);
+
+ try
+ {
+ $options->forceNativeTTF = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testGdDriverOptionsPropertyImageMapResolution()
@@ -2075,6 +2119,17 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
$options->imageMapResolution,
'Setting property value did not work for property imageMapResolution in class ezcGraphGdDriverOptions'
);
+
+ try
+ {
+ $options->imageMapResolution = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
}
?>
diff --git a/tests/driver_ming_test.php b/tests/driver_ming_test.php
index 4b14960..83066fb 100644
--- a/tests/driver_ming_test.php
+++ b/tests/driver_ming_test.php
@@ -1431,6 +1431,17 @@ class ezcGraphMingDriverTest extends ezcTestCase
$options->compression,
'Setting property value did not work for property compression in class ezcGraphMingDriverOptions'
);
+
+ try
+ {
+ $options->compression = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testMingDriverOptionsPropertyCircleResolution()
@@ -1449,6 +1460,17 @@ class ezcGraphMingDriverTest extends ezcTestCase
$options->circleResolution,
'Setting property value did not work for property circleResolution in class ezcGraphMingDriverOptions'
);
+
+ try
+ {
+ $options->circleResolution = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
}
?>
diff --git a/tests/driver_options_test.php b/tests/driver_options_test.php
index e2dcbd8..dd4660e 100644
--- a/tests/driver_options_test.php
+++ b/tests/driver_options_test.php
@@ -28,7 +28,7 @@ class ezcGraphDriverOptionsTest extends ezcImageTestCase
$options = new ezcGraphSvgDriverOptions();
$this->assertSame(
- false,
+ null,
$options->width,
'Wrong default value for property width in class ezcGraphSvgDriverOptions'
);
@@ -39,6 +39,17 @@ class ezcGraphDriverOptionsTest extends ezcImageTestCase
$options->width,
'Setting property value did not work for property width in class ezcGraphSvgDriverOptions'
);
+
+ try
+ {
+ $options->width = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testDriverOptionsPropertyHeight()
@@ -46,7 +57,7 @@ class ezcGraphDriverOptionsTest extends ezcImageTestCase
$options = new ezcGraphSvgDriverOptions();
$this->assertSame(
- false,
+ null,
$options->height,
'Wrong default value for property height in class ezcGraphSvgDriverOptions'
);
@@ -57,6 +68,17 @@ class ezcGraphDriverOptionsTest extends ezcImageTestCase
$options->height,
'Setting property value did not work for property height in class ezcGraphSvgDriverOptions'
);
+
+ try
+ {
+ $options->height = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testDriverOptionsPropertyShadeCircularArc()
@@ -75,6 +97,17 @@ class ezcGraphDriverOptionsTest extends ezcImageTestCase
$options->shadeCircularArc,
'Setting property value did not work for property shadeCircularArc in class ezcGraphSvgDriverOptions'
);
+
+ try
+ {
+ $options->shadeCircularArc = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testDriverOptionsPropertyLineSpacing()
@@ -93,6 +126,17 @@ class ezcGraphDriverOptionsTest extends ezcImageTestCase
$options->lineSpacing,
'Setting property value did not work for property lineSpacing in class ezcGraphSvgDriverOptions'
);
+
+ try
+ {
+ $options->lineSpacing = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testDriverOptionsPropertyFont()
diff --git a/tests/driver_svg_test.php b/tests/driver_svg_test.php
index 84ec27e..eeb8dcd 100644
--- a/tests/driver_svg_test.php
+++ b/tests/driver_svg_test.php
@@ -1212,6 +1212,17 @@ class ezcGraphSvgDriverTest extends ezcTestCase
$options->assumedNumericCharacterWidth,
'Setting property value did not work for property assumedNumericCharacterWidth in class ezcGraphSvgDriverOptions'
);
+
+ try
+ {
+ $options->assumedNumericCharacterWidth = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testSvgDriverOptionsPropertyAssumedTextCharacterWidth()
@@ -1230,6 +1241,17 @@ class ezcGraphSvgDriverTest extends ezcTestCase
$options->assumedTextCharacterWidth,
'Setting property value did not work for property assumedTextCharacterWidth in class ezcGraphSvgDriverOptions'
);
+
+ try
+ {
+ $options->assumedTextCharacterWidth = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testSvgDriverOptionsPropertyStrokeLineCap()
diff --git a/tests/element_options_test.php b/tests/element_options_test.php
index c7014a6..c4e78dd 100644
--- a/tests/element_options_test.php
+++ b/tests/element_options_test.php
@@ -127,6 +127,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->padding,
'Setting property value did not work for property padding in class ezcGraphChartElementBackground'
);
+
+ try
+ {
+ $options->padding = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementPropertyMargin()
@@ -145,6 +156,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->margin,
'Setting property value did not work for property margin in class ezcGraphChartElementBackground'
);
+
+ try
+ {
+ $options->margin = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementPropertyBorderWidth()
@@ -163,6 +185,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->borderWidth,
'Setting property value did not work for property borderWidth in class ezcGraphChartElementBackground'
);
+
+ try
+ {
+ $options->borderWidth = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementPropertyPosition()
@@ -210,6 +243,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->maxTitleHeight,
'Setting property value did not work for property maxTitleHeight in class ezcGraphChartElementBackground'
);
+
+ try
+ {
+ $options->maxTitleHeight = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementPropertyPortraitTitleSize()
@@ -228,6 +272,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->portraitTitleSize,
'Setting property value did not work for property portraitTitleSize in class ezcGraphChartElementBackground'
);
+
+ try
+ {
+ $options->portraitTitleSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementPropertyLandscapeTitleSize()
@@ -246,6 +301,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->landscapeTitleSize,
'Setting property value did not work for property landscapeTitleSize in class ezcGraphChartElementBackground'
);
+
+ try
+ {
+ $options->landscapeTitleSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementPropertyFont()
@@ -365,6 +431,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->portraitSize,
'Setting property value did not work for property portraitSize in class ezcGraphChartElementLegend'
);
+
+ try
+ {
+ $options->portraitSize = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementLegendPropertyLandscapeSize()
@@ -383,6 +460,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->landscapeSize,
'Setting property value did not work for property landscapeSize in class ezcGraphChartElementLegend'
);
+
+ try
+ {
+ $options->landscapeSize = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementLegendPropertySymbolSize()
@@ -401,6 +489,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->symbolSize,
'Setting property value did not work for property symbolSize in class ezcGraphChartElementLegend'
);
+
+ try
+ {
+ $options->landscapeSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementLegendPropertyMinimumSymbolSize()
@@ -419,6 +518,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->minimumSymbolSize,
'Setting property value did not work for property minimumSymbolSize in class ezcGraphChartElementLegend'
);
+
+ try
+ {
+ $options->landscapeSize = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementLegendPropertySpacing()
@@ -437,6 +547,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->spacing,
'Setting property value did not work for property spacing in class ezcGraphChartElementLegend'
);
+
+ try
+ {
+ $options->landscapeSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementAxisPropertyNullPosition()
@@ -473,6 +594,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->axisSpace,
'Setting property value did not work for property axisSpace in class ezcGraphChartElementNumericAxis'
);
+
+ try
+ {
+ $options->axisSpace = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementAxisPropertyMajorGrid()
@@ -643,6 +775,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->labelSize,
'Setting property value did not work for property labelSize in class ezcGraphChartElementNumericAxis'
);
+
+ try
+ {
+ $options->labelSize = 2;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementAxisPropertyLabelMargin()
@@ -661,6 +804,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->labelMargin,
'Setting property value did not work for property labelMargin in class ezcGraphChartElementNumericAxis'
);
+
+ try
+ {
+ $options->labelMargin = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementAxisPropertyMaxArrowHeadSize()
@@ -679,6 +833,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->maxArrowHeadSize,
'Setting property value did not work for property maxArrowHeadSize in class ezcGraphChartElementNumericAxis'
);
+
+ try
+ {
+ $options->labelMargin = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartElementAxisPropertyAxisLabelRenderer()
@@ -726,6 +891,17 @@ class ezcGraphElementOptionsTest extends ezcImageTestCase
$options->maxHeight,
'Setting property value did not work for property maxHeight in class ezcGraphChartElementText'
);
+
+ try
+ {
+ $options->maxHeight = 2;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
}
?>
diff --git a/tests/font_test.php b/tests/font_test.php
index b9a5c16..20e8eb1 100644
--- a/tests/font_test.php
+++ b/tests/font_test.php
@@ -274,6 +274,17 @@ class ezcGraphFontTest extends ezcTestCase
$options->minFontSize,
'Setting property value did not work for property minFontSize in class ezcGraphFontOptions'
);
+
+ try
+ {
+ $options->minFontSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testFontOptionsPropertyMaxFontSize()
@@ -292,6 +303,17 @@ class ezcGraphFontTest extends ezcTestCase
$options->maxFontSize,
'Setting property value did not work for property maxFontSize in class ezcGraphFontOptions'
);
+
+ try
+ {
+ $options->maxFontSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testFontOptionsPropertyMinimalUsedFont()
@@ -422,6 +444,17 @@ class ezcGraphFontTest extends ezcTestCase
$options->borderWidth,
'Setting property value did not work for property borderWidth in class ezcGraphFontOptions'
);
+
+ try
+ {
+ $options->borderWidth = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testFontOptionsPropertyPadding()
@@ -440,6 +473,17 @@ class ezcGraphFontTest extends ezcTestCase
$options->padding,
'Setting property value did not work for property padding in class ezcGraphFontOptions'
);
+
+ try
+ {
+ $options->padding = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testFontOptionsPropertyMinimizeBorder()
@@ -458,6 +502,17 @@ class ezcGraphFontTest extends ezcTestCase
$options->minimizeBorder,
'Setting property value did not work for property minimizeBorder in class ezcGraphFontOptions'
);
+
+ try
+ {
+ $options->minimizeBorder = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testFontOptionsPropertyTextShadow()
@@ -476,6 +531,17 @@ class ezcGraphFontTest extends ezcTestCase
$options->textShadow,
'Setting property value did not work for property textShadow in class ezcGraphFontOptions'
);
+
+ try
+ {
+ $options->textShadow = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testFontOptionsPropertyTextShadowOffset()
@@ -494,6 +560,17 @@ class ezcGraphFontTest extends ezcTestCase
$options->textShadowOffset,
'Setting property value did not work for property textShadowOffset in class ezcGraphFontOptions'
);
+
+ try
+ {
+ $options->textShadowOffset = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testFontOptionsPropertyTextShadowColor()
diff --git a/tests/line_test.php b/tests/line_test.php
index 40a591e..e50ccc4 100644
--- a/tests/line_test.php
+++ b/tests/line_test.php
@@ -65,6 +65,17 @@ class ezcGraphLineChartTest extends ezcTestCase
$options->lineThickness,
'Setting property value did not work for property lineThickness in class ezcGraphLineChartOptions'
);
+
+ try
+ {
+ $options->lineThickness = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testLineChartOptionsPropertyFillLines()
@@ -90,6 +101,17 @@ class ezcGraphLineChartTest extends ezcTestCase
$options->fillLines,
'Setting property value did not work for property fillLines in class ezcGraphLineChartOptions'
);
+
+ try
+ {
+ $options->fillLines = true;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testLineChartOptionsPropertySymbolSize()
@@ -108,6 +130,17 @@ class ezcGraphLineChartTest extends ezcTestCase
$options->symbolSize,
'Setting property value did not work for property symbolSize in class ezcGraphLineChartOptions'
);
+
+ try
+ {
+ $options->symbolSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testLineChartOptionsPropertyHighlightFont()
@@ -165,6 +198,17 @@ class ezcGraphLineChartTest extends ezcTestCase
$options->highlightSize,
'Setting property value did not work for property highlightSize in class ezcGraphLineChartOptions'
);
+
+ try
+ {
+ $options->highlightSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testLineChartOptionsPropertyHighlightLines()
@@ -183,6 +227,17 @@ class ezcGraphLineChartTest extends ezcTestCase
$options->highlightLines,
'Setting property value did not work for property highlightLines in class ezcGraphLineChartOptions'
);
+
+ try
+ {
+ $options->highlightLines = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testElementGenerationLegend()
@@ -668,5 +723,23 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->fail( 'Expected ezcBaseValueException.' );
}
+
+ public function testLineChartOptionsPropertyLegend()
+ {
+ $chart = new ezcGraphLineChart();
+
+ $chart->legend = false;
+
+ try
+ {
+ $chart->legend = 12;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
}
?>
diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php
index 8cf01a6..221d7f0 100644
--- a/tests/numeric_axis_test.php
+++ b/tests/numeric_axis_test.php
@@ -574,6 +574,63 @@ class ezcGraphNumericAxisTest extends ezcTestCase
.05
);
}
-}
+ public function testChartElementNumericAxisPropertyMin()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ null,
+ $options->min,
+ 'Wrong default value for property min in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->min = 1;
+ $this->assertSame(
+ 1.,
+ $options->min,
+ 'Setting property value did not work for property min in class ezcGraphChartElementNumericAxis'
+ );
+
+ try
+ {
+ $options->min = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testChartElementNumericAxisPropertyMax()
+ {
+ $options = new ezcGraphChartElementNumericAxis();
+
+ $this->assertSame(
+ null,
+ $options->max,
+ 'Wrong default value for property max in class ezcGraphChartElementNumericAxis'
+ );
+
+ $options->max = 1;
+ $this->assertSame(
+ 1.,
+ $options->max,
+ 'Setting property value did not work for property max in class ezcGraphChartElementNumericAxis'
+ );
+
+ try
+ {
+ $options->max = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+}
?>
diff --git a/tests/palette_test.php b/tests/palette_test.php
index 25ae6c5..8861ec3 100644
--- a/tests/palette_test.php
+++ b/tests/palette_test.php
@@ -363,19 +363,6 @@ class ezcGraphPaletteTest extends ezcTestCase
$this->fail( 'expected ezcGraphUnknownColorDefinitionException.' );
}
- public function testModifyPaletteIntProperty()
- {
- $palette = new ezcGraphPaletteTango();
-
- $palette->chartBorderWidth = 0;
- $palette->padding = -1;
- $palette->margin = 3;
-
- $this->assertSame( $palette->chartBorderWidth, 0 );
- $this->assertSame( $palette->padding, 0 );
- $this->assertSame( $palette->margin, 3 );
- }
-
public function testModifyPaletteDatasetColorArray()
{
$palette = new ezcGraphPaletteTango();
@@ -427,6 +414,121 @@ class ezcGraphPaletteTest extends ezcTestCase
$this->fail( 'expected ezcBaseValueException.' );
}
-}
+ public function testPalettePropertyChartBorderWidth()
+ {
+ $options = new ezcGraphPaletteTango();
+
+ $this->assertSame(
+ 0,
+ $options->chartBorderWidth,
+ 'Wrong default value for property chartBorderWidth in class ezcGraphPalette'
+ );
+
+ $options->chartBorderWidth = 1;
+ $this->assertSame(
+ 1,
+ $options->chartBorderWidth,
+ 'Setting property value did not work for property chartBorderWidth in class ezcGraphPalette'
+ );
+
+ try
+ {
+ $options->chartBorderWidth = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testPalettePropertyElementBorderWidth()
+ {
+ $options = new ezcGraphPaletteTango();
+
+ $this->assertSame(
+ 0,
+ $options->elementBorderWidth,
+ 'Wrong default value for property elementBorderWidth in class ezcGraphPalette'
+ );
+
+ $options->elementBorderWidth = 1;
+ $this->assertSame(
+ 1,
+ $options->elementBorderWidth,
+ 'Setting property value did not work for property elementBorderWidth in class ezcGraphPalette'
+ );
+
+ try
+ {
+ $options->elementBorderWidth = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testPalettePropertyPadding()
+ {
+ $options = new ezcGraphPaletteTango();
+
+ $this->assertSame(
+ 1,
+ $options->padding,
+ 'Wrong default value for property padding in class ezcGraphPalette'
+ );
+
+ $options->padding = 2;
+ $this->assertSame(
+ 2,
+ $options->padding,
+ 'Setting property value did not work for property padding in class ezcGraphPalette'
+ );
+
+ try
+ {
+ $options->padding = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testPalettePropertyMargin()
+ {
+ $options = new ezcGraphPaletteTango();
+
+ $this->assertSame(
+ 0,
+ $options->margin,
+ 'Wrong default value for property margin in class ezcGraphPalette'
+ );
+
+ $options->margin = 1;
+ $this->assertSame(
+ 1,
+ $options->margin,
+ 'Setting property value did not work for property margin in class ezcGraphPalette'
+ );
+
+ try
+ {
+ $options->margin = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+}
?>
diff --git a/tests/pie_test.php b/tests/pie_test.php
index 31c053d..32e14c8 100644
--- a/tests/pie_test.php
+++ b/tests/pie_test.php
@@ -480,6 +480,17 @@ class ezcGraphPieChartTest extends ezcImageTestCase
$filename,
$this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
);
+
+ try
+ {
+ $chart->options->sum = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderPieChartWithAbsoluteTreshHold()
@@ -496,6 +507,17 @@ class ezcGraphPieChartTest extends ezcImageTestCase
$filename,
$this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
);
+
+ try
+ {
+ $chart->options->absoluteTreshHold = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderPieChartWithPercentageTreshHold()
@@ -513,6 +535,17 @@ class ezcGraphPieChartTest extends ezcImageTestCase
$filename,
$this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
);
+
+ try
+ {
+ $chart->options->percentTreshHold = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderPieChartWithPercentageTreshHoldAndCustomSum()
diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php
index 381b632..4a41bf6 100644
--- a/tests/renderer_2d_test.php
+++ b/tests/renderer_2d_test.php
@@ -1960,6 +1960,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->maxLabelHeight,
'Setting property value did not work for property maxLabelHeight in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->maxLabelHeight = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyShowSymbol()
@@ -1978,6 +1989,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->showSymbol,
'Setting property value did not work for property showSymbol in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->showSymbol = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertySymbolSize()
@@ -1996,6 +2018,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->symbolSize,
'Setting property value did not work for property symbolSize in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->symbolSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyMoveOut()
@@ -2014,6 +2047,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->moveOut,
'Setting property value did not work for property moveOut in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->moveOut = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyTitlePosition()
@@ -2032,6 +2076,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->titlePosition,
'Setting property value did not work for property titlePosition in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->titlePosition = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyTitleAlignement()
@@ -2050,6 +2105,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->titleAlignement,
'Setting property value did not work for property titleAlignement in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->titleAlignement = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyDataBorder()
@@ -2068,6 +2134,24 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->dataBorder,
'Setting property value did not work for property dataBorder in class ezcGraphRendererOptions'
);
+
+ $options->dataBorder = false;
+ $this->assertSame(
+ false,
+ $options->dataBorder,
+ 'Setting property value did not work for property dataBorder in class ezcGraphRendererOptions'
+ );
+
+ try
+ {
+ $options->dataBorder = true;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyBarMargin()
@@ -2086,6 +2170,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->barMargin,
'Setting property value did not work for property barMargin in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->barMargin = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyBarPadding()
@@ -2104,6 +2199,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->barPadding,
'Setting property value did not work for property barPadding in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->barPadding = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyPieChartOffset()
@@ -2118,10 +2224,21 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->pieChartOffset = 1;
$this->assertSame(
- 1,
+ 1.,
$options->pieChartOffset,
'Setting property value did not work for property pieChartOffset in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->pieChartOffset = 450;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyLegendSymbolGleam()
@@ -2140,6 +2257,24 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->legendSymbolGleam,
'Setting property value did not work for property legendSymbolGleam in class ezcGraphRendererOptions'
);
+
+ $options->legendSymbolGleam = false;
+ $this->assertSame(
+ false,
+ $options->legendSymbolGleam,
+ 'Setting property value did not work for property legendSymbolGleam in class ezcGraphRendererOptions'
+ );
+
+ try
+ {
+ $options->legendSymbolGleam = true;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyLegendSymbolGleamSize()
@@ -2158,6 +2293,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->legendSymbolGleamSize,
'Setting property value did not work for property legendSymbolGleamSize in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->legendSymbolGleamSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyLegendSymbolGleamColor()
@@ -2206,6 +2352,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->pieVerticalSize,
'Setting property value did not work for property pieVerticalSize in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->pieVerticalSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyPieHorizontalSize()
@@ -2224,6 +2381,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->pieHorizontalSize,
'Setting property value did not work for property pieHorizontalSize in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->pieHorizontalSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyPieChartSymbolColor()
@@ -2271,6 +2439,24 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->pieChartGleam,
'Setting property value did not work for property pieChartGleam in class ezcGraphRendererOptions'
);
+
+ $options->pieChartGleam = false;
+ $this->assertSame(
+ false,
+ $options->pieChartGleam,
+ 'Setting property value did not work for property pieChartGleam in class ezcGraphRendererOptions'
+ );
+
+ try
+ {
+ $options->pieChartGleam = true;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRendererOptionsPropertyPieChartGleamColor()
@@ -2318,6 +2504,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->pieChartGleamBorder,
'Setting property value did not work for property pieChartGleamBorder in class ezcGraphRendererOptions'
);
+
+ try
+ {
+ $options->pieChartGleamBorder = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer2dOptionsPropertyPieChartShadowSize()
@@ -2336,6 +2533,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->pieChartShadowSize,
'Setting property value did not work for property pieChartShadowSize in class ezcGraphRenderer2dOptions'
);
+
+ try
+ {
+ $options->pieChartShadowSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer2dOptionsPropertyPieChartShadowTransparency()
@@ -2354,6 +2562,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->pieChartShadowTransparency,
'Setting property value did not work for property pieChartShadowTransparency in class ezcGraphRenderer2dOptions'
);
+
+ try
+ {
+ $options->pieChartShadowTransparency = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer2dOptionsPropertyPieChartShadowColor()
@@ -2390,7 +2609,7 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options = new ezcGraphRenderer2dOptions();
$this->assertSame(
- false,
+ null,
$options->width,
'Wrong default value for property width in class ezcGraphChartOptions'
);
@@ -2401,6 +2620,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->width,
'Setting property value did not work for property width in class ezcGraphChartOptions'
);
+
+ try
+ {
+ $options->width = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartOptionsPropertyHeigh()
@@ -2408,7 +2638,7 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options = new ezcGraphChartOptions();
$this->assertSame(
- false,
+ null,
$options->height,
'Wrong default value for property heigh in class ezcGraphChartOptions'
);
@@ -2419,6 +2649,17 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$options->height,
'Setting property value did not work for property heigh in class ezcGraphChartOptions'
);
+
+ try
+ {
+ $options->height = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testChartOptionsPropertyFont()
diff --git a/tests/renderer_3d_test.php b/tests/renderer_3d_test.php
index 65a5551..bb61bb5 100644
--- a/tests/renderer_3d_test.php
+++ b/tests/renderer_3d_test.php
@@ -1256,6 +1256,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->seperateLines,
'Setting property value did not work for property seperateLines in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->seperateLines = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyFillAxis()
@@ -1274,6 +1285,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->fillAxis,
'Setting property value did not work for property fillAxis in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->fillAxis = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyFillGrid()
@@ -1292,6 +1314,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->fillGrid,
'Setting property value did not work for property fillGrid in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->fillGrid = 42;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyDepth()
@@ -1310,6 +1343,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->depth,
'Setting property value did not work for property depth in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->depth = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyPieChartHeight()
@@ -1317,7 +1361,7 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options = new ezcGraphRenderer3dOptions();
$this->assertSame(
- 10,
+ 10.,
$options->pieChartHeight,
'Wrong default value for property pieChartHeight in class ezcGraphRenderer3dOptions'
);
@@ -1328,6 +1372,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->pieChartHeight,
'Setting property value did not work for property pieChartHeight in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->pieChartHeight = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyPieChartRotation()
@@ -1346,6 +1401,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->pieChartRotation,
'Setting property value did not work for property pieChartRotation in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->pieChartRotation = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyPieChartShadowSize()
@@ -1360,10 +1426,21 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->pieChartShadowSize = 5;
$this->assertSame(
- 5,
+ 5.,
$options->pieChartShadowSize,
'Setting property value did not work for property pieChartShadowSize in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->pieChartShadowSize = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyPieChartShadowTransparency()
@@ -1382,6 +1459,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->pieChartShadowTransparency,
'Setting property value did not work for property pieChartShadowTransparency in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->pieChartShadowTransparency = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyPieChartShadowColor()
@@ -1429,6 +1517,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->barDarkenSide,
'Setting property value did not work for property barDarkenSide in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->barDarkenSide = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyBarDarkenTop()
@@ -1447,6 +1546,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->barDarkenTop,
'Setting property value did not work for property barDarkenTop in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->barDarkenTop = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
public function testRenderer3dOptionsPropertyBarChartGleam()
@@ -1465,6 +1575,17 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
$options->barChartGleam,
'Setting property value did not work for property barChartGleam in class ezcGraphRenderer3dOptions'
);
+
+ try
+ {
+ $options->barChartGleam = false;
+ }
+ catch( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
}
}
?>
OpenPOWER on IntegriCloud