[
'outputFormat' => PolyOutput::FORMAT_HTML,
'messages' => ['one message', 'two message'],
'expected' => "one message
\ntwo message
\n",
],
'ansi for html' => [
'outputFormat' => PolyOutput::FORMAT_ANSI,
'messages' => ['one message', 'two message'],
'expected' => '',
],
];
}
#[DataProvider('provideWriteForHtml')]
public function testWriteForHtml(
string $outputFormat,
string|iterable $messages,
string $expected
): void {
$buffer = new BufferedOutput();
$output = new PolyOutput($outputFormat, wrappedOutput: $buffer);
$output->writeForHtml($messages, true);
$this->assertSame($expected, $buffer->fetch());
}
public static function provideWriteForAnsi(): array
{
return [
'html for ansi' => [
'outputFormat' => PolyOutput::FORMAT_HTML,
'messages' => ['one message', 'two message'],
'expected' => '',
],
'ansi for ansi' => [
'outputFormat' => PolyOutput::FORMAT_ANSI,
'messages' => ['one message', 'two message'],
'expected' => "one message\ntwo message\n",
],
];
}
#[DataProvider('provideWriteForAnsi')]
public function testWriteForAnsi(
string $outputFormat,
string|iterable $messages,
string $expected
): void {
$buffer = new BufferedOutput();
$output = new PolyOutput($outputFormat, wrappedOutput: $buffer);
$output->writeForAnsi($messages, true);
$this->assertSame($expected, $buffer->fetch());
}
public static function provideList(): array
{
return [
'empty list ANSI' => [
'outputFormat' => PolyOutput::FORMAT_ANSI,
'list' => [
'type' => PolyOutput::LIST_UNORDERED,
'items' => []
],
'expected' => '',
],
'empty list HTML' => [
'outputFormat' => PolyOutput::FORMAT_HTML,
'list' => [
'type' => PolyOutput::LIST_UNORDERED,
'items' => []
],
'expected' => '