packages/sql-semantics-mysql/tests/Unit/Rules/Server/AdminRowsTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Rules\Server;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Statement\Type\Nullability;
11use SqlSemantics\Platform\MySql\Rules\Server\AdminRows;
12use SqlSemantics\Platform\MySql\Semantics;
13
14#[CoversClass(AdminRows::class)]
15#[Medium]
16final class AdminRowsTest extends TestCase
17{
18 public function testAdminRecordsTheMaintenanceResult(): void
19 {
20 $check = (new Semantics())->analyze('CHECK TABLE t');
21
22 self::assertSame(4, $check->fields()?->count());
23 self::assertSame(Nullability::Nullable, $check->field('Msg_text')->slot->nullability);
24 }
25
26 public function testChecksumRecordsTableAndChecksum(): void
27 {
28 $checksum = (new Semantics())->analyze('CHECKSUM TABLE t');
29
30 self::assertSame(Nullability::Nullable, $checksum->field('Checksum')->slot->nullability);
31 }
32
33 public function testRecoverRecordsThePreparedTransactions(): void
34 {
35 $recover = (new Semantics())->analyze('XA RECOVER');
36
37 self::assertSame(Nullability::NotNull, $recover->field('data')->slot->nullability);
38 }
39
40 public function testRecordRecordsTheLayout(): void
41 {
42 $cache = (new Semantics())->analyze('LOAD INDEX INTO CACHE t');
43
44 self::assertSame('Op', $cache->field(1)->slot->name?->value);
45 }
46}
47