packages/sql-semantics-postgres/tests/Unit/Rules/Query/ClosedListTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Rules\Query;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlSemantics\Platform\PostgreSql\Rules\Query\ClosedList::class)]
12#[Small]
13final class ClosedListTest extends TestCase
14{
15    public function testOfAcceptsItemsOfTheClasses(): void
16    {
17        self::assertCount(1, (new \SqlSemantics\Platform\PostgreSql\Rules\Query\ClosedList())->of([new \SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant('1'))], [\SqlSemantics\Platform\PostgreSql\Model\Statement\Scalar::class], 'm'));
18    }
19
20    public function testOfRefusesAnItemOfAnotherClass(): void
21    {
22        $this->expectExceptionMessage('m');
23        (new \SqlSemantics\Platform\PostgreSql\Rules\Query\ClosedList())->of([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('a')], [\SqlSemantics\Platform\PostgreSql\Model\Statement\Scalar::class], 'm');
24    }
25}
26