packages/sql-semantics-postgres/tests/Unit/Statement/Catalog/ForeignData/ImportRestrictionTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Catalog\ForeignData;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlSemantics\Platform\PostgreSql\Statement\Catalog\ForeignData\ImportRestriction::class)]
12#[Medium]
13final class ImportRestrictionTest extends TestCase
14{
15    public function testRenderKeepsOnly(): void
16    {
17        self::assertSame('IMPORT FOREIGN SCHEMA r EXCEPT (a, ONLY b) FROM SERVER s INTO l', (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('IMPORT FOREIGN SCHEMA r EXCEPT (a, ONLY b) FROM SERVER s INTO l')->toString());
18    }
19
20    public function testRejectsAnEmptyList(): void
21    {
22        $this->expectExceptionMessage('An import restriction names at least one table.');
23        new \SqlSemantics\Platform\PostgreSql\Statement\Catalog\ForeignData\ImportRestriction(\SqlSemantics\Platform\PostgreSql\Statement\Catalog\ForeignData\ImportRestrictionKind::Except, []);
24    }
25}
26