packages/sql-semantics-sqlite/tests/Unit/Model/Statement/StatementTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Model\Statement;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\Sqlite\Model\Construction\Derivation;
11use SqlSemantics\Platform\Sqlite\Model\Statement\Statement;
12use SqlSemantics\Platform\Sqlite\Semantics;
13
14#[CoversClass(Statement::class)]
15#[Medium]
16final class StatementTest extends TestCase
17{
18    public function testDeriveStatementRecordsTheRowsAndDeclarationsOfTheRoot(): void
19    {
20        $semantics = new Semantics();
21        $statement = $semantics->analyze('CREATE TABLE t (a INTEGER)')->statement;
22        $derivation = new Derivation($semantics->context([]));
23
24        $statement->deriveStatement($derivation);
25
26        self::assertCount(1, $derivation->facts()->declarations);
27        self::assertNull($derivation->facts()->output);
28    }
29}
30