8000 Merge branch '3.2' into 3.3 · symfony/symfony@75c3eca · GitHub
[go: up one dir, main page]

Skip to content

Commit 75c3eca

Browse files
Merge branch '3.2' into 3.3
* 3.2: Remove unused constant Fix passing options with defaultCommand
2 parents a6f44d2 + 8c8958e commit 75c3eca

File tree

4 files changed

+62
-6
lines changed

4 files changed

+62
-6
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,12 @@ public function doRun(InputInterface $input, OutputInterface $output)
195195

196196
if (!$name) {
197197
$name = $this->defaultCommand;
198-
$input = new ArrayInput(array('command' => $this->defaultCommand));
198+
$this->definition->setArguments(array_merge(
199+
$this->definition->getArguments(),
200+
array(
201+
'command' => new InputArgument('command', InputArgument::OPTIONAL, $this->definition->getArgument('command')->getDescription(), $name),
202+
)
203+
));
199204
}
200205

201206
try {

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public static function setUpBeforeClass()
4141
{
4242
self::$fixturesPath = realpath(__DIR__.'/Fixtures/');
4343
require_once self::$fixturesPath.'/FooCommand.php';
44+
require_once self::$fixturesPath.'/FooOptCommand.php';
4445
require_once self::$fixturesPath.'/Foo1Command.php';
4546
require_once self::$fixturesPath.'/Foo2Command.php';
4647
require_once self::$fixturesPath.'/Foo3Command.php';
@@ -1315,16 +1316,31 @@ public function testSetRunCustomDefaultCommand()
13151316
$application->setDefaultCommand($command->getName());
13161317

13171318
$tester = new ApplicationTester($application);
1318-
$tester->run(array());
1319-
$this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
1319+
$tester->run(array(), array('interactive' => false));
1320+
$this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
13201321

13211322
$application = new CustomDefaultCommandApplication();
13221323
$application->setAutoExit(false);
13231324

13241325
$tester = new ApplicationTester($application);
1325-
$tester->run(array());
1326+
$tester->run(array(), array('interactive' => false));
1327+
1328+
$this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
1329+
}
1330+
1331+
public function testSetRunCustomDefaultCommandWithOption()
1332+
{
1333+
$command = new \FooOptCommand();
1334+
1335+
$application = new Application();
1336+
$application->setAutoExit(false);
1337+
$application->add($command);
1338+
$application->setDefaultCommand($command->getName());
1339+
1340+
$tester = new ApplicationTester($application);
1341+
$tester->run(array('--fooopt' => 'opt'), array('interactive' => false));
13261342

1327-
$this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
1343+
$this->assertEquals('called'.PHP_EOL.'opt'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
13281344
}
13291345

13301346
public function testSetRunCustomSingleCommand()
Lines 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

Lines 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