mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Add removeSubcommand in ConsoleOptionParser
This commit is contained in:
parent
183c1e1276
commit
79dc624062
2 changed files with 26 additions and 0 deletions
|
@ -410,6 +410,17 @@ class ConsoleOptionParser {
|
|||
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 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
|||
$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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue