<?php

declare(strict_types=1);

namespace Dalten\RuianToUir\Tests\Unit\Writer;

use Dalten\RuianToUir\Converter\Result\AddRecord;
use Dalten\RuianToUir\Formatter\PlainText;
use Dalten\RuianToUir\Writer\PrintOut;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

#[CoversClass(PrintOut::class)]
final class PrintOutTest extends TestCase
{
    public function testPrintsFormattedLineToStdout(): void
    {
        $formatter = new PlainText();
        $writer = new PrintOut($formatter);

        $data = new AddRecord('Address', 1, ['foo' => 'bar']);

        ob_start();
        $writer->write($data, 'Address');
        $output = ob_get_clean();

        $this->assertSame("Address;ADD;foo=bar" . PHP_EOL, $output);
    }
}
