Skip to content

Commit

Permalink
[Console] increased code coverage of Output classes
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi authored and nicolas-grekas committed Jan 6, 2017
1 parent 6699928 commit ab4ba23
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php
Expand Up @@ -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;

Expand All @@ -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());
}
}
48 changes: 48 additions & 0 deletions src/Symfony/Component/Console/Tests/Output/NullOutputTest.php
Expand Up @@ -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
Expand All @@ -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());
}
}

0 comments on commit ab4ba23

Please sign in to comment.