Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8c8958e

Browse filesBrowse files
Merge branch '2.8' into 3.2
* 2.8: Remove unused constant Fix passing options with defaultCommand
2 parents 21f1e10 + 359e2d9 commit 8c8958e
Copy full SHA for 8c8958e

File tree

Expand file treeCollapse file tree

4 files changed

+62
-6
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+62
-6
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,12 @@ public function doRun(InputInterface $input, OutputInterface $output)
190190

191191
if (!$name) {
192192
$name = $this->defaultCommand;
193-
$input = new ArrayInput(array('command' => $this->defaultCommand));
193+
$this->definition->setArguments(array_merge(
194+
$this->definition->getArguments(),
195+
array(
196+
'command' => new InputArgument('command', InputArgument::OPTIONAL, $this->definition->getArgument('command')->getDescription(), $name),
197+
)
198+
));
194199
}
195200

196201
$this->runningCommand = null;

‎src/Symfony/Component/Console/Tests/ApplicationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/ApplicationTest.php
+20-4Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static function setUpBeforeClass()
3939
{
4040
self::$fixturesPath = realpath(__DIR__.'/Fixtures/');
4141
require_once self::$fixturesPath.'/FooCommand.php';
42+
require_once self::$fixturesPath.'/FooOptCommand.php';
4243
require_once self::$fixturesPath.'/Foo1Command.php';
4344
require_once self::$fixturesPath.'/Foo2Command.php';
4445
require_once self::$fixturesPath.'/Foo3Command.php';
@@ -1168,16 +1169,31 @@ public function testSetRunCustomDefaultCommand()
11681169
$application->setDefaultCommand($command->getName());
11691170

11701171
$tester = new ApplicationTester($application);
1171-
$tester->run(array());
1172-
$this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
1172+
$tester->run(array(), array('interactive' => false));
1173+
$this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
11731174

11741175
$application = new CustomDefaultCommandApplication();
11751176
$application->setAutoExit(false);
11761177

11771178
$tester = new ApplicationTester($application);
1178-
$tester->run(array());
1179+
$tester->run(array(), array('interactive' => false));
1180+
1181+
$this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
1182+
}
1183+
1184+
public function testSetRunCustomDefaultCommandWithOption()
1185+
{
1186+
$command = new \FooOptCommand();
1187+
1188+
$application = new Application();
1189+
$application->setAutoExit(false);
1190+
$application->add($command);
1191+
$application->setDefaultCommand($command->getName());
1192+
1193+
$tester = new ApplicationTester($application);
1194+
$tester->run(array('--fooopt' => 'opt'), array('interactive' => false));
11791195

1180-
$this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
1196+
$this->assertEquals('called'.PHP_EOL.'opt'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
11811197
}
11821198

11831199
public function testSetRunCustomSingleCommand()
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
use Symfony\Component\Console\Command\Command;
4+
use Symfony\Component\Console\Input\InputInterface;
5+
use Symfony\Component\Console\Input\InputOption;
6+
use Symfony\Component\Console\Output\OutputInterface;
7+
8+
class FooOptCommand extends Command
9+
{
10+
public $input;
11+
public $output;
12+
13+
protected function configure()
14+
{
15+
$this
16+
->setName('foo:bar')
17+
->setDescription('The foo:bar command')
18+
->setAliases(array('afoobar'))
19+
->addOption('fooopt', 'fo', InputOption::VALUE_OPTIONAL, 'fooopt description')
20+
;
21+
}
22+
23+
protected function interact(InputInterface $input, OutputInterface $output)
24+
{
25+
$output->writeln('interact called');
26+
}
27+
28+
protected function execute(InputInterface $input, OutputInterface $output)
29+
{
30+
$this->input = $input;
31+
$this->output = $output;
32+
33+
$output->writeln('called');
34+
$output->writeln($this->input->getOption('fooopt'));
35+
}
36+
}

‎src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Tests/Encoder/BCryptPasswordEncoderTest.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
class BCryptPasswordEncoderTest extends TestCase
2121
{
2222
const PASSWORD = 'password';
23-
const BYTES = '0123456789abcdef';
2423
const VALID_COST = '04';
2524

2625
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.