[console][formater] allow format toString object.

This commit is contained in:
Abdellatif Ait boudad 2015-05-20 07:26:55 +00:00 committed by Christophe Coevoet
parent 905bbbdd90
commit 70b4964e4e
2 changed files with 17 additions and 0 deletions

View File

@ -142,6 +142,7 @@ class OutputFormatter implements OutputFormatterInterface
*/
public function format($message)
{
$message = (string) $message;
$offset = 0;
$output = '';
$tagRegex = '[a-z][a-z0-9_=;-]*';

View File

@ -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));
}
public function testFormatToStringObject()
{
$formatter = new OutputFormatter(false);
$this->assertEquals(
'some info', $formatter->format(new TableCell())
);
}
public function testNotDecoratedFormatter()
{
$formatter = new OutputFormatter(false);
@ -255,3 +263,11 @@ EOF
));
}
}
class TableCell
{
public function __toString()
{
return '<info>some info</info>';
}
}