diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2006-10-27 11:34:51 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2006-10-27 11:34:51 +0000 |
commit | ea523b19b2f15e5c08541897a9685f94ff4ebbae (patch) | |
tree | 4d1359d8b431f4b0b2a1f1b38754c4986d1a4c2f | |
parent | 4ed2de1f6271653a6f965237a245d0d4c2535aab (diff) | |
download | zetacomponents-graph-ea523b19b2f15e5c08541897a9685f94ff4ebbae.zip zetacomponents-graph-ea523b19b2f15e5c08541897a9685f94ff4ebbae.tar.gz |
- Added tests for structs
-rw-r--r-- | src/structs/coordinate.php | 4 | ||||
-rw-r--r-- | tests/struct_test.php | 199 | ||||
-rw-r--r-- | tests/suite.php | 2 |
3 files changed, 203 insertions, 2 deletions
diff --git a/src/structs/coordinate.php b/src/structs/coordinate.php index c84683f..bbdd077 100644 --- a/src/structs/coordinate.php +++ b/src/structs/coordinate.php @@ -70,8 +70,8 @@ class ezcGraphCoordinate */ public function __set_state( array $properties ) { - $this->x = (float) $properties['x']; - $this->y = (float) $properties['y']; + $this->x = $properties['x']; + $this->y = $properties['y']; } } diff --git a/tests/struct_test.php b/tests/struct_test.php new file mode 100644 index 0000000..70333be --- /dev/null +++ b/tests/struct_test.php @@ -0,0 +1,199 @@ +<?php +/** + * ezcGraphStructTest + * + * @package Graph + * @version //autogen// + * @subpackage Tests + * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved. + * @license http://ez.no/licenses/new_bsd New BSD License + */ + +/** + * Tests for ezcGraph class. + * + * @package ImageAnalysis + * @subpackage Tests + */ +class ezcGraphStructTest extends ezcTestCase +{ + public static function suite() + { + return new PHPUnit_Framework_TestSuite( "ezcGraphStructTest" ); + } + + public function testCreateContext() + { + $context = new ezcGraphContext( 'set', 'point' ); + + $this->assertSame( + 'set', + $context->dataset, + 'Wrong value when reading public property dataset in ezcGraphContext.' + ); + + $this->assertSame( + 'point', + $context->datapoint, + 'Wrong value when reading public property datapoint in ezcGraphContext.' + ); + + $context->dataset = 'set 2'; + $context->datapoint = 'point 2'; + + $this->assertSame( + 'set 2', + $context->dataset, + 'Wrong value when reading public property dataset in ezcGraphContext.' + ); + + $this->assertSame( + 'point 2', + $context->datapoint, + 'Wrong value when reading public property datapoint in ezcGraphContext.' + ); + } + + public function testContextUnknowPropertySet() + { + $context = new ezcGraphContext( 'set', 'point' ); + + try + { + $context->unknown = 42; + } + catch ( ezcBasePropertyNotFoundException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBasePropertyNotFoundException.' ); + } + + public function testContextUnknowPropertyGet() + { + $context = new ezcGraphContext( 'set', 'point' ); + + try + { + $context->unknown; + } + catch ( ezcBasePropertyNotFoundException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBasePropertyNotFoundException.' ); + } + + public function testContextSetState() + { + $context = new ezcGraphContext(); + + $context->__set_state( + array( + 'dataset' => 'set', + 'datapoint' => 'point', + ) ); + + $this->assertSame( + 'set', + $context->dataset, + 'Wrong value when reading public property dataset in ezcGraphContext.' + ); + + $this->assertSame( + 'point', + $context->datapoint, + 'Wrong value when reading public property datapoint in ezcGraphContext.' + ); + } + + public function testCreateCoordinate() + { + $context = new ezcGraphCoordinate( 23, 42 ); + + $this->assertSame( + 23, + $context->x, + 'Wrong value when reading public property x in ezcGraphCoordinate.' + ); + + $this->assertSame( + 42, + $context->y, + 'Wrong value when reading public property y in ezcGraphCoordinate.' + ); + + $context->x = 5; + $context->y = 12; + + $this->assertSame( + 5, + $context->x, + 'Wrong value when reading public property x in ezcGraphCoordinate.' + ); + + $this->assertSame( + 12, + $context->y, + 'Wrong value when reading public property y in ezcGraphCoordinate.' + ); + } + + public function testCoordinateUnknowPropertySet() + { + $context = new ezcGraphCoordinate( 23, 42 ); + + try + { + $context->unknown = 42; + } + catch ( ezcBasePropertyNotFoundException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBasePropertyNotFoundException.' ); + } + + public function testCoordinateUnknowPropertyGet() + { + $context = new ezcGraphCoordinate( 23, 42 ); + + try + { + $context->unknown; + } + catch ( ezcBasePropertyNotFoundException $e ) + { + return true; + } + + $this->fail( 'Expected ezcBasePropertyNotFoundException.' ); + } + + public function testCoordinateSetState() + { + $context = new ezcGraphCoordinate(); + + $context->__set_state( + array( + 'x' => 23, + 'y' => 42, + ) ); + + $this->assertSame( + 23, + $context->x, + 'Wrong value when reading public property x in ezcGraphCoordinate.' + ); + + $this->assertSame( + 42, + $context->y, + 'Wrong value when reading public property y in ezcGraphCoordinate.' + ); + } +} +?> diff --git a/tests/suite.php b/tests/suite.php index 318f433..9f97d9c 100644 --- a/tests/suite.php +++ b/tests/suite.php @@ -37,6 +37,7 @@ require_once 'palette_test.php'; require_once 'matrix_test.php'; require_once 'boundings_test.php'; require_once 'polynom_test.php'; +require_once 'struct_test.php'; require_once 'image_map_test.php'; /** @@ -77,6 +78,7 @@ class ezcGraphSuite extends PHPUnit_Framework_TestSuite $this->addTest( ezcGraphMatrixTest::suite() ); $this->addTest( ezcGraphBoundingsTest::suite() ); $this->addTest( ezcGraphPolynomTest::suite() ); + $this->addTest( ezcGraphStructTest::suite() ); $this->addTest( ezcGraphImageMapTest::suite() ); } |