Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / symfony / console / Symfony / Component / Console / Tests / Formatter / OutputFormatterStyleTest.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\Formatter;
13
14 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
15
16 class OutputFormatterStyleTest extends \PHPUnit_Framework_TestCase
17 {
18     public function testConstructor()
19     {
20         $style = new OutputFormatterStyle('green', 'black', array('bold', 'underscore'));
21         $this->assertEquals("\033[32;40;1;4mfoo\033[0m", $style->apply('foo'));
22
23         $style = new OutputFormatterStyle('red', null, array('blink'));
24         $this->assertEquals("\033[31;5mfoo\033[0m", $style->apply('foo'));
25
26         $style = new OutputFormatterStyle(null, 'white');
27         $this->assertEquals("\033[47mfoo\033[0m", $style->apply('foo'));
28     }
29
30     public function testForeground()
31     {
32         $style = new OutputFormatterStyle();
33
34         $style->setForeground('black');
35         $this->assertEquals("\033[30mfoo\033[0m", $style->apply('foo'));
36
37         $style->setForeground('blue');
38         $this->assertEquals("\033[34mfoo\033[0m", $style->apply('foo'));
39
40         $this->setExpectedException('InvalidArgumentException');
41         $style->setForeground('undefined-color');
42     }
43
44     public function testBackground()
45     {
46         $style = new OutputFormatterStyle();
47
48         $style->setBackground('black');
49         $this->assertEquals("\033[40mfoo\033[0m", $style->apply('foo'));
50
51         $style->setBackground('yellow');
52         $this->assertEquals("\033[43mfoo\033[0m", $style->apply('foo'));
53
54         $this->setExpectedException('InvalidArgumentException');
55         $style->setBackground('undefined-color');
56     }
57
58     public function testOptions()
59     {
60         $style = new OutputFormatterStyle();
61
62         $style->setOptions(array('reverse', 'conceal'));
63         $this->assertEquals("\033[7;8mfoo\033[0m", $style->apply('foo'));
64
65         $style->setOption('bold');
66         $this->assertEquals("\033[7;8;1mfoo\033[0m", $style->apply('foo'));
67
68         $style->unsetOption('reverse');
69         $this->assertEquals("\033[8;1mfoo\033[0m", $style->apply('foo'));
70
71         $style->setOption('bold');
72         $this->assertEquals("\033[8;1mfoo\033[0m", $style->apply('foo'));
73
74         $style->setOptions(array('bold'));
75         $this->assertEquals("\033[1mfoo\033[0m", $style->apply('foo'));
76     }
77 }