packages/ztd-query-postgres/tests/Unit/Shadow/Mutation/Upsert/Expression/ExpressionCursorTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Shadow\Mutation\Upsert\Expression;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9
10#[CoversClass(\ZtdQuery\Platform\Postgres\Shadow\Mutation\Upsert\Expression\ExpressionCursor::class)]
11#[\PHPUnit\Framework\Attributes\UsesClass(\ZtdQuery\Platform\Postgres\Sql\PgSqlLexerProfile::class)]
12final class ExpressionCursorTest extends TestCase
13{
14 public function testRetainsTheSourceAndStartsAtTheFirstToken(): void
15 {
16 $sql = 'id + 1';
17 $tokens = \ZtdQuery\Sql\SqlTokenStream::tokenize($sql, \ZtdQuery\Platform\Postgres\Sql\PgSqlLexerProfile::create())->significantTokens();
18 $cursor = new \ZtdQuery\Platform\Postgres\Shadow\Mutation\Upsert\Expression\ExpressionCursor($sql, 'users', $tokens);
19 self::assertSame('id + 1', $cursor->sql);
20 self::assertSame('users', $cursor->tableName);
21 self::assertSame($tokens, $cursor->tokens);
22 self::assertSame(0, $cursor->index);
23 }
24}
25