packages/sql-semantics-postgres/tests/Unit/Statement/Expression/Constructor/CaseBranchTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Expression\Constructor;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\PostgreSql\Model\Contract\GrammarRelease;
11use SqlSemantics\Platform\PostgreSql\Model\Rendering\Lexical;
12use SqlSemantics\Platform\PostgreSql\Model\Rendering\Output;
13use SqlSemantics\Platform\PostgreSql\Rendering\Codec;
14use SqlSemantics\Platform\PostgreSql\Statement\Expression\Constructor\CaseBranch;
15use SqlSemantics\Platform\PostgreSql\Statement\Literal\BooleanLiteral;
16use SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral;
17
18#[CoversClass(CaseBranch::class)]
19#[Small]
20final class CaseBranchTest extends TestCase
21{
22 public function testRenderWritesWhenAndThen(): void
23 {
24 $out = new Output(new Codec(GrammarRelease::PostgreSql172));
25 (new CaseBranch(new BooleanLiteral(true), new NullLiteral()))->render($out);
26 self::assertSame('WHEN TRUE THEN NULL', (new Lexical())->join($out->pieces()));
27 }
28}
29