packages/sql-semantics-postgres/tests/Unit/Statement/Table/Index/AlterStatisticsTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Table\Index;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlSemantics\Platform\PostgreSql\Statement\Table\Index\AlterStatistics::class)]
12#[Medium]
13final class AlterStatisticsTest extends TestCase
14{
15    public function testDeriveStatementHasNoOperand(): void
16    {
17        $semantics = new \SqlSemantics\Platform\PostgreSql\Semantics();
18        $statement = $semantics->analyze('ALTER STATISTICS s SET STATISTICS 5', []);
19        self::assertSame([
20        ], array_map(static fn ($problem): string => $problem->message(), $statement->facts->diagnostics));
21    }
22
23    public function testRenderWritesTheClauseAsWritten(): void
24    {
25        $semantics = new \SqlSemantics\Platform\PostgreSql\Semantics();
26        $statement = $semantics->analyze('ALTER STATISTICS IF EXISTS x.s SET STATISTICS -1', []);
27        self::assertSame('ALTER STATISTICS IF EXISTS x.s SET STATISTICS - 1', $statement->toString());
28    }
29}
30