packages/sql-semantics-postgres/tests/Unit/Rules/Catalog/PublicationListTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Rules\Catalog;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlSemantics\Platform\PostgreSql\Rules\Catalog\PublicationList::class)]
12#[Medium]
13final class PublicationListTest extends TestCase
14{
15    public function testCheckAcceptsACurrentSchemaAnywhere(): void
16    {
17        self::assertSame('CREATE PUBLICATION p FOR TABLE t, CURRENT_SCHEMA', (new \SqlSemantics\Platform\PostgreSql\Semantics())->inspect('CREATE PUBLICATION p FOR TABLE t, CURRENT_SCHEMA')->toString());
18    }
19
20    public function testDeriveReportsAQualifiedTableAfterASchema(): void
21    {
22        self::assertSame('invalid schema name', (new \SqlSemantics\Platform\PostgreSql\Semantics())->inspect('CREATE PUBLICATION p FOR TABLES IN SCHEMA s, a.b')->facts->diagnostics[0]->message());
23    }
24
25    public function testDeriveReportsAFilterAfterASchema(): void
26    {
27        self::assertSame('WHERE clause not allowed for schema', (new \SqlSemantics\Platform\PostgreSql\Semantics())->inspect('CREATE PUBLICATION p FOR TABLES IN SCHEMA s, t WHERE (true)')->facts->diagnostics[0]->message());
28    }
29
30    public function testDeriveReportsColumnsAfterASchema(): void
31    {
32        self::assertSame('column specification not allowed for schema', (new \SqlSemantics\Platform\PostgreSql\Semantics())->inspect('CREATE PUBLICATION p FOR TABLES IN SCHEMA s, t (a)')->facts->diagnostics[0]->message());
33    }
34
35    public function testRuleOfAnIntroducedItemIsNull(): void
36    {
37        self::assertNull((new \SqlSemantics\Platform\PostgreSql\Rules\Catalog\PublicationList())->rule(null, new \SqlSemantics\Platform\PostgreSql\Statement\Catalog\Publication\PublicationSchema(null), null));
38    }
39}
40