ConsoleOutputTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Tests\Output;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Console\Formatter\OutputFormatter;
  13. use Symfony\Component\Console\Output\ConsoleOutput;
  14. use Symfony\Component\Console\Output\Output;
  15. class ConsoleOutputTest extends TestCase
  16. {
  17. public function testConstructor()
  18. {
  19. $output = new ConsoleOutput(Output::VERBOSITY_QUIET, true);
  20. $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
  21. $this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument');
  22. }
  23. public function testSetFormatter()
  24. {
  25. $output = new ConsoleOutput();
  26. $outputFormatter = new OutputFormatter();
  27. $output->setFormatter($outputFormatter);
  28. $this->assertSame($outputFormatter, $output->getFormatter());
  29. }
  30. public function testSetVerbosity()
  31. {
  32. $output = new ConsoleOutput();
  33. $output->setVerbosity(Output::VERBOSITY_VERBOSE);
  34. $this->assertSame(Output::VERBOSITY_VERBOSE, $output->getVerbosity());
  35. }
  36. }