packages/sql-semantics-mysql/tests/Unit/Statement/Server/Plugin/OnWordTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Server\Plugin;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Statement\Type\Known;
11use SqlSemantics\Platform\MySql\Semantics;
12use SqlSemantics\Platform\MySql\Statement\Server\Plugin\InstallComponent;
13use SqlSemantics\Platform\MySql\Statement\Server\Plugin\OnWord;
14use SqlSemantics\Platform\MySql\Statement\Type\Character;
15use SqlSemantics\Platform\MySql\Statement\Type\Kind\CharacterKind;
16
17#[CoversClass(OnWord::class)]
18#[Medium]
19final class OnWordTest extends TestCase
20{
21 public function testRenderWritesOn(): void
22 {
23 self::assertSame("INSTALL COMPONENT 'c' SET c.v = ON", (new Semantics())->analyze("install component 'c' set c.v = on")->toString());
24 }
25
26 public function testDeriveScalarIsAString(): void
27 {
28 $install = (new Semantics())->analyze("INSTALL COMPONENT 'c' SET c.v = ON");
29 self::assertInstanceOf(InstallComponent::class, $install->statement);
30
31 self::assertEquals(new Known(new Character(CharacterKind::VarChar)), $install->facts->scalar($install->statement->settings[0]->value)->type);
32 }
33}
34