packages/sql-semantics-mysql/tests/Unit/Statement/Query/ValueRowTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Query;
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\Literal\NullLiteral;
15use SqlSemantics\Platform\MySql\Statement\Literal\NumberLiteral;
16use SqlSemantics\Platform\MySql\Statement\Query\ValueRow;
17
18#[CoversClass(ValueRow::class)]
19#[Medium]
20final class ValueRowTest extends TestCase
21{
22 public function testRenderWritesTheRowConstructor(): void
23 {
24 $semantics = new Semantics();
25 $row = new ValueRow([new NumberLiteral('1'), new NullLiteral()]);
26 $out = new Output(new Codec($semantics->profile()->grammar));
27 $row->render($out);
28
29 self::assertSame('ROW(1, NULL)', (new Lexical())->join($out->pieces()));
30 self::assertCount(2, $row->values);
31 }
32}
33