summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2007-05-10 07:16:11 +0000
committerKore Nordmann <github@kore-nordmann.de>2007-05-10 07:16:11 +0000
commitbd52f8f8433a944b50d79c6d2d4c20cd982c4620 (patch)
treed3f3b4a24fd9f826523a3942a6802db44c90090a /tests
parentcabd4817dc80cca8ddeb93b40e0cd18b6b3768de (diff)
downloadzetacomponents-graph-bd52f8f8433a944b50d79c6d2d4c20cd982c4620.zip
zetacomponents-graph-bd52f8f8433a944b50d79c6d2d4c20cd982c4620.tar.gz
- Fixed issue #10759: Unset implementation broken in array access in datasets
and dataset properties
Diffstat (limited to 'tests')
-rw-r--r--tests/dataset_test.php160
1 files changed, 160 insertions, 0 deletions
diff --git a/tests/dataset_test.php b/tests/dataset_test.php
index a685766..474c7ef 100644
--- a/tests/dataset_test.php
+++ b/tests/dataset_test.php
@@ -303,5 +303,165 @@ class ezcGraphDataSetTest extends ezcTestCase
$this->fail( 'Expected ezcGraphInvalidArrayDataSourceException.' );
}
+
+ public function testDataSetOffsetExists()
+ {
+ $chart = new ezcGraphPieChart();
+ $chart->data['income'] = new ezcGraphArrayDataSet( array( 2000 => 2345.2, 2456.3, 2567.4 ) );
+
+ $this->assertSame(
+ true,
+ isset( $chart->data['income'] )
+ );
+
+ $this->assertSame(
+ false,
+ isset( $chart->data['non existant'] )
+ );
+ }
+
+ public function testDataSetOffsetGetFailure()
+ {
+ $chart = new ezcGraphPieChart();
+ $chart->data['income'] = new ezcGraphArrayDataSet( array( 2000 => 2345.2, 2456.3, 2567.4 ) );
+
+ try
+ {
+ $chart->data['non existant'];
+ }
+ catch ( ezcGraphNoSuchDataSetException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphNoSuchDataSetException.' );
+ }
+
+ public function testDataSetOffsetSetFailure()
+ {
+ $chart = new ezcGraphPieChart();
+
+ try
+ {
+ $chart->data['income'] = true;
+ }
+ catch ( ezcBaseValueException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcBaseValueException.' );
+ }
+
+ public function testDataSetOffsetUnset()
+ {
+ $chart = new ezcGraphPieChart();
+ $chart->data['income'] = new ezcGraphArrayDataSet( array( 2000 => 2345.2, 2456.3, 2567.4 ) );
+
+ $this->assertSame(
+ true,
+ isset( $chart->data['income'] ),
+ 'Offset should exist here.'
+ );
+
+ unset( $chart->data['income'] );
+
+ $this->assertSame(
+ false,
+ isset( $chart->data['income'] ),
+ 'Offset should not exist any more.'
+ );
+ }
+
+ public function testDataSetOffsetUnsetFailure()
+ {
+ $chart = new ezcGraphPieChart();
+ $chart->data['income'] = new ezcGraphArrayDataSet( array( 2000 => 2345.2, 2456.3, 2567.4 ) );
+
+ try
+ {
+ unset( $chart->data['non existant'] );
+ }
+ catch ( ezcGraphNoSuchDataSetException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphNoSuchDataSetException.' );
+ }
+
+ public function testDataSetPropertyOffsetExists()
+ {
+ $chart = new ezcGraphPieChart();
+ $chart->data['income'] = new ezcGraphArrayDataSet( array( 2000 => 2345.2, 2456.3, 2567.4 ) );
+ $chart->data['income']->highlight[2000] = true;
+
+ $this->assertSame(
+ true,
+ isset( $chart->data['income']->highlight[2000] )
+ );
+
+ $this->assertSame(
+ false,
+ isset( $chart->data['income']->highlight[42] )
+ );
+ }
+
+ public function testDataSetPropertyOffsetGetFailure()
+ {
+ $chart = new ezcGraphPieChart();
+ $chart->data['income'] = new ezcGraphArrayDataSet( array( 2000 => 2345.2, 2456.3, 2567.4 ) );
+ $chart->data['income']->highlight[2000] = true;
+
+ try
+ {
+ $chart->data['income']->highlight[42];
+ }
+ catch ( ezcGraphNoSuchDataException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphNoSuchDataException.' );
+ }
+
+ public function testDataSetPropertyOffsetUnset()
+ {
+ $chart = new ezcGraphPieChart();
+ $chart->data['income'] = new ezcGraphArrayDataSet( array( 2000 => 2345.2, 2456.3, 2567.4 ) );
+ $chart->data['income']->highlight[2000] = true;
+
+ $this->assertSame(
+ true,
+ $chart->data['income']->highlight[2000],
+ 'Offset should exist here.'
+ );
+
+ unset( $chart->data['income']->highlight[2000] );
+
+ $this->assertSame(
+ false,
+ $chart->data['income']->highlight[2000],
+ 'Offset should not exist any more.'
+ );
+ }
+
+ public function testDataSetPropertyOffsetUnsetFailure()
+ {
+ $chart = new ezcGraphPieChart();
+ $chart->data['income'] = new ezcGraphArrayDataSet( array( 2000 => 2345.2, 2456.3, 2567.4 ) );
+ $chart->data['income']->highlight[2000] = true;
+
+ try
+ {
+ unset( $chart->data['income']->highlight[42] );
+ }
+ catch ( ezcGraphNoSuchDataException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphNoSuchDataException.' );
+ }
}
?>
OpenPOWER on IntegriCloud