4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Console\Tests\Output;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Console\Formatter\OutputFormatter;
16 use Symfony\Component\Console\Output\NullOutput;
17 use Symfony\Component\Console\Output\Output;
18 use Symfony\Component\Console\Output\OutputInterface;
20 class NullOutputTest extends TestCase
22 public function testConstructor()
24 $output = new NullOutput();
27 $output->write('foo');
28 $buffer = ob_get_clean();
30 $this->assertSame('', $buffer, '->write() does nothing (at least nothing is printed)');
31 $this->assertFalse($output->isDecorated(), '->isDecorated() returns false');
34 public function testVerbosity()
36 $output = new NullOutput();
37 $this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() returns VERBOSITY_QUIET for NullOutput by default');
39 $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
40 $this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() always returns VERBOSITY_QUIET for NullOutput');
43 public function testSetFormatter()
45 $output = new NullOutput();
46 $outputFormatter = new OutputFormatter();
47 $output->setFormatter($outputFormatter);
48 $this->assertNotSame($outputFormatter, $output->getFormatter());
51 public function testSetVerbosity()
53 $output = new NullOutput();
54 $output->setVerbosity(Output::VERBOSITY_NORMAL);
55 $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity());
58 public function testSetDecorated()
60 $output = new NullOutput();
61 $output->setDecorated(true);
62 $this->assertFalse($output->isDecorated());
65 public function testIsQuiet()
67 $output = new NullOutput();
68 $this->assertTrue($output->isQuiet());
71 public function testIsVerbose()
73 $output = new NullOutput();
74 $this->assertFalse($output->isVerbose());
77 public function testIsVeryVerbose()
79 $output = new NullOutput();
80 $this->assertFalse($output->isVeryVerbose());
83 public function testIsDebug()
85 $output = new NullOutput();
86 $this->assertFalse($output->isDebug());