packages/sql-semantics-postgres/tests/Unit/Statement/Object/Reference/OperatorGroupNameTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Object\Reference;
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\Model\Statement\Identifier\Name;
16use SqlSemantics\Platform\PostgreSql\Platform;
17use SqlSemantics\Platform\PostgreSql\Rendering\Codec;
18use SqlSemantics\Platform\PostgreSql\Statement\Name\DottedName;
19use SqlSemantics\Platform\PostgreSql\Statement\Object\Reference\OperatorGroupName;
20
21#[CoversClass(OperatorGroupName::class)]
22#[Small]
23final class OperatorGroupNameTest extends TestCase
24{
25 public function testDeriveClauseRecordsNothing(): void
26 {
27 $derivation = new Derivation((new Platform())->context(new LanguageProfile(GrammarRelease::PostgreSql172), null, [], true));
28 (new OperatorGroupName(new DottedName([new Name('c')]), new Name('btree')))->deriveClause($derivation, $derivation->environment());
29 self::assertSame([], $derivation->facts()->diagnostics);
30 }
31
32 public function testRenderWritesTheAccessMethod(): void
33 {
34 $out = new Output(new Codec(GrammarRelease::PostgreSql172));
35 (new OperatorGroupName(new DottedName([new Name('s'), new Name('c')]), new Name('gist')))->render($out);
36 self::assertSame('s.c USING gist', (new Lexical())->join($out->pieces()));
37 }
38}
39