packages/sql-semantics-mysql/tests/Unit/Statement/Call/Json/JsonResponseTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Call\Json;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Contract\ParameterStyle;
11use SqlSemantics\Platform\MySql\Model\Rendering\Lexical;
12use SqlSemantics\Platform\MySql\Model\Rendering\Output;
13use SqlSemantics\Platform\MySql\Platform;
14use SqlSemantics\Platform\MySql\Statement\Call\Json\JsonResponse;
15use SqlSemantics\Platform\MySql\Statement\Call\Json\JsonResponseKind;
16use SqlSemantics\Platform\MySql\Statement\Literal\NumberLiteral;
17
18#[CoversClass(JsonResponse::class)]
19#[Small]
20final class JsonResponseTest extends TestCase
21{
22 public function testRenderWritesTheDefault(): void
23 {
24 $platform = new Platform();
25 $profile = $platform->profile('mysql-8.4.7', null, ParameterStyle::Native);
26 $out = new Output($platform->codec($profile));
27 (new JsonResponse(JsonResponseKind::Default, new NumberLiteral('1')))->render($out);
28
29 self::assertSame('DEFAULT 1', (new Lexical())->join($out->pieces()));
30 }
31}
32