bug #19923 [bugfix] [Console] Set `Input::$interactive` to `false` when command is executed with `--quiet` as verbosity level (phansys)

This PR was merged into the 2.7 branch.

Discussion
----------

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

|Q            |A     |
|---          |---   |
|Branch       |2.7   |
|Bug fix?     |yes   |
|New feature? |no    |
|BC breaks?   |yes    |
|Deprecations?|no    |
|Tests pass?  |yes   |
|Fixed tickets|#19899|
|License      |MIT   |
|Doc PR       |n/a   |

Closes #19899.

Commits
-------

4214311 [bugfix] [Console] Set `Input::$interactive` to `false` when command is executed with `--quiet` as verbosity level
This commit is contained in:
Fabien Potencier 2016-09-14 13:28:32 -07:00
commit c1cc6ca40e
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');