pass command name automatically if required by the application

This commit is contained in:
Christian Flothmann 2013-08-01 12:59:52 +02:00 committed by Fabien Potencier
parent 426559f65e
commit 81aead238b

View File

@ -55,6 +55,18 @@ class CommandTester
*/
public function execute(array $input, array $options = array())
{
// set the command name automatically if the application requires
// this argument and no command name was passed
if (!isset($input['command'])) {
$application = $this->command->getApplication();
if (null !== $application) {
$definition = $application->getDefinition();
if ($definition->hasArgument('command')) {
$input['command'] = $this->command->getName();
}
}
}
$this->input = new ArrayInput($input);
if (isset($options['interactive'])) {
$this->input->setInteractive($options['interactive']);