FormatterHelperTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  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\Tests\Component\Console\Formatter;
  11. use Symfony\Component\Console\Helper\FormatterHelper;
  12. class FormatterHelperTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testFormatSection()
  15. {
  16. $formatter = new FormatterHelper();
  17. $this->assertEquals('<info>[cli]</info> Some text to display', $formatter->formatSection('cli', 'Some text to display'), '::formatSection() formats a message in a section');
  18. }
  19. public function testFormatBlock()
  20. {
  21. $formatter = new FormatterHelper();
  22. $this->assertEquals('<error> Some text to display </error>', $formatter->formatBlock('Some text to display', 'error'), '::formatBlock() formats a message in a block');
  23. $this->assertEquals("<error> Some text to display </error>\n<error> foo bar </error>", $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), '::formatBlock() formats a message in a block');
  24. $this->assertEquals("<error> </error>\n<error> Some text to display </error>\n<error> </error>", $formatter->formatBlock('Some text to display', 'error', true), '::formatBlock() formats a message in a block');
  25. }
  26. }