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 PHPUnit\Framework\TestCase;
15 use Symfony\Component\Console\Formatter\OutputFormatterStyleStack;
16 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
18 class OutputFormatterStyleStackTest extends TestCase
20 public function testPush()
22 $stack = new OutputFormatterStyleStack();
23 $stack->push($s1 = new OutputFormatterStyle('white', 'black'));
24 $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue'));
26 $this->assertEquals($s2, $stack->getCurrent());
28 $stack->push($s3 = new OutputFormatterStyle('green', 'red'));
30 $this->assertEquals($s3, $stack->getCurrent());
33 public function testPop()
35 $stack = new OutputFormatterStyleStack();
36 $stack->push($s1 = new OutputFormatterStyle('white', 'black'));
37 $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue'));
39 $this->assertEquals($s2, $stack->pop());
40 $this->assertEquals($s1, $stack->pop());
43 public function testPopEmpty()
45 $stack = new OutputFormatterStyleStack();
46 $style = new OutputFormatterStyle();
48 $this->assertEquals($style, $stack->pop());
51 public function testPopNotLast()
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'));
58 $this->assertEquals($s2, $stack->pop($s2));
59 $this->assertEquals($s1, $stack->pop());
63 * @expectedException \InvalidArgumentException
65 public function testInvalidPop()
67 $stack = new OutputFormatterStyleStack();
68 $stack->push(new OutputFormatterStyle('white', 'black'));
69 $stack->pop(new OutputFormatterStyle('yellow', 'blue'));