Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 50c8050

Browse files
committed
[Console] pass command name automatically if required by the application
1 parent b970d17 commit 50c8050

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Symfony/Component/Console/Tester/CommandTester.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ public function __construct(Command $command)
5252
*/
5353
public function execute(array $input, array $options = array())
5454
{
55+
// set the command name automatically if the application requires
56+
// this argument and no command name was passed
57+
if (!isset($input['command'])) {
58+
$application = $this->command->getApplication();
59+
if (null !== $application) {
60+
$definition = $application->getDefinition();
61+
if ($definition->hasArgument('command')) {
62+
$input['command'] = $this->command->getName();
63+
}
64+
}
65+
}
66+
5567
$this->input = new ArrayInput($input);
5668
if (isset($options['interactive'])) {
5769
$this->input->setInteractive($options['interactive']);

0 commit comments

Comments
 (0)