12 namespace Symfony\Component\Console\Tests\Formatter;
21 $this->assertEquals(
"\033[32;40;1;4mfoo\033[39;49;22;24m", $style->apply(
'foo'));
24 $this->assertEquals(
"\033[31;5mfoo\033[39;25m", $style->apply(
'foo'));
27 $this->assertEquals(
"\033[47mfoo\033[49m", $style->apply(
'foo'));
34 $style->setForeground(
'black');
35 $this->assertEquals(
"\033[30mfoo\033[39m", $style->apply(
'foo'));
37 $style->setForeground(
'blue');
38 $this->assertEquals(
"\033[34mfoo\033[39m", $style->apply(
'foo'));
40 $style->setForeground(
'default');
41 $this->assertEquals(
"\033[39mfoo\033[39m", $style->apply(
'foo'));
43 $this->setExpectedException(
'InvalidArgumentException');
44 $style->setForeground(
'undefined-color');
51 $style->setBackground(
'black');
52 $this->assertEquals(
"\033[40mfoo\033[49m", $style->apply(
'foo'));
54 $style->setBackground(
'yellow');
55 $this->assertEquals(
"\033[43mfoo\033[49m", $style->apply(
'foo'));
57 $style->setBackground(
'default');
58 $this->assertEquals(
"\033[49mfoo\033[49m", $style->apply(
'foo'));
60 $this->setExpectedException(
'InvalidArgumentException');
61 $style->setBackground(
'undefined-color');
68 $style->setOptions(array(
'reverse',
'conceal'));
69 $this->assertEquals(
"\033[7;8mfoo\033[27;28m", $style->apply(
'foo'));
71 $style->setOption(
'bold');
72 $this->assertEquals(
"\033[7;8;1mfoo\033[27;28;22m", $style->apply(
'foo'));
74 $style->unsetOption(
'reverse');
75 $this->assertEquals(
"\033[8;1mfoo\033[28;22m", $style->apply(
'foo'));
77 $style->setOption(
'bold');
78 $this->assertEquals(
"\033[8;1mfoo\033[28;22m", $style->apply(
'foo'));
80 $style->setOptions(array(
'bold'));
81 $this->assertEquals(
"\033[1mfoo\033[22m", $style->apply(
'foo'));
84 $style->setOption(
'foo');
85 $this->fail(
'->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
86 }
catch (\Exception $e) {
87 $this->assertInstanceOf(
'\InvalidArgumentException', $e,
'->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
88 $this->assertContains(
'Invalid option specified: "foo"', $e->getMessage(),
'->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
92 $style->unsetOption(
'foo');
93 $this->fail(
'->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
94 }
catch (\Exception $e) {
95 $this->assertInstanceOf(
'\InvalidArgumentException', $e,
'->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
96 $this->assertContains(
'Invalid option specified: "foo"', $e->getMessage(),
'->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');