Merge branch '2.7' into 2.8
* 2.7: Remove unused constant Fix passing options with defaultCommand
This commit is contained in:
commit
359e2d9a3d
@ -192,7 +192,12 @@ class Application
|
|||||||
|
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
$name = $this->defaultCommand;
|
$name = $this->defaultCommand;
|
||||||
$input = new ArrayInput(array('command' => $this->defaultCommand));
|
$this->definition->setArguments(array_merge(
|
||||||
|
$this->definition->getArguments(),
|
||||||
|
array(
|
||||||
|
'command' => new InputArgument('command', InputArgument::OPTIONAL, $this->definition->getArgument('command')->getDescription(), $name),
|
||||||
|
)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->runningCommand = null;
|
$this->runningCommand = null;
|
||||||
|
@ -39,6 +39,7 @@ class ApplicationTest extends TestCase
|
|||||||
{
|
{
|
||||||
self::$fixturesPath = realpath(__DIR__.'/Fixtures/');
|
self::$fixturesPath = realpath(__DIR__.'/Fixtures/');
|
||||||
require_once self::$fixturesPath.'/FooCommand.php';
|
require_once self::$fixturesPath.'/FooCommand.php';
|
||||||
|
require_once self::$fixturesPath.'/FooOptCommand.php';
|
||||||
require_once self::$fixturesPath.'/Foo1Command.php';
|
require_once self::$fixturesPath.'/Foo1Command.php';
|
||||||
require_once self::$fixturesPath.'/Foo2Command.php';
|
require_once self::$fixturesPath.'/Foo2Command.php';
|
||||||
require_once self::$fixturesPath.'/Foo3Command.php';
|
require_once self::$fixturesPath.'/Foo3Command.php';
|
||||||
@ -1177,16 +1178,31 @@ class ApplicationTest extends TestCase
|
|||||||
$application->setDefaultCommand($command->getName());
|
$application->setDefaultCommand($command->getName());
|
||||||
|
|
||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
$tester->run(array());
|
$tester->run(array(), array('interactive' => false));
|
||||||
$this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
$this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
||||||
|
|
||||||
$application = new CustomDefaultCommandApplication();
|
$application = new CustomDefaultCommandApplication();
|
||||||
$application->setAutoExit(false);
|
$application->setAutoExit(false);
|
||||||
|
|
||||||
$tester = new ApplicationTester($application);
|
$tester = new ApplicationTester($application);
|
||||||
$tester->run(array());
|
$tester->run(array(), array('interactive' => false));
|
||||||
|
|
||||||
$this->assertEquals('interact called'.PHP_EOL.'called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
$this->assertEquals('called'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetRunCustomDefaultCommandWithOption()
|
||||||
|
{
|
||||||
|
$command = new \FooOptCommand();
|
||||||
|
|
||||||
|
$application = new Application();
|
||||||
|
$application->setAutoExit(false);
|
||||||
|
$application->add($command);
|
||||||
|
$application->setDefaultCommand($command->getName());
|
||||||
|
|
||||||
|
$tester = new ApplicationTester($application);
|
||||||
|
$tester->run(array('--fooopt' => 'opt'), array('interactive' => false));
|
||||||
|
|
||||||
|
$this->assertEquals('called'.PHP_EOL.'opt'.PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
|
class FooOptCommand extends Command
|
||||||
|
{
|
||||||
|
public $input;
|
||||||
|
public $output;
|
||||||
|
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('foo:bar')
|
||||||
|
->setDescription('The foo:bar command')
|
||||||
|
->setAliases(array('afoobar'))
|
||||||
|
->addOption('fooopt', 'fo', InputOption::VALUE_OPTIONAL, 'fooopt description')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function interact(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$output->writeln('interact called');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$this->input = $input;
|
||||||
|
$this->output = $output;
|
||||||
|
|
||||||
|
$output->writeln('called');
|
||||||
|
$output->writeln($this->input->getOption('fooopt'));
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@ Usage:
|
|||||||
help [options] [--] [<command_name>]
|
help [options] [--] [<command_name>]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
command The command to execute
|
command The command to execute [default: "list"]
|
||||||
command_name The command name [default: "help"]
|
command_name The command name [default: "help"]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
@ -20,7 +20,6 @@ use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
|
|||||||
class BCryptPasswordEncoderTest extends TestCase
|
class BCryptPasswordEncoderTest extends TestCase
|
||||||
{
|
{
|
||||||
const PASSWORD = 'password';
|
const PASSWORD = 'password';
|
||||||
const BYTES = '0123456789abcdef';
|
|
||||||
const VALID_COST = '04';
|
const VALID_COST = '04';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user