packages/sql-semantics-mysql/tests/Unit/Statement/Server/Maintenance/RepairTableTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Server\Maintenance;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Semantics;
11use SqlSemantics\Platform\MySql\Statement\Server\Maintenance\RepairTable;
12use SqlSemantics\Platform\MySql\Statement\Server\Problem\NonUniqueTable;
13
14#[CoversClass(RepairTable::class)]
15#[Medium]
16final class RepairTableTest extends TestCase
17{
18    public function testRenderWritesTheOptions(): void
19    {
20        self::assertSame('REPAIR TABLE t EXTENDED', (new Semantics('mysql-5.7.44'))->inspect('repair table t extended')->toString());
21    }
22
23    public function testDeriveStatementReportsATableNamedTwice(): void
24    {
25        $operation = (new Semantics())->inspect('REPAIR TABLE t, db.u, t');
26
27        self::assertInstanceOf(NonUniqueTable::class, $operation->facts->diagnostics[0]);
28    }
29}
30