Yaffs site version 1.1
[yaffs-website] / vendor / symfony / console / Tests / Formatter / OutputFormatterStyleStackTest.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 PHPUnit\Framework\TestCase;
15 use Symfony\Component\Console\Formatter\OutputFormatterStyleStack;
16 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
17
18 class OutputFormatterStyleStackTest extends TestCase
19 {
20     public function testPush()
21     {
22         $stack = new OutputFormatterStyleStack();
23         $stack->push($s1 = new OutputFormatterStyle('white', 'black'));
24         $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue'));
25
26         $this->assertEquals($s2, $stack->getCurrent());
27
28         $stack->push($s3 = new OutputFormatterStyle('green', 'red'));
29
30         $this->assertEquals($s3, $stack->getCurrent());
31     }
32
33     public function testPop()
34     {
35         $stack = new OutputFormatterStyleStack();
36         $stack->push($s1 = new OutputFormatterStyle('white', 'black'));
37         $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue'));
38
39         $this->assertEquals($s2, $stack->pop());
40         $this->assertEquals($s1, $stack->pop());
41     }
42
43     public function testPopEmpty()
44     {
45         $stack = new OutputFormatterStyleStack();
46         $style = new OutputFormatterStyle();
47
48         $this->assertEquals($style, $stack->pop());
49     }
50
51     public function testPopNotLast()
52     {
53         $stack = new OutputFormatterStyleStack();
54         $stack->push($s1 = new OutputFormatterStyle('white', 'black'));
55         $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue'));
56         $stack->push($s3 = new OutputFormatterStyle('green', 'red'));
57
58         $this->assertEquals($s2, $stack->pop($s2));
59         $this->assertEquals($s1, $stack->pop());
60     }
61
62     /**
63      * @expectedException \InvalidArgumentException
64      */
65     public function testInvalidPop()
66     {
67         $stack = new OutputFormatterStyleStack();
68         $stack->push(new OutputFormatterStyle('white', 'black'));
69         $stack->pop(new OutputFormatterStyle('yellow', 'blue'));
70     }
71 }