Author: Tobias Schlitt
Date: 2006-09-24 18:18:30 +0200 (Sun, 24 Sep 2006)
New Revision: 3561

Log:
- Added more tests.

Added:
   trunk/ConsoleTools/tests/option_rule_test.php
Modified:
   trunk/ConsoleTools/tests/suite.php

Added: trunk/ConsoleTools/tests/option_rule_test.php
===================================================================
--- trunk/ConsoleTools/tests/option_rule_test.php       2006-09-24 15:27:52 UTC 
(rev 3560)
+++ trunk/ConsoleTools/tests/option_rule_test.php       2006-09-24 16:18:30 UTC 
(rev 3561)
@@ -0,0 +1,112 @@
+<?php
+/**
+ * ezcConsoleToolsOptionRuleTest
+ * 
+ * @package ConsoleTools
+ * @subpackage Tests
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Test suite for ezcConsoleOption class.
+ * 
+ * @package ConsoleTools
+ * @subpackage Tests
+ */
+class ezcConsoleToolsOptionRuleTest extends ezcTestCase
+{
+
+       public static function suite()
+       {
+               return new ezcTestSuite( "ezcConsoleToolsOptionRuleTest" );
+       }
+
+    public function testGetAccessSuccess()
+    {
+        $option = new ezcConsoleOption( "a", "aaa" );
+        $rule = new ezcConsoleOptionRule( $option, array( "a", "b", "c" ) );
+
+        $this->assertSame( $option, $rule->option );
+        $this->assertEquals( array( "a", "b", "c" ), $rule->values );
+    }
+
+    public function testGetAccessFailure()
+    {
+        $option = new ezcConsoleOption( "a", "aaa" );
+        $rule = new ezcConsoleOptionRule( $option, array( "a", "b", "c" ) );
+
+        try
+        {
+            $foo = $rule->nonExistent;
+        }
+        catch ( ezcBasePropertyNotFoundException $e )
+        {
+            return true;
+        }
+        $this->fail( "Exception not thrown on access of invalid property." );
+    }
+    
+    public function testSetAccessSuccess()
+    {
+        $option = new ezcConsoleOption( "a", "aaa" );
+        $rule = new ezcConsoleOptionRule( $option, array( "a" ) );
+
+        $rule->option = $option;
+        $rule->values = array( "a", "b", "c" );
+
+        $this->assertSame( $option, $rule->option );
+        $this->assertEquals( array( "a", "b", "c" ), $rule->values );
+    }
+
+    public function testSetAccessFailureOption()
+    {
+        $option = new ezcConsoleOption( "a", "aaa" );
+        $rule = new ezcConsoleOptionRule( $option, array( "a" ) );
+
+        try
+        {
+            $rule->option = array();
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return;
+        }
+        $this->fail( "Exception not thrown on invalid value for 
ezcConsoleOptionRule->option." );
+    }
+
+    public function testSetAccessFailureValues()
+    {
+        $option = new ezcConsoleOption( "a", "aaa" );
+        $rule = new ezcConsoleOptionRule( $option, array( "a" ) );
+
+        try
+        {
+            $rule->values = 23;
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return;
+        }
+        $this->fail( "Exception not thrown on invalid value for 
ezcConsoleOptionRule->values." );
+    }
+
+    public function testSetAccessFailureNonExsitent()
+    {
+        $option = new ezcConsoleOption( "a", "aaa" );
+        $rule = new ezcConsoleOptionRule( $option, array( "a" ) );
+
+        try
+        {
+            $rule->values = 23;
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            return;
+        }
+        $this->fail( "Exception not thrown on invalid value for 
ezcConsoleOptionRule->values." );
+    }
+}
+
+?>


Property changes on: trunk/ConsoleTools/tests/option_rule_test.php
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/ConsoleTools/tests/suite.php
===================================================================
--- trunk/ConsoleTools/tests/suite.php  2006-09-24 15:27:52 UTC (rev 3560)
+++ trunk/ConsoleTools/tests/suite.php  2006-09-24 16:18:30 UTC (rev 3561)
@@ -93,6 +93,7 @@
                $this->addTest( ezcConsoleToolsOutputOptionsTest::suite() );
                $this->addTest( ezcConsoleToolsInputTest::suite() );
                $this->addTest( ezcConsoleToolsOptionTest::suite() );
+               $this->addTest( ezcConsoleToolsOptionRuleTest::suite() );
                $this->addTest( ezcConsoleToolsTableCellTest::suite() );
                $this->addTest( ezcConsoleToolsTableRowTest::suite() );
                $this->addTest( ezcConsoleToolsTableTest::suite() );

-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to