packages/sql-semantics-postgres/tests/Unit/Statement/Catalog/Database/AlterDatabaseTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Catalog\Database;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlSemantics\Platform\PostgreSql\Statement\Catalog\Database\AlterDatabase::class)]
12#[Medium]
13final class AlterDatabaseTest extends TestCase
14{
15    public function testRenderWritesWith(): void
16    {
17        self::assertSame('ALTER DATABASE d WITH CONNECTION LIMIT = 10', (new \SqlSemantics\Platform\PostgreSql\Semantics())->inspect('ALTER DATABASE d CONNECTION LIMIT 10')->toString());
18    }
19
20    public function testDeriveStatementReportsATablespaceWithOtherOptions(): void
21    {
22        self::assertSame('option "tablespace" cannot be specified with other options', (new \SqlSemantics\Platform\PostgreSql\Semantics())->inspect('ALTER DATABASE d WITH tablespace x allow_connections false')->facts->diagnostics[0]->message());
23    }
24
25    public function testDeriveStatementReportsAnOptionOnlyCreateAccepts(): void
26    {
27        self::assertSame('option "owner" not recognized', (new \SqlSemantics\Platform\PostgreSql\Semantics())->inspect('ALTER DATABASE d OWNER x')->facts->diagnostics[0]->message());
28    }
29}
30