Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / symfony / console / Symfony / Component / Console / Tests / Helper / FormatterHelperTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Console\Tests\Helper;
13
14 use Symfony\Component\Console\Helper\FormatterHelper;
15
16 class FormatterHelperTest extends \PHPUnit_Framework_TestCase
17 {
18     public function testFormatSection()
19     {
20         $formatter = new FormatterHelper();
21
22         $this->assertEquals(
23             '<info>[cli]</info> Some text to display',
24             $formatter->formatSection('cli', 'Some text to display'),
25             '::formatSection() formats a message in a section'
26         );
27     }
28
29     public function testFormatBlock()
30     {
31         $formatter = new FormatterHelper();
32
33         $this->assertEquals(
34             '<error> Some text to display </error>',
35             $formatter->formatBlock('Some text to display', 'error'),
36             '::formatBlock() formats a message in a block'
37         );
38
39         $this->assertEquals(
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'
44         );
45
46         $this->assertEquals(
47             '<error>                        </error>' . "\n" .
48             '<error>  Some text to display  </error>' . "\n" .
49             '<error>                        </error>',
50             $formatter->formatBlock('Some text to display', 'error', true),
51             '::formatBlock() formats a message in a block'
52         );
53     }
54
55     public function testFormatBlockWithDiacriticLetters()
56     {
57         if (!extension_loaded('mbstring')) {
58             $this->markTestSkipped('This test requires mbstring to work.');
59         }
60
61         $formatter = new FormatterHelper();
62
63         $this->assertEquals(
64             '<error>                       </error>' . "\n" .
65             '<error>  Du texte à afficher  </error>' . "\n" .
66             '<error>                       </error>',
67             $formatter->formatBlock('Du texte à afficher', 'error', true),
68             '::formatBlock() formats a message in a block'
69         );
70     }
71
72     public function testFormatBlockLGEscaping()
73     {
74         $formatter = new FormatterHelper();
75
76         $this->assertEquals(
77             '<error>                            </error>' . "\n" .
78             '<error>  \<info>some info\</info>  </error>' . "\n" .
79             '<error>                            </error>',
80             $formatter->formatBlock('<info>some info</info>', 'error', true),
81             '::formatBlock() escapes \'<\' chars'
82         );
83     }
84 }