Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Console] increased code coverage of Output classes #21124

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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());
}
}