packages/sql-semantics-mysql/tests/Unit/Statement/Alter/Command/DropElementTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Alter\Command;
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\Alter\Command\DropElement;
12
13#[CoversClass(DropElement::class)]
14#[Medium]
15final class DropElementTest extends TestCase
16{
17 public function testDeriveCommandDerivesNothing(): void
18 {
19 $semantics = new Semantics();
20 $table = $semantics->analyze('CREATE TABLE t (a INT, b INT)');
21 $alter = $semantics->analyze('ALTER TABLE t DROP INDEX i, DROP FOREIGN KEY f', [$table]);
22
23 self::assertSame([], $alter->facts->diagnostics);
24 }
25
26 public function testRenderWritesEveryKind(): void
27 {
28 self::assertSame('ALTER TABLE t DROP COLUMN a CASCADE, DROP PRIMARY KEY, DROP INDEX i, DROP CHECK c, DROP CONSTRAINT d', (new Semantics())->analyze('ALTER TABLE t DROP a CASCADE, DROP PRIMARY KEY, DROP KEY i, DROP CHECK c, DROP CONSTRAINT d')->toString());
29 }
30}
31