From ab4ba23931437973386ffa0d32709053fb16681d Mon Sep 17 00:00:00 2001 From: ShinDarth Date: Mon, 2 Jan 2017 09:16:49 +0100 Subject: [PATCH] [Console] increased code coverage of Output classes --- .../Tests/Output/ConsoleOutputTest.php | 16 +++++++ .../Console/Tests/Output/NullOutputTest.php | 48 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php b/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php index 1afbbb6e6cff..b3808c07cfbf 100644 --- a/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Console\Tests\Output; +use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\Output; @@ -22,4 +23,19 @@ public function testConstructor() $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); $this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument'); } + + public function testSetFormatter() + { + $output = new ConsoleOutput(); + $outputFormatter = new OutputFormatter(); + $output->setFormatter($outputFormatter); + $this->assertSame($outputFormatter, $output->getFormatter()); + } + + public function testSetVerbosity() + { + $output = new ConsoleOutput(); + $output->setVerbosity(Output::VERBOSITY_VERBOSE); + $this->assertSame(Output::VERBOSITY_VERBOSE, $output->getVerbosity()); + } } diff --git a/src/Symfony/Component/Console/Tests/Output/NullOutputTest.php b/src/Symfony/Component/Console/Tests/Output/NullOutputTest.php index b20ae4e8d07a..f09573f04da9 100644 --- a/src/Symfony/Component/Console/Tests/Output/NullOutputTest.php +++ b/src/Symfony/Component/Console/Tests/Output/NullOutputTest.php @@ -11,7 +11,9 @@ namespace Symfony\Component\Console\Tests\Output; +use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\Output; use Symfony\Component\Console\Output\OutputInterface; class NullOutputTest extends \PHPUnit_Framework_TestCase @@ -36,4 +38,50 @@ public function testVerbosity() $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); $this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() always returns VERBOSITY_QUIET for NullOutput'); } + + public function testSetFormatter() + { + $output = new NullOutput(); + $outputFormatter = new OutputFormatter(); + $output->setFormatter($outputFormatter); + $this->assertNotSame($outputFormatter, $output->getFormatter()); + } + + public function testSetVerbosity() + { + $output = new NullOutput(); + $output->setVerbosity(Output::VERBOSITY_NORMAL); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity()); + } + + public function testSetDecorated() + { + $output = new NullOutput(); + $output->setDecorated(true); + $this->assertFalse($output->isDecorated()); + } + + public function testIsQuiet() + { + $output = new NullOutput(); + $this->assertTrue($output->isQuiet()); + } + + public function testIsVerbose() + { + $output = new NullOutput(); + $this->assertFalse($output->isVerbose()); + } + + public function testIsVeryVerbose() + { + $output = new NullOutput(); + $this->assertFalse($output->isVeryVerbose()); + } + + public function testIsDebug() + { + $output = new NullOutput(); + $this->assertFalse($output->isDebug()); + } }