packages/sql-semantics-postgres/tests/Unit/Statement/Expression/Step/AllFieldsTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Expression\Step;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\PostgreSql\Model\Construction\Derivation;
11use SqlSemantics\Platform\PostgreSql\Model\Contract\GrammarRelease;
12use SqlSemantics\Platform\PostgreSql\Model\Contract\LanguageProfile;
13use SqlSemantics\Platform\PostgreSql\Model\Rendering\Lexical;
14use SqlSemantics\Platform\PostgreSql\Model\Rendering\Output;
15use SqlSemantics\Platform\PostgreSql\Platform;
16use SqlSemantics\Platform\PostgreSql\Rendering\Codec;
17use SqlSemantics\Platform\PostgreSql\Statement\Expression\Step\AllFields;
18
19#[CoversClass(AllFields::class)]
20#[Small]
21final class AllFieldsTest extends TestCase
22{
23 public function testFieldIsNone(): void
24 {
25 self::assertNull((new AllFields())->field());
26 }
27
28 public function testDeriveClauseRecordsNothing(): void
29 {
30 $derivation = new Derivation((new Platform())->context(new LanguageProfile(GrammarRelease::PostgreSql172), null, [], true));
31 (new AllFields())->deriveClause($derivation, $derivation->environment());
32 self::assertSame([], $derivation->facts()->diagnostics);
33 }
34
35 public function testRenderWritesTheStar(): void
36 {
37 $out = new Output(new Codec(GrammarRelease::PostgreSql172));
38 (new AllFields())->render($out);
39 self::assertSame('.*', (new Lexical())->join($out->pieces()));
40 }
41}
42