packages/sql-semantics-sqlite/tests/Unit/Model/Resolution/CommonBindingTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Model\Resolution;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\Sqlite\Model\Resolution\CommonBinding;
11use SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name;
12use SqlSemantics\Platform\Sqlite\Model\Statement\Shape\OutputSlot;
13use SqlSemantics\Platform\Sqlite\Model\Statement\Shape\RowShape;
14use SqlSemantics\Platform\Sqlite\Model\Statement\Type\Known;
15use SqlSemantics\Platform\Sqlite\Model\Statement\Type\Nullability;
16use SqlSemantics\Platform\Sqlite\Statement\Query\Star;
17use SqlSemantics\Platform\Sqlite\Statement\Type\Storage;
18
19#[CoversClass(CommonBinding::class)]
20#[Small]
21final class CommonBindingTest extends TestCase
22{
23    public function testABindingTiesANameToItsDefinitionAndShape(): void
24    {
25        $definition = new Star();
26        $shape = new RowShape([new OutputSlot(new Name('a'), new Known(Storage::Integer), Nullability::NotNull)]);
27
28        $binding = new CommonBinding(new Name('c'), $definition, $shape);
29
30        self::assertSame('c', $binding->name->value);
31        self::assertSame($definition, $binding->definition);
32        self::assertSame($shape, $binding->shape);
33    }
34}
35