[Console] fixed the formatter for single-char tags
This commit is contained in:
parent
c6c35b3db9
commit
a47d663f25
@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface
|
|||||||
/**
|
/**
|
||||||
* The pattern to phrase the format.
|
* The pattern to phrase the format.
|
||||||
*/
|
*/
|
||||||
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx';
|
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]*)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx';
|
||||||
|
|
||||||
private $decorated;
|
private $decorated;
|
||||||
private $styles = array();
|
private $styles = array();
|
||||||
|
@ -113,7 +113,10 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($style, $formatter->getStyle('test'));
|
$this->assertEquals($style, $formatter->getStyle('test'));
|
||||||
$this->assertNotEquals($style, $formatter->getStyle('info'));
|
$this->assertNotEquals($style, $formatter->getStyle('info'));
|
||||||
|
|
||||||
$this->assertEquals("\033[34;47msome custom msg\033[0m", $formatter->format('<test>some custom msg</test>'));
|
$style = new OutputFormatterStyle('blue', 'white');
|
||||||
|
$formatter->setStyle('b', $style);
|
||||||
|
|
||||||
|
$this->assertEquals("\033[34;47msome \033[0m\033[34;47mcustom\033[0m\033[34;47m msg\033[0m", $formatter->format('<test>some <b>custom</b> msg</test>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRedefineStyle()
|
public function testRedefineStyle()
|
||||||
@ -137,7 +140,7 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testNonStyleTag()
|
public function testNonStyleTag()
|
||||||
{
|
{
|
||||||
$formatter = new OutputFormatter(true);
|
$formatter = new OutputFormatter(true);
|
||||||
$this->assertEquals("\033[32msome \033[0m\033[32m<tag> styled\033[0m", $formatter->format('<info>some <tag> styled</info>'));
|
$this->assertEquals("\033[32msome \033[0m\033[32m<tag> styled \033[0m\033[32m<p>single-char tag\033[0m\033[32m</p>\033[0m", $formatter->format('<info>some <tag> styled <p>single-char tag</p></info>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNotDecoratedFormatter()
|
public function testNotDecoratedFormatter()
|
||||||
|
Reference in New Issue
Block a user