packages/sql-semantics-sqlite/tests/Unit/Model/Statement/Shape/AbsentFieldTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Model\Statement\Shape;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\Sqlite\Model\Statement\Shape\AbsentField;
11use SqlSemantics\Platform\Sqlite\Semantics;
12
13#[CoversClass(AbsentField::class)]
14#[Medium]
15final class AbsentFieldTest extends TestCase
16{
17    public function testNameIsTheLookedUpNameOfACompleteShape(): void
18    {
19        $lookup = (new Semantics())->analyze('SELECT 1 AS a')->lookupField('b');
20
21        self::assertInstanceOf(AbsentField::class, $lookup);
22        self::assertSame('b', $lookup->name);
23    }
24
25    public function testNameOfAPositionWithoutNameIsNeverFound(): void
26    {
27        $lookup = (new Semantics())->analyze('SELECT 1')->lookupField('');
28
29        self::assertInstanceOf(AbsentField::class, $lookup);
30    }
31}
32