Merge branch '2.3' into 2.7
* 2.3: [Console][DX] Fixed ambiguous error message when using a duplicate option shortcut
This commit is contained in:
commit
13394f81f7
@ -297,14 +297,14 @@ class Command
|
||||
return;
|
||||
}
|
||||
|
||||
$this->definition->addOptions($this->application->getDefinition()->getOptions());
|
||||
|
||||
if ($mergeArgs) {
|
||||
$currentArguments = $this->definition->getArguments();
|
||||
$this->definition->setArguments($this->application->getDefinition()->getArguments());
|
||||
$this->definition->addArguments($currentArguments);
|
||||
}
|
||||
|
||||
$this->definition->addOptions($this->application->getDefinition()->getOptions());
|
||||
|
||||
$this->applicationDefinitionMerged = true;
|
||||
if ($mergeArgs) {
|
||||
$this->applicationDefinitionMergedWithArgs = true;
|
||||
|
@ -730,6 +730,33 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @expectedExceptionMessage An option with shortcut "e" already exists.
|
||||
*/
|
||||
public function testAddingOptionWithDuplicateShortcut()
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
$application = new Application();
|
||||
$application->setAutoExit(false);
|
||||
$application->setCatchExceptions(false);
|
||||
$application->setDispatcher($dispatcher);
|
||||
|
||||
$application->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'Environment'));
|
||||
|
||||
$application
|
||||
->register('foo')
|
||||
->setAliases(['f'])
|
||||
->setDefinition(array(new InputOption('survey', 'e', InputOption::VALUE_REQUIRED, 'My option with a shortcut.')))
|
||||
->setCode(function (InputInterface $input, OutputInterface $output) {})
|
||||
;
|
||||
|
||||
$input = new ArrayInput(array('command' => 'foo'));
|
||||
$output = new NullOutput();
|
||||
|
||||
$application->run($input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \LogicException
|
||||
* @dataProvider getAddingAlreadySetDefinitionElementData
|
||||
|
Reference in New Issue
Block a user