packages/sql-semantics-postgres/tests/Unit/Statement/Catalog/Cast/CreateTransformTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Catalog\Cast;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlSemantics\Platform\PostgreSql\Statement\Catalog\Cast\CreateTransform::class)]
12#[Medium]
13final class CreateTransformTest extends TestCase
14{
15    public function testRenderKeepsTheOrder(): void
16    {
17        self::assertSame('CREATE OR REPLACE TRANSFORM FOR t LANGUAGE l (TO SQL WITH FUNCTION b (internal), FROM SQL WITH FUNCTION a (internal))', (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE OR REPLACE TRANSFORM FOR t LANGUAGE l (TO SQL WITH FUNCTION b(internal), FROM SQL WITH FUNCTION a(internal))')->toString());
18    }
19
20    public function testDeriveStatementDerivesTheFunctions(): void
21    {
22        self::assertSame([], (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TRANSFORM FOR t LANGUAGE l (FROM SQL WITH FUNCTION a(internal))')->facts->diagnostics);
23    }
24}
25