Файл: symfony-2.7/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php
Строк: 191
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace SymfonyComponentConsoleTestsFormatter;
use SymfonyComponentConsoleFormatterOutputFormatter;
use SymfonyComponentConsoleFormatterOutputFormatterStyle;
class OutputFormatterTest extends PHPUnit_Framework_TestCase
{
public function testEmptyTag()
{
$formatter = new OutputFormatter(true);
$this->assertEquals("foo<>bar", $formatter->format('foo<>bar'));
}
public function testLGCharEscaping()
{
$formatter = new OutputFormatter(true);
$this->assertEquals("foo<bar", $formatter->format('foo\<bar'));
$this->assertEquals("<info>some info</info>", $formatter->format('\<info>some info\</info>'));
$this->assertEquals("\<info>some info\</info>", OutputFormatter::escape('<info>some info</info>'));
$this->assertEquals(
" 33[33mSymfony\Component\Console does work very well! 33[39m",
$formatter->format('<comment>SymfonyComponentConsole does work very well!</comment>')
);
}
public function testBundledStyles()
{
$formatter = new OutputFormatter(true);
$this->assertTrue($formatter->hasStyle('error'));
$this->assertTrue($formatter->hasStyle('info'));
$this->assertTrue($formatter->hasStyle('comment'));
$this->assertTrue($formatter->hasStyle('question'));
$this->assertEquals(
" 33[37;41msome error 33[39;49m",
$formatter->format('<error>some error</error>')
);
$this->assertEquals(
" 33[32msome info 33[39m",
$formatter->format('<info>some info</info>')
);
$this->assertEquals(
" 33[33msome comment 33[39m",
$formatter->format('<comment>some comment</comment>')
);
$this->assertEquals(
" 33[30;46msome question 33[39;49m",
$formatter->format('<question>some question</question>')
);
}
public function testNestedStyles()
{
$formatter = new OutputFormatter(true);
$this->assertEquals(
" 33[37;41msome