\033[39m\033[32m styled \033[39m\033[32m\033[39m\033[32msingle-char tag\033[39m\033[32m
\033[39m", $formatter->format('some styled single-char tag
'));
}
public function testFormatLongString()
{
$formatter = new OutputFormatter(true);
$long = str_repeat('\\', 14000);
$this->assertEquals("\033[37;41msome error\033[39;49m".$long, $formatter->format('some error'.$long));
}
public function testFormatToStringObject()
{
$formatter = new OutputFormatter(false);
$this->assertEquals(
'some info', $formatter->format(new TableCell())
);
}
public function testNotDecoratedFormatter()
{
$formatter = new OutputFormatter(false);
$this->assertTrue($formatter->hasStyle('error'));
$this->assertTrue($formatter->hasStyle('info'));
$this->assertTrue($formatter->hasStyle('comment'));
$this->assertTrue($formatter->hasStyle('question'));
$this->assertEquals(
'some error', $formatter->format('some error')
);
$this->assertEquals(
'some info', $formatter->format('some info')
);
$this->assertEquals(
'some comment', $formatter->format('some comment')
);
$this->assertEquals(
'some question', $formatter->format('some question')
);
$this->assertEquals(
'some text with inline style', $formatter->format('some text with inline style>')
);
$formatter->setDecorated(true);
$this->assertEquals(
"\033[37;41msome error\033[39;49m", $formatter->format('some error')
);
$this->assertEquals(
"\033[32msome info\033[39m", $formatter->format('some info')
);
$this->assertEquals(
"\033[33msome comment\033[39m", $formatter->format('some comment')
);
$this->assertEquals(
"\033[30;46msome question\033[39;49m", $formatter->format('some question')
);
$this->assertEquals(
"\033[31msome text with inline style\033[39m", $formatter->format('some text with inline style>')
);
}
public function testContentWithLineBreaks()
{
$formatter = new OutputFormatter(true);
$this->assertEquals(<<format(<<<'EOF'
some text
EOF
));
$this->assertEquals(<<format(<<<'EOF'
some text
EOF
));
$this->assertEquals(<<format(<<<'EOF'
some text
EOF
));
$this->assertEquals(<<format(<<<'EOF'
some text
more text
EOF
));
}
}
class TableCell
{
public function __toString()
{
return 'some info';
}
}