Skip to content

Commit

Permalink
minor #21124 [Console] increased code coverage of Output classes (Shi…
Browse files Browse the repository at this point in the history
…nDarth)

This PR was squashed before being merged into the 2.7 branch (closes #21124).

Discussion
----------

[Console] increased code coverage of Output classes

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

This PR increases the coverage of Output classes of the Console component from 80.81% to 94.95%

Commits
-------

ab4ba23 [Console] increased code coverage of Output classes
  • Loading branch information
nicolas-grekas committed Jan 6, 2017
2 parents 4864e9d + ab4ba23 commit 1038221
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 1038221

Please sign in to comment.