public function testStyle() { $this->assertFalse($this->decoratedFormatter->hasStyle('nonExisting')); $outputFormatterStyle = new OutputFormatterStyle('blue'); $this->decoratedFormatter->setStyle('blue', $outputFormatterStyle); $this->assertTrue($this->decoratedFormatter->hasStyle('blue')); $this->assertSame($outputFormatterStyle, $this->decoratedFormatter->getStyle('blue')); }
public function testEscapingOutput() { $raw_formatter = new OutputFormatter(true); $decorated_formatter = new HtmlOutputFormatterDecorator($raw_formatter); $decorated_formatter->setStyle('error', new HtmlOutputFormatterStyle('white', 'red')); $decorated_formatter->setStyle('info', new HtmlOutputFormatterStyle('green')); $decorated_formatter->setStyle('comment', new HtmlOutputFormatterStyle('yellow')); $decorated_formatter->setStyle('question', new HtmlOutputFormatterStyle('black', 'cyan')); $this->assertSame('a<script>evil();</script>a', $decorated_formatter->format('a<script>evil();</script>a')); $this->assertSame('<script><span style="color:rgba(50,230,50,1)">evil();</span></script>', $decorated_formatter->format('<script><info>evil();</info></script>')); $this->assertSame('<span style="color:rgba(50,230,50,1)">a<script><info>evil();</span></script>', $decorated_formatter->format('<info>a<script><info>evil();</info></script>')); $this->assertSame('<span style="color:rgba(50,230,50,1)">a&lt;<script><info>evil();</span></script>', $decorated_formatter->format('<info>a<<script><info>evil();</info></script>')); }