FormatterHelperTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace Symfony\Tests\Component\Console\Formatter;
  10. use Symfony\Component\Console\Helper\FormatterHelper;
  11. class FormatterHelperTest extends \PHPUnit_Framework_TestCase
  12. {
  13. public function testFormatSection()
  14. {
  15. $formatter = new FormatterHelper();
  16. $this->assertEquals('<info>[cli]</info> Some text to display', $formatter->formatSection('cli', 'Some text to display'), '::formatSection() formats a message in a section');
  17. }
  18. public function testFormatBlock()
  19. {
  20. $formatter = new FormatterHelper();
  21. $this->assertEquals('<error> Some text to display </error>', $formatter->formatBlock('Some text to display', 'error'), '::formatBlock() formats a message in a block');
  22. $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');
  23. $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');
  24. }
  25. }