mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing issue where exceptions for missing required arguments would be raised when trying to get help.
This commit is contained in:
parent
43646b9372
commit
2af684cbec
2 changed files with 15 additions and 1 deletions
|
@ -436,7 +436,7 @@ class ConsoleOptionParser {
|
|||
}
|
||||
}
|
||||
foreach ($this->_args as $i => $arg) {
|
||||
if ($arg->isRequired() && !isset($args[$i])) {
|
||||
if ($arg->isRequired() && !isset($args[$i]) && empty($params['help'])) {
|
||||
throw new RuntimeException(
|
||||
sprintf(__('Missing required arguments. %s is required.'), $arg->name())
|
||||
);
|
||||
|
|
|
@ -396,6 +396,20 @@ TEXT;
|
|||
$this->assertEquals($expected, $result, 'Help does not match');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that no exception is triggered when help is being generated
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testHelpNoExceptionWhenGettingHelp() {
|
||||
$parser = new ConsoleOptionParser('mycommand', false);
|
||||
$parser->addOption('test', array('help' => 'A test option.'))
|
||||
->addArgument('model', array('help' => 'The model to make.', 'required' => true));
|
||||
|
||||
$result = $parser->parse(array('--help'));
|
||||
$this->assertTrue($result[0]['help']);
|
||||
}
|
||||
|
||||
/**
|
||||
* test help() with options and arguments that have choices.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue