packages/sql-semantics-sqlite/tests/Unit/Statement/Transaction/SavepointTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Transaction;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\Sqlite\Semantics;
11use SqlSemantics\Platform\Sqlite\Statement\Transaction\Savepoint;
12
13#[CoversClass(Savepoint::class)]
14#[Medium]
15final class SavepointTest extends TestCase
16{
17    public function testDeriveStatementRecordsNoFact(): void
18    {
19        $operation = (new Semantics())->analyze('SAVEPOINT s1', []);
20
21        self::assertNull($operation->shape());
22        self::assertSame([], $operation->facts->diagnostics);
23    }
24
25    public function testRenderWritesTheDecodedName(): void
26    {
27        $operation = (new Semantics())->analyze("savepoint 'before import'");
28
29        self::assertInstanceOf(Savepoint::class, $operation->statement);
30        self::assertSame('before import', $operation->statement->name->value);
31        self::assertSame('SAVEPOINT `before import`', $operation->toString());
32    }
33}
34