packages/sql-semantics-postgres/tests/Unit/Rules/Routine/ObjectSpellingTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Rules\Routine;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\PostgreSql\Model\Contract\GrammarRelease;
11use SqlSemantics\Platform\PostgreSql\Model\Rendering\Lexical;
12use SqlSemantics\Platform\PostgreSql\Model\Rendering\Output;
13use SqlSemantics\Platform\PostgreSql\Rendering\Codec;
14use SqlSemantics\Platform\PostgreSql\Rules\Routine\ObjectSpelling;
15use SqlSemantics\Platform\PostgreSql\Statement\Name\ObjectKind;
16
17#[CoversClass(ObjectSpelling::class)]
18#[Small]
19final class ObjectSpellingTest extends TestCase
20{
21 public function testKindWritesConstraintForADomainConstraint(): void
22 {
23 $domain = new Output(new Codec(GrammarRelease::PostgreSql172));
24 (new ObjectSpelling())->kind($domain, ObjectKind::DomainConstraint);
25 $wrapper = new Output(new Codec(GrammarRelease::PostgreSql172));
26 (new ObjectSpelling())->kind($wrapper, ObjectKind::ForeignDataWrapper);
27 self::assertSame(['CONSTRAINT', 'FOREIGN DATA WRAPPER'], [(new Lexical())->join($domain->pieces()), (new Lexical())->join($wrapper->pieces())]);
28 }
29}
30