packages/sql-semantics-postgres/tests/Unit/Statement/Utility/Transaction/RollbackTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Utility\Transaction;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlSemantics\Platform\PostgreSql\Statement\Utility\Transaction\Rollback::class)]
12#[Medium]
13final class RollbackTest extends TestCase
14{
15    public function testDeriveStatementRecordsNoProblem(): void
16    {
17        self::assertSame([], (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ROLLBACK')->facts->diagnostics);
18    }
19
20    public function testRenderWritesTheChaining(): void
21    {
22        self::assertSame('ABORT AND NO CHAIN', (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ABORT AND NO CHAIN')->toString());
23    }
24
25    public function testSpellingIsRead(): void
26    {
27        $statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ABORT')->statement;
28        self::assertInstanceOf(\SqlSemantics\Platform\PostgreSql\Statement\Utility\Transaction\Rollback::class, $statement);
29        self::assertSame(\SqlSemantics\Platform\PostgreSql\Statement\Utility\Transaction\RollbackSpelling::Abort, $statement->spelling);
30    }
31}
32