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\Helper;
14 use Symfony\Component\Console\Helper\FormatterHelper;
16 class FormatterHelperTest extends \PHPUnit_Framework_TestCase
18 public function testFormatSection()
20 $formatter = new FormatterHelper();
23 '<info>[cli]</info> Some text to display',
24 $formatter->formatSection('cli', 'Some text to display'),
25 '::formatSection() formats a message in a section'
29 public function testFormatBlock()
31 $formatter = new FormatterHelper();
34 '<error> Some text to display </error>',
35 $formatter->formatBlock('Some text to display', 'error'),
36 '::formatBlock() formats a message in a block'
40 '<error> Some text to display </error>' . "\n" .
41 '<error> foo bar </error>',
42 $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'),
43 '::formatBlock() formats a message in a block'
47 '<error> </error>' . "\n" .
48 '<error> Some text to display </error>' . "\n" .
50 $formatter->formatBlock('Some text to display', 'error', true),
51 '::formatBlock() formats a message in a block'
55 public function testFormatBlockWithDiacriticLetters()
57 if (!extension_loaded('mbstring')) {
58 $this->markTestSkipped('This test requires mbstring to work.');
61 $formatter = new FormatterHelper();
64 '<error> </error>' . "\n" .
65 '<error> Du texte à afficher </error>' . "\n" .
67 $formatter->formatBlock('Du texte à afficher', 'error', true),
68 '::formatBlock() formats a message in a block'
72 public function testFormatBlockLGEscaping()
74 $formatter = new FormatterHelper();
77 '<error> </error>' . "\n" .
78 '<error> \<info>some info\</info> </error>' . "\n" .
80 $formatter->formatBlock('<info>some info</info>', 'error', true),
81 '::formatBlock() escapes \'<\' chars'