packages/sql-semantics-mysql/tests/Unit/Statement/Expression/Branching/CaseBranchTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Expression\Branching;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
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\Expression\Branching\CaseBranch;
15use SqlSemantics\Platform\MySql\Statement\Literal\NumberLiteral;
16
17#[CoversClass(CaseBranch::class)]
18#[Medium]
19final class CaseBranchTest extends TestCase
20{
21 public function testRenderWritesWhenAndThen(): void
22 {
23 $platform = new Platform();
24 $out = new Output($platform->codec($platform->profile('mysql-8.4.7', null, ParameterStyle::Native)));
25 (new CaseBranch(new NumberLiteral('1'), new NumberLiteral('2')))->render($out);
26
27 self::assertSame('WHEN 1 THEN 2', (new Lexical())->join($out->pieces()));
28 }
29}
30