packages/sql-semantics-mysql/tests/Unit/Statement/Dml/Load/FieldOptionTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Dml\Load;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Rendering\Lexical;
11use SqlSemantics\Platform\MySql\Model\Rendering\Output;
12use SqlSemantics\Platform\MySql\Rendering\Codec;
13use SqlSemantics\Platform\MySql\Semantics;
14use SqlSemantics\Platform\MySql\Statement\Dml\Load\FieldOption;
15use SqlSemantics\Platform\MySql\Statement\Dml\Load\FieldOptionKind;
16use SqlSemantics\Platform\MySql\Statement\Literal\Text;
17
18#[CoversClass(FieldOption::class)]
19#[Medium]
20final class FieldOptionTest extends TestCase
21{
22    public function testRenderWritesTheOption(): void
23    {
24        $out = new Output(new Codec((new Semantics())->profile()->grammar));
25        (new FieldOption(FieldOptionKind::OptionallyEnclosed, new Text('"')))->render($out);
26
27        self::assertSame('OPTIONALLY ENCLOSED BY \'"\'', (new Lexical())->join($out->pieces()));
28    }
29}
30