packages/sql-semantics-mysql/tests/Unit/Statement/Utility/Show/Program/ShowFunctionStatusTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Utility\Show\Program;
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\Utility\Show\Program\ShowFunctionStatus;
12
13#[CoversClass(ShowFunctionStatus::class)]
14#[Medium]
15final class ShowFunctionStatusTest extends TestCase
16{
17 public function testDeriveStatementRecordsTheRows(): void
18 {
19 $show = (new Semantics('mysql-8.0.44'))->analyze("SHOW FUNCTION STATUS LIKE 'x'");
20 self::assertInstanceOf(ShowFunctionStatus::class, $show->statement);
21 self::assertSame('Definer', $show->field(3)->name?->value);
22 }
23
24 public function testDeriveRelationShapesTheRowsOfTheRelease(): void
25 {
26 $show = (new Semantics('mysql-8.0.44'))->analyze("SHOW FUNCTION STATUS LIKE 'x'");
27 self::assertInstanceOf(ShowFunctionStatus::class, $show->statement);
28 $later = (new Semantics())->analyze('SHOW FUNCTION STATUS');
29 self::assertSame('Language', $later->field(3)->name?->value);
30 self::assertSame('Db', $show->facts->relation($show->statement)->shape->slots[0]->name?->value);
31 }
32
33 public function testRenderWritesTheStatement(): void
34 {
35 self::assertSame("SHOW FUNCTION STATUS LIKE 'x'", (new Semantics('mysql-8.0.44'))->analyze("SHOW FUNCTION STATUS LIKE 'x'")->toString());
36 }
37}
38