mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '2.6-remove-subcommand' into 2.6
Merge changes from cakephp/cakephp#4039 into 2.6. This will effectively backports the changes to 2.6, and allows them to be merged into 3.0 at the same time. Closes #4039
This commit is contained in:
commit
7a14ed7490
2 changed files with 26 additions and 0 deletions
|
@ -410,6 +410,17 @@ class ConsoleOptionParser {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a subcommand from the option parser.
|
||||||
|
*
|
||||||
|
* @param string $name The subcommand name to remove.
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function removeSubcommand($name) {
|
||||||
|
unset($this->_subcommands[$name]);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add multiple subcommands at once.
|
* Add multiple subcommands at once.
|
||||||
*
|
*
|
||||||
|
|
|
@ -476,6 +476,21 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
||||||
$this->assertEquals('test', $result['test']->name());
|
$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
|
* test adding multiple subcommands
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue