packages/sql-semantics-mysql/tests/Unit/Rendering/LeadingDotTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Rendering;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Contract\GrammarRelease;
11use SqlSemantics\Platform\MySql\Model\Rendering\Lexical;
12use SqlSemantics\Platform\MySql\Model\Rendering\Output;
13use SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name;
14use SqlSemantics\Platform\MySql\Rendering\Codec;
15use SqlSemantics\Platform\MySql\Rendering\LeadingDot;
16
17#[CoversClass(LeadingDot::class)]
18#[Small]
19final class LeadingDotTest extends TestCase
20{
21 public function testWriteSeparatesTheDotFromAPrecedingWordAndJoinsTheNameToIt(): void
22 {
23 $out = (new Output(new Codec(GrammarRelease::MySql5744)))->keyword('FROM');
24 (new LeadingDot())->write($out);
25 $out->name(new Name('t'));
26
27 self::assertSame('FROM .t', (new Lexical())->join($out->pieces()));
28 }
29}
30