Yaffs site version 1.1
[yaffs-website] / vendor / symfony / 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 PHPUnit\Framework\TestCase;
15 use Symfony\Component\Console\Helper\FormatterHelper;
16
17 class FormatterHelperTest extends TestCase
18 {
19     public function testFormatSection()
20     {
21         $formatter = new FormatterHelper();
22
23         $this->assertEquals(
24             '<info>[cli]</info> Some text to display',
25             $formatter->formatSection('cli', 'Some text to display'),
26             '::formatSection() formats a message in a section'
27         );
28     }
29
30     public function testFormatBlock()
31     {
32         $formatter = new FormatterHelper();
33
34         $this->assertEquals(
35             '<error> Some text to display </error>',
36             $formatter->formatBlock('Some text to display', 'error'),
37             '::formatBlock() formats a message in a block'
38         );
39
40         $this->assertEquals(
41             '<error> Some text to display </error>'."\n".
42             '<error> foo bar              </error>',
43             $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'),
44             '::formatBlock() formats a message in a block'
45         );
46
47         $this->assertEquals(
48             '<error>                        </error>'."\n".
49             '<error>  Some text to display  </error>'."\n".
50             '<error>                        </error>',
51             $formatter->formatBlock('Some text to display', 'error', true),
52             '::formatBlock() formats a message in a block'
53         );
54     }
55
56     public function testFormatBlockWithDiacriticLetters()
57     {
58         $formatter = new FormatterHelper();
59
60         $this->assertEquals(
61             '<error>                       </error>'."\n".
62             '<error>  Du texte à afficher  </error>'."\n".
63             '<error>                       </error>',
64             $formatter->formatBlock('Du texte à afficher', 'error', true),
65             '::formatBlock() formats a message in a block'
66         );
67     }
68
69     public function testFormatBlockWithDoubleWidthDiacriticLetters()
70     {
71         $formatter = new FormatterHelper();
72         $this->assertEquals(
73             '<error>                    </error>'."\n".
74             '<error>  表示するテキスト  </error>'."\n".
75             '<error>                    </error>',
76             $formatter->formatBlock('表示するテキスト', 'error', true),
77             '::formatBlock() formats a message in a block'
78         );
79     }
80
81     public function testFormatBlockLGEscaping()
82     {
83         $formatter = new FormatterHelper();
84
85         $this->assertEquals(
86             '<error>                            </error>'."\n".
87             '<error>  \<info>some info\</info>  </error>'."\n".
88             '<error>                            </error>',
89             $formatter->formatBlock('<info>some info</info>', 'error', true),
90             '::formatBlock() escapes \'<\' chars'
91         );
92     }
93 }