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\Formatter;
14 use Symfony\Component\Console\Formatter\OutputFormatterStyleStack;
15 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
17 class OutputFormatterStyleStackTest extends \PHPUnit_Framework_TestCase
19 public function testPush()
21 $stack = new OutputFormatterStyleStack();
22 $stack->push($s1 = new OutputFormatterStyle('white', 'black'));
23 $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue'));
25 $this->assertEquals($s2, $stack->getCurrent());
27 $stack->push($s3 = new OutputFormatterStyle('green', 'red'));
29 $this->assertEquals($s3, $stack->getCurrent());
32 public function testPop()
34 $stack = new OutputFormatterStyleStack();
35 $stack->push($s1 = new OutputFormatterStyle('white', 'black'));
36 $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue'));
38 $this->assertEquals($s2, $stack->pop());
39 $this->assertEquals($s1, $stack->pop());
42 public function testPopEmpty()
44 $stack = new OutputFormatterStyleStack();
45 $style = new OutputFormatterStyle();
47 $this->assertEquals($style, $stack->pop());
50 public function testPopNotLast()
52 $stack = new OutputFormatterStyleStack();
53 $stack->push($s1 = new OutputFormatterStyle('white', 'black'));
54 $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue'));
55 $stack->push($s3 = new OutputFormatterStyle('green', 'red'));
57 $this->assertEquals($s2, $stack->pop($s2));
58 $this->assertEquals($s1, $stack->pop());
62 * @expectedException InvalidArgumentException
64 public function testInvalidPop()
66 $stack = new OutputFormatterStyleStack();
67 $stack->push(new OutputFormatterStyle('white', 'black'));
68 $stack->pop(new OutputFormatterStyle('yellow', 'blue'));