packages/sql-semantics-mysql/tests/Unit/Statement/Partition/PartitionEntryTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Partition;
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\Problem\PartitionEntryRefused;
12use SqlSemantics\Platform\MySql\Statement\Partition\PartitionEntry;
13
14#[CoversClass(PartitionEntry::class)]
15#[Medium]
16final class PartitionEntryTest extends TestCase
17{
18 public function testDeriveStatementReportsTheRefusal(): void
19 {
20 $entry = (new Semantics('mysql-5.6.51'))->inspect('PARTITION BY KEY ()');
21
22 self::assertInstanceOf(PartitionEntryRefused::class, $entry->facts->diagnostics[0]);
23 }
24
25 public function testRenderWritesTheClause(): void
26 {
27 self::assertSame('PARTITION BY HASH (1) PARTITIONS 2', (new Semantics('mysql-5.7.44'))->inspect('partition by hash (1) partitions 2')->toString());
28 }
29}
30