packages/sql-semantics-sqlite/tests/Unit/Model/Statement/SelectionTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Model\Statement;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\Sqlite\Model\Statement\Selection;
11use SqlSemantics\Platform\Sqlite\Semantics;
12use SqlSemantics\Platform\Sqlite\Statement\Relation\TableInput;
13
14#[CoversClass(Selection::class)]
15#[Medium]
16final class SelectionTest extends TestCase
17{
18 public function testInputAnswersTheRelationStructureOrNull(): void
19 {
20 $semantics = new Semantics();
21 $withInput = $semantics->analyze('SELECT a FROM t')->statement;
22 $withoutInput = $semantics->analyze('SELECT 1')->statement;
23
24 self::assertInstanceOf(Selection::class, $withInput);
25 self::assertInstanceOf(Selection::class, $withoutInput);
26 self::assertInstanceOf(TableInput::class, $withInput->input());
27 self::assertNull($withoutInput->input());
28 }
29}
30