packages/sql-semantics-postgres/tests/Unit/Statement/Catalog/ForeignData/AlterForeignServerTest.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\AlterForeignServer::class)]
12#[Medium]
13final class AlterForeignServerTest extends TestCase
14{
15    public function testRenderWritesTheVersionAndOptions(): void
16    {
17        self::assertSame('ALTER SERVER s VERSION NULL OPTIONS (ADD a \'b\')', (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER SERVER s VERSION NULL OPTIONS (ADD a \'b\')')->toString());
18    }
19
20    public function testDeriveStatementRecordsNothing(): void
21    {
22        self::assertSame([], (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER SERVER s OPTIONS (DROP a)')->facts->diagnostics);
23    }
24
25    public function testRejectsAnEmptyChange(): void
26    {
27        $this->expectExceptionMessage('ALTER SERVER changes the version or an option.');
28        new \SqlSemantics\Platform\PostgreSql\Statement\Catalog\ForeignData\AlterForeignServer(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('s'), null);
29    }
30}
31