summaryrefslogtreecommitdiffstats
path: root/tests/color_test.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-05-09 10:04:46 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-05-09 10:04:46 +0000
commitb1a7160bf0bda45f2a2e818e09446bd53e2162c1 (patch)
treed1f8493ecdf0c3ff0eaeb100e4a445104deab4bd /tests/color_test.php
parentee8e254fcaa69679b828a78b7d6666157170224b (diff)
downloadzetacomponents-graph-b1a7160bf0bda45f2a2e818e09446bd53e2162c1.zip
zetacomponents-graph-b1a7160bf0bda45f2a2e818e09446bd53e2162c1.tar.gz
- Completed color tests
- Implemented factory methods in ezcGraphColor
Diffstat (limited to 'tests/color_test.php')
-rw-r--r--tests/color_test.php142
1 files changed, 142 insertions, 0 deletions
diff --git a/tests/color_test.php b/tests/color_test.php
new file mode 100644
index 0000000..90beced
--- /dev/null
+++ b/tests/color_test.php
@@ -0,0 +1,142 @@
+<?php
+/**
+ * ezcGraphColorTest
+ *
+ * @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 ezcGraphColorTest extends ezcTestCase
+{
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcGraphColorTest" );
+ }
+
+ /**
+ * setUp
+ *
+ * @access public
+ */
+ public function setUp()
+ {
+ }
+
+ /**
+ * tearDown
+ *
+ * @access public
+ */
+ public function tearDown()
+ {
+ }
+
+ public function testFactoryColorFromHex()
+ {
+ $color = ezcGraphColor::fromHex( '#05172A' );
+
+ $this->assertEquals( $color->red, 5, 'Wrong red color value' );
+ $this->assertEquals( $color->green, 23, 'Wrong green color value' );
+ $this->assertEquals( $color->blue, 42, 'Wrong blue color value' );
+ $this->assertEquals( $color->alpha, 0, 'Wrong alpha color value' );
+ }
+
+ public function testFactoryColorFromHexWithAlpha()
+ {
+ $color = ezcGraphColor::fromHex( '#05172A40' );
+
+ $this->assertEquals( $color->red, 5, 'Wrong red color value' );
+ $this->assertEquals( $color->green, 23, 'Wrong green color value' );
+ $this->assertEquals( $color->blue, 42, 'Wrong blue color value' );
+ $this->assertEquals( $color->alpha, 64, 'Wrong alpha color value' );
+ }
+
+ public function testFactoryColorFromIntegerArray()
+ {
+ $color = ezcGraphColor::fromIntegerArray( array( 5, 23, 42 ) );
+
+ $this->assertEquals( $color->red, 5, 'Wrong red color value' );
+ $this->assertEquals( $color->green, 23, 'Wrong green color value' );
+ $this->assertEquals( $color->blue, 42, 'Wrong blue color value' );
+ $this->assertEquals( $color->alpha, 0, 'Wrong alpha color value' );
+ }
+
+ public function testFactoryColorFromFloatArray()
+ {
+ $color = ezcGraphColor::fromFloatArray( array( .02, .092, .165 ) );
+
+ $this->assertEquals( $color->red, 5, 'Wrong red color value' );
+ $this->assertEquals( $color->green, 23, 'Wrong green color value' );
+ $this->assertEquals( $color->blue, 42, 'Wrong blue color value' );
+ $this->assertEquals( $color->alpha, 0, 'Wrong alpha color value' );
+ }
+
+ public function testFactoryColorCreateFromHex()
+ {
+ $color = ezcGraphColor::create( '#05172A' );
+
+ $this->assertEquals( $color->red, 5, 'Wrong red color value' );
+ $this->assertEquals( $color->green, 23, 'Wrong green color value' );
+ $this->assertEquals( $color->blue, 42, 'Wrong blue color value' );
+ $this->assertEquals( $color->alpha, 0, 'Wrong alpha color value' );
+ }
+
+ public function testFactoryColorCreateFromHexWithAlpha()
+ {
+ $color = ezcGraphColor::create( '#05172A40' );
+
+ $this->assertEquals( $color->red, 5, 'Wrong red color value' );
+ $this->assertEquals( $color->green, 23, 'Wrong green color value' );
+ $this->assertEquals( $color->blue, 42, 'Wrong blue color value' );
+ $this->assertEquals( $color->alpha, 64, 'Wrong alpha color value' );
+ }
+
+ public function testFactoryColorCreateFromIntegerArray()
+ {
+ $color = ezcGraphColor::create( array( 5, 23, 42 ) );
+
+ $this->assertEquals( $color->red, 5, 'Wrong red color value' );
+ $this->assertEquals( $color->green, 23, 'Wrong green color value' );
+ $this->assertEquals( $color->blue, 42, 'Wrong blue color value' );
+ $this->assertEquals( $color->alpha, 0, 'Wrong alpha color value' );
+ }
+
+ public function testFactoryColorCreateFromFloatArray()
+ {
+ $color = ezcGraphColor::create( array( .02, .092, .165 ) );
+
+ $this->assertEquals( $color->red, 5, 'Wrong red color value' );
+ $this->assertEquals( $color->green, 23, 'Wrong green color value' );
+ $this->assertEquals( $color->blue, 42, 'Wrong blue color value' );
+ $this->assertEquals( $color->alpha, 0, 'Wrong alpha color value' );
+ }
+
+ public function testFactoryUnknownColorDefinition()
+ {
+ try
+ {
+ $color = ezcGraphColor::create( 1337 );
+ }
+ catch ( ezcGraphUnknownColorDefinitionException $e )
+ {
+ return true;
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $this->fail( 'Expected ezcGraphUnknownColorDefinitionException' );
+ }
+}
+?>
OpenPOWER on IntegriCloud