FormatterHelperTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\Helper;
  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(
  18. '<info>[cli]</info> Some text to display',
  19. $formatter->formatSection('cli', 'Some text to display'),
  20. '::formatSection() formats a message in a section'
  21. );
  22. }
  23. public function testFormatBlock()
  24. {
  25. $formatter = new FormatterHelper();
  26. $this->assertEquals(
  27. '<error> Some text to display </error>',
  28. $formatter->formatBlock('Some text to display', 'error'),
  29. '::formatBlock() formats a message in a block'
  30. );
  31. $this->assertEquals(
  32. '<error> Some text to display </error>' . "\n" .
  33. '<error> foo bar </error>',
  34. $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'),
  35. '::formatBlock() formats a message in a block'
  36. );
  37. $this->assertEquals(
  38. '<error> </error>' . "\n" .
  39. '<error> Some text to display </error>' . "\n" .
  40. '<error> </error>',
  41. $formatter->formatBlock('Some text to display', 'error', true),
  42. '::formatBlock() formats a message in a block'
  43. );
  44. $this->assertEquals(
  45. '<error> </error>' . "\n" .
  46. '<error> Du texte à afficher </error>' . "\n" .
  47. '<error> </error>',
  48. $formatter->formatBlock('Du texte à afficher', 'error', true),
  49. '::formatBlock() formats a message in a block'
  50. );
  51. }
  52. }