packages/sql-semantics-postgres/tests/Unit/Rules/Routine/RoutineFactsTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Rules\Routine;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name;
11use SqlSemantics\Platform\PostgreSql\Model\Statement\Reference\Column\MissingColumn;
12use SqlSemantics\Platform\PostgreSql\Rules\Routine\RoutineFacts;
13use SqlSemantics\Platform\PostgreSql\Semantics;
14
15#[CoversClass(RoutineFacts::class)]
16#[Medium]
17final class RoutineFactsTest extends TestCase
18{
19    public function testCreateHidesParametersFromDefaults(): void
20    {
21        $operation = (new Semantics())->inspect('CREATE FUNCTION f(a int4, b int4 DEFAULT a) RETURNS int4 RETURN b', []);
22        self::assertEquals([new MissingColumn(new Name('a'))], $operation->facts->diagnostics);
23    }
24}
25