packages/ztd-query-postgres/tests/Unit/Sql/Value/LiteralTextTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Sql\Value;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9
10#[CoversClass(\ZtdQuery\Platform\Postgres\Sql\Value\LiteralText::class)]
11final class LiteralTextTest extends TestCase
12{
13 public function testQuotedEscapesScalars(): void
14 {
15 $text = new \ZtdQuery\Platform\Postgres\Sql\Value\LiteralText();
16 self::assertSame("'O''Reilly'", $text->quoted("O'Reilly"));
17 self::assertSame("'0'", $text->quoted(false));
18 self::assertSame("'1.5'", $text->quoted(1.5));
19 }
20
21 public function testUntypedPreservesNativeLiteralExpressions(): void
22 {
23 $text = new \ZtdQuery\Platform\Postgres\Sql\Value\LiteralText();
24 self::assertSame('TRUE', $text->untyped(true));
25 self::assertSame('FALSE', $text->untyped(false));
26 self::assertSame('1.5', $text->untyped(1.5));
27 }
28}
29