packages/sql-semantics-mysql/tests/Unit/Statement/Partition/Method/ExpressionMethodTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Partition\Method;
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\Partition\Method\ExpressionMethod;
12
13#[CoversClass(ExpressionMethod::class)]
14#[Medium]
15final class ExpressionMethodTest extends TestCase
16{
17 public function testDeriveMethodReportsAColumnTheTableDoesNotHave(): void
18 {
19 $semantics = new Semantics();
20 $table = $semantics->inspect('CREATE TABLE t (a INT)');
21
22 self::assertSame('Column q does not exist.', $semantics->inspect('ALTER TABLE t PARTITION BY RANGE (q) (PARTITION p VALUES LESS THAN MAXVALUE)', [$table])->facts->diagnostics[0]->message());
23 }
24
25 public function testRenderWritesTheKind(): void
26 {
27 self::assertSame('ALTER TABLE t PARTITION BY LIST (a) (PARTITION p VALUES IN (1, 2))', (new Semantics())->inspect('ALTER TABLE t PARTITION BY LIST (a) (PARTITION p VALUES IN (1, 2))')->toString());
28 }
29}
30