packages/sql-semantics-postgres/tests/Unit/Lowering/StatementRoutesTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Lowering;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\PostgreSql\Lowering\StatementRoutes;
11use SqlSemantics\Platform\PostgreSql\Model\Contract\GrammarRelease;
12use SqlSemantics\Platform\PostgreSql\Model\Contract\LanguageProfile;
13use SqlSemantics\Platform\PostgreSql\Platform;
14
15#[CoversClass(StatementRoutes::class)]
16#[Small]
17final class StatementRoutesTest extends TestCase
18{
19    public function testRoutesCoverEveryStatementOfBothReleases(): void
20    {
21        $platform = new Platform();
22        $all = [...$platform->productions(new LanguageProfile(GrammarRelease::PostgreSql166))->all(), ...$platform->productions(new LanguageProfile(GrammarRelease::PostgreSql172))->all()];
23        $expected = array_values(array_unique(array_filter($all, static fn (string $signature): bool => str_starts_with($signature, 'stmt: '))));
24        $routed = array_keys(StatementRoutes::ROUTES);
25        sort($expected);
26        sort($routed);
27        self::assertSame($expected, $routed);
28    }
29}
30