Author: Tobias Schlitt
Date: 2006-09-24 13:45:39 +0200 (Sun, 24 Sep 2006)
New Revision: 3558
Log:
- Fixed bug #9052: Exception because of invalid property in ezcConsoleOption.
Added:
trunk/ConsoleTools/tests/option_test.php
Modified:
trunk/ConsoleTools/ChangeLog
trunk/ConsoleTools/src/input/option.php
Modified: trunk/ConsoleTools/ChangeLog
===================================================================
--- trunk/ConsoleTools/ChangeLog 2006-09-24 10:33:21 UTC (rev 3557)
+++ trunk/ConsoleTools/ChangeLog 2006-09-24 11:45:39 UTC (rev 3558)
@@ -3,6 +3,7 @@
- Added feature to print to a different output target (e.g. stderr).
- Fixed bug 9046: Last argument not treated invalid option value.
+- Fixed bug #9052: Exception because of invalid property in ezcConsoleOption.
1.1.2 - Monday 28 August 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Modified: trunk/ConsoleTools/src/input/option.php
===================================================================
--- trunk/ConsoleTools/src/input/option.php 2006-09-24 10:33:21 UTC (rev
3557)
+++ trunk/ConsoleTools/src/input/option.php 2006-09-24 11:45:39 UTC (rev
3558)
@@ -250,7 +250,7 @@
{
foreach ( $this->dependencies as $id => $rule )
{
- if ( $rule->param === $param )
+ if ( $rule->option === $param )
{
unset( $this->dependencies[$id] );
}
@@ -269,7 +269,7 @@
{
foreach ( $this->dependencies as $id => $rule )
{
- if ( $rule->param === $param )
+ if ( $rule->option === $param )
{
return true;
}
@@ -360,7 +360,7 @@
{
foreach ( $this->exclusions as $id => $rule )
{
- if ( $rule->param === $param )
+ if ( $rule->option === $param )
{
unset( $this->exclusions[$id] );
}
@@ -379,7 +379,7 @@
{
foreach ( $this->exclusions as $id => $rule )
{
- if ( $rule->param === $param )
+ if ( $rule->option === $param )
{
return true;
}
Added: trunk/ConsoleTools/tests/option_test.php
===================================================================
--- trunk/ConsoleTools/tests/option_test.php 2006-09-24 10:33:21 UTC (rev
3557)
+++ trunk/ConsoleTools/tests/option_test.php 2006-09-24 11:45:39 UTC (rev
3558)
@@ -0,0 +1,235 @@
+<?php
+/**
+ * ezcConsoleToolsOptionTest
+ *
+ * @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 ezcConsoleToolsOptionTest extends ezcTestCase
+{
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcConsoleToolsOptionTest" );
+ }
+
+ public function testAddDependencyExisting()
+ {
+ $option_1 = new ezcConsoleOption(
+ "a",
+ "aaa"
+ );
+ $option_2 = new ezcConsoleOption(
+ "b",
+ "bbb"
+ );
+
+ $rule = new ezcConsoleOptionRule(
+ $option_2, array( "c" )
+ );
+
+ $option_1->addDependency( $rule );
+ $option_1->addDependency( $rule );
+
+ $this->assertAttributeEquals(
+ array( $rule ),
+ "dependencies",
+ $option_1
+ );
+ }
+
+ // Bug #9052: Exception because of invalid property in ezcConsoleOption
+ public function testRemoveDependency()
+ {
+ $option_1 = new ezcConsoleOption(
+ "a",
+ "aaa"
+ );
+ $option_2 = new ezcConsoleOption(
+ "b",
+ "bbb"
+ );
+
+ $rule_1 = new ezcConsoleOptionRule(
+ $option_2, array( "c" )
+ );
+
+ $rule_2 = new ezcConsoleOptionRule(
+ $option_2, array( "d" )
+ );
+
+ $option_1->addDependency( $rule_1 );
+ $option_1->addDependency( $rule_2 );
+ $option_1->removeAllDependencies( $option_2 );
+
+ $this->assertAttributeEquals(
+ array(),
+ "dependencies",
+ $option_1
+ );
+ }
+
+ // Bug #9052: Exception because of invalid property in ezcConsoleOption
+ public function testHasDependency()
+ {
+ $option_1 = new ezcConsoleOption(
+ "a",
+ "aaa"
+ );
+ $option_2 = new ezcConsoleOption(
+ "b",
+ "bbb"
+ );
+
+ $rule = new ezcConsoleOptionRule(
+ $option_2, array( "c" )
+ );
+
+ $option_1->addDependency( $rule );
+
+ $this->assertTrue(
+ $option_1->hasDependency( $option_2 )
+ );
+ }
+
+ public function testResetDependencies()
+ {
+ $option_1 = new ezcConsoleOption(
+ "a",
+ "aaa"
+ );
+ $option_2 = new ezcConsoleOption(
+ "b",
+ "bbb"
+ );
+
+ $rule = new ezcConsoleOptionRule(
+ $option_2, array( "c" )
+ );
+
+ $option_1->addDependency( $rule );
+ $option_1->resetDependencies();
+
+ $this->assertAttributeEquals(
+ array(),
+ "dependencies",
+ $option_1
+ );
+ }
+
+ public function testAddExclusionExisting()
+ {
+ $option_1 = new ezcConsoleOption(
+ "a",
+ "aaa"
+ );
+ $option_2 = new ezcConsoleOption(
+ "b",
+ "bbb"
+ );
+
+ $rule = new ezcConsoleOptionRule(
+ $option_2, array( "c" )
+ );
+
+ $option_1->addExclusion( $rule );
+ $option_1->addExclusion( $rule );
+
+ $this->assertAttributeEquals(
+ array( $rule ),
+ "exclusions",
+ $option_1
+ );
+ }
+
+ // Bug #9052: Exception because of invalid property in ezcConsoleOption
+ public function testRemoveExclusion()
+ {
+ $option_1 = new ezcConsoleOption(
+ "a",
+ "aaa"
+ );
+ $option_2 = new ezcConsoleOption(
+ "b",
+ "bbb"
+ );
+
+ $rule_1 = new ezcConsoleOptionRule(
+ $option_2, array( "c" )
+ );
+
+ $rule_2 = new ezcConsoleOptionRule(
+ $option_2, array( "d" )
+ );
+
+ $option_1->addExclusion( $rule_1 );
+ $option_1->addExclusion( $rule_2 );
+ $option_1->removeAllExclusions( $option_2 );
+
+ $this->assertAttributeEquals(
+ array(),
+ "exclusions",
+ $option_1
+ );
+ }
+
+ // Bug #9052: Exception because of invalid property in ezcConsoleOption
+ public function testHasExclusion()
+ {
+ $option_1 = new ezcConsoleOption(
+ "a",
+ "aaa"
+ );
+ $option_2 = new ezcConsoleOption(
+ "b",
+ "bbb"
+ );
+
+ $rule = new ezcConsoleOptionRule(
+ $option_2, array( "c" )
+ );
+
+ $option_1->addExclusion( $rule );
+
+ $this->assertTrue(
+ $option_1->hasExclusion( $option_2 )
+ );
+ }
+
+ public function testResetExclusions()
+ {
+ $option_1 = new ezcConsoleOption(
+ "a",
+ "aaa"
+ );
+ $option_2 = new ezcConsoleOption(
+ "b",
+ "bbb"
+ );
+
+ $rule = new ezcConsoleOptionRule(
+ $option_2, array( "c" )
+ );
+
+ $option_1->addExclusion( $rule );
+ $option_1->resetExclusions();
+
+ $this->assertAttributeEquals(
+ array(),
+ "exclusions",
+ $option_1
+ );
+ }
+}
+
+?>
Property changes on: trunk/ConsoleTools/tests/option_test.php
___________________________________________________________________
Name: svn:eol-style
+ native
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components