[bugfix] [Console] Set `Input::$interactive` to `false` when command is executed with `--quiet` as verbosity level

This commit is contained in:
Javier Spagnoletti 2016-09-12 23:49:02 -03:00
parent 2a9be06bc8
commit 4214311a1c
2 changed files with 4 additions and 1 deletions

View File

@ -337,7 +337,7 @@ class Application
* Adds an array of command objects.
*
* If a Command is not enabled it will not be added.
*
*
* @param Command[] $commands An array of commands
*/
public function addCommands(array $commands)
@ -808,6 +808,7 @@ class Application
if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
$input->setInteractive(false);
} else {
if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) {
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);

View File

@ -636,9 +636,11 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$tester->run(array('command' => 'list', '--quiet' => true));
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed');
$this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if --quiet is passed');
$tester->run(array('command' => 'list', '-q' => true));
$this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed');
$this->assertFalse($tester->getInput()->isInteractive(), '->run() sets off the interactive mode if -q is passed');
$tester->run(array('command' => 'list', '--verbose' => true));
$this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed');