[console][formater] allow format toString object.
This commit is contained in:
parent
905bbbdd90
commit
70b4964e4e
@ -142,6 +142,7 @@ class OutputFormatter implements OutputFormatterInterface
|
|||||||
*/
|
*/
|
||||||
public function format($message)
|
public function format($message)
|
||||||
{
|
{
|
||||||
|
$message = (string) $message;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$output = '';
|
$output = '';
|
||||||
$tagRegex = '[a-z][a-z0-9_=;-]*';
|
$tagRegex = '[a-z][a-z0-9_=;-]*';
|
||||||
|
@ -166,6 +166,14 @@ class OutputFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals("\033[37;41msome error\033[0m".$long, $formatter->format('<error>some error</error>'.$long));
|
$this->assertEquals("\033[37;41msome error\033[0m".$long, $formatter->format('<error>some error</error>'.$long));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFormatToStringObject()
|
||||||
|
{
|
||||||
|
$formatter = new OutputFormatter(false);
|
||||||
|
$this->assertEquals(
|
||||||
|
'some info', $formatter->format(new TableCell())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testNotDecoratedFormatter()
|
public function testNotDecoratedFormatter()
|
||||||
{
|
{
|
||||||
$formatter = new OutputFormatter(false);
|
$formatter = new OutputFormatter(false);
|
||||||
@ -255,3 +263,11 @@ EOF
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TableCell
|
||||||
|
{
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return '<info>some info</info>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user