merged branch lyrixx/console-verbosity (PR #8640)
This PR was squashed before being merged into the master branch (closes #8640).
Discussion
----------
[Console] Added more semantic commands to detect verbosity
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | n/a
| License | MIT
| Doc PR | n/a
Commits
-------
0fa3a74
[Console] Added more semantic commands to detect verbosity
This commit is contained in:
commit
041b04feb9
@ -5,6 +5,7 @@ CHANGELOG
|
||||
-----
|
||||
|
||||
* added a way to force terminal dimensions
|
||||
* added convevient method to detect verbosity level
|
||||
* [BC BREAK] made descriptors use output instead of returning a string
|
||||
|
||||
2.3.0
|
||||
|
@ -98,6 +98,26 @@ abstract class Output implements OutputInterface
|
||||
return $this->verbosity;
|
||||
}
|
||||
|
||||
public function isQuiet()
|
||||
{
|
||||
return self::VERBOSITY_QUIET === $this->verbosity;
|
||||
}
|
||||
|
||||
public function isVerbose()
|
||||
{
|
||||
return self::VERBOSITY_VERBOSE <= $this->verbosity;
|
||||
}
|
||||
|
||||
public function isVeryVerbose()
|
||||
{
|
||||
return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
|
||||
}
|
||||
|
||||
public function isDebug()
|
||||
{
|
||||
return self::VERBOSITY_DEBUG <= $this->verbosity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -35,6 +35,35 @@ class OutputTest extends \PHPUnit_Framework_TestCase
|
||||
$output = new TestOutput();
|
||||
$output->setVerbosity(Output::VERBOSITY_QUIET);
|
||||
$this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '->setVerbosity() sets the verbosity');
|
||||
|
||||
$this->assertTrue($output->isQuiet());
|
||||
$this->assertFalse($output->isVerbose());
|
||||
$this->assertFalse($output->isVeryVerbose());
|
||||
$this->assertFalse($output->isDebug());
|
||||
|
||||
$output->setVerbosity(Output::VERBOSITY_NORMAL);
|
||||
$this->assertFalse($output->isQuiet());
|
||||
$this->assertFalse($output->isVerbose());
|
||||
$this->assertFalse($output->isVeryVerbose());
|
||||
$this->assertFalse($output->isDebug());
|
||||
|
||||
$output->setVerbosity(Output::VERBOSITY_VERBOSE);
|
||||
$this->assertFalse($output->isQuiet());
|
||||
$this->assertTrue($output->isVerbose());
|
||||
$this->assertFalse($output->isVeryVerbose());
|
||||
$this->assertFalse($output->isDebug());
|
||||
|
||||
$output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE);
|
||||
$this->assertFalse($output->isQuiet());
|
||||
$this->assertTrue($output->isVerbose());
|
||||
$this->assertTrue($output->isVeryVerbose());
|
||||
$this->assertFalse($output->isDebug());
|
||||
|
||||
$output->setVerbosity(Output::VERBOSITY_DEBUG);
|
||||
$this->assertFalse($output->isQuiet());
|
||||
$this->assertTrue($output->isVerbose());
|
||||
$this->assertTrue($output->isVeryVerbose());
|
||||
$this->assertTrue($output->isDebug());
|
||||
}
|
||||
|
||||
public function testWriteWithVerbosityQuiet()
|
||||
|
Reference in New Issue
Block a user