packages/sql-semantics-postgres/tests/Unit/Statement/Catalog/Publication/PublicationSchemaTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Catalog\Publication;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlSemantics\Platform\PostgreSql\Statement\Catalog\Publication\PublicationSchema::class)]
12#[Medium]
13final class PublicationSchemaTest extends TestCase
14{
15    public function testIntroducedWhenTheKeywordsAreWritten(): void
16    {
17        self::assertTrue((new \SqlSemantics\Platform\PostgreSql\Statement\Catalog\Publication\PublicationSchema(null))->introduced());
18    }
19
20    public function testRenderContinuesSchemas(): void
21    {
22        self::assertSame('CREATE PUBLICATION p FOR TABLES IN SCHEMA CURRENT_SCHEMA, s, CURRENT_SCHEMA', (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE PUBLICATION p FOR TABLES IN SCHEMA CURRENT_SCHEMA, s, CURRENT_SCHEMA')->toString());
23    }
24
25    public function testRenderReadsABareNameAfterASchemaAsASchema(): void
26    {
27        $statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE PUBLICATION p FOR TABLES IN SCHEMA a, b')->statement;
28        self::assertInstanceOf(\SqlSemantics\Platform\PostgreSql\Statement\Catalog\Publication\CreatePublication::class, $statement);
29        self::assertSame(\SqlSemantics\Platform\PostgreSql\Statement\Catalog\Publication\PublicationSchema::class, $statement->objects[1]::class);
30    }
31}
32