diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-05-10 07:16:11 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-05-10 07:16:11 +0000 |
commit | bd52f8f8433a944b50d79c6d2d4c20cd982c4620 (patch) | |
tree | d3f3b4a24fd9f826523a3942a6802db44c90090a | |
parent | cabd4817dc80cca8ddeb93b40e0cd18b6b3768de (diff) | |
download | zetacomponents-graph-bd52f8f8433a944b50d79c6d2d4c20cd982c4620.zip zetacomponents-graph-bd52f8f8433a944b50d79c6d2d4c20cd982c4620.tar.gz |
- Fixed issue #10759: Unset implementation broken in array access in datasets
and dataset properties
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/data_container/base.php | 4 | ||||
-rw-r--r-- | src/interfaces/dataset_property.php | 2 | ||||
-rw-r--r-- | tests/dataset_test.php | 160 |
4 files changed, 166 insertions, 3 deletions
@@ -9,6 +9,9 @@ for Angles % 90 != 0 - Fixed issue #10745 (BaxedAxisLabelRenderer wrong label positions for angles: (135 <= $angle <= 325) +- Fixed issue #10759: Unset implementation broken in array access in datasets + and dataset properties + 1.1beta1 - [RELEASEDATE] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/data_container/base.php b/src/data_container/base.php index de2424d..6a78d8a 100644 --- a/src/data_container/base.php +++ b/src/data_container/base.php @@ -81,7 +81,7 @@ class ezcGraphChartDataContainer implements ArrayAccess, Iterator, Countable */ public function offsetGet( $key ) { - if ( !isset( $key ) ) + if ( !isset( $this->data[$key] ) ) { throw new ezcGraphNoSuchDataSetException( $key ); } @@ -123,7 +123,7 @@ class ezcGraphChartDataContainer implements ArrayAccess, Iterator, Countable */ public function offsetUnset( $key ) { - if ( !isset( $key ) ) + if ( !isset( $this->data[$key] ) ) { throw new ezcGraphNoSuchDataSetException( $key ); } diff --git a/src/interfaces/dataset_property.php b/src/interfaces/dataset_property.php index bfff3e6..0550f85 100644 --- a/src/interfaces/dataset_property.php +++ b/src/interfaces/dataset_property.php @@ -159,7 +159,7 @@ abstract class ezcGraphDataSetProperty implements ArrayAccess */ final public function offsetUnset( $key ) { - if ( isset( $this->dataset[$value] ) ) + if ( isset( $this->dataset[$key] ) ) { unset( $this->dataValue[$key] ); } 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.' ); + } } ?> |