Skip to content
Permalink
Browse files

Add removeSubcommand in ConsoleOptionParser

  • Loading branch information...
TamiasSibiricus authored and markstory committed Jul 20, 2014
1 parent 183c1e1 commit 79dc624062582ac57ce4ca19f8945d8addc6b92e
Showing with 26 additions and 0 deletions.
  1. +11 −0 lib/Cake/Console/ConsoleOptionParser.php
  2. +15 −0 lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php
@@ -410,6 +410,17 @@ public function addSubcommand($name, $options = array()) {
return $this;
}
/**
* Remove an subcommand from the option parser.
*
* @param string $name The subcommand name to remove.
* @return ConsoleOptionParser this
*/
public function removeSubcommand($name) {
unset($this->_subcommands[$name]);
return $this;
}
/**
* Add multiple subcommands at once.
*
@@ -476,6 +476,21 @@ public function testAddSubcommandObject() {
$this->assertEquals('test', $result['test']->name());
}
/**
* test removeSubcommand with an object.
*
* @return void
*/
public function testRemoveSubcommand() {
$parser = new ConsoleOptionParser('test', false);
$parser->addSubcommand(new ConsoleInputSubcommand('test'));
$result = $parser->subcommands();
$this->assertEquals(1, count($result));
$parser->removeSubcommand('test');
$result = $parser->subcommands();
$this->assertEquals(0, count($result), 'Remove a subcommand does not work');
}
/**
* test adding multiple subcommands
*

0 comments on commit 79dc624

Please sign in to comment.
You can’t perform that action at this time.