packages/sql-semantics-mysql/tests/Unit/Lowering/Expression/ListRuleTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Lowering\Expression;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Lowering\Expression\ListRule;
11use SqlSemantics\Platform\MySql\Lowering\Lowering;
12use SqlSemantics\Platform\MySql\Model\Contract\ParameterStyle;
13use SqlSemantics\Platform\MySql\Model\Lowering\Leaves;
14use SqlSemantics\Platform\MySql\Platform;
15
16#[CoversClass(ListRule::class)]
17#[Medium]
18final class ListRuleTest extends TestCase
19{
20    public function testExpressionsLowersAListAndAnAbsentList(): void
21    {
22        $platform = new Platform();
23        $profile = $platform->profile('mysql-8.4.7', null, ParameterStyle::Native);
24        $lowering = new Lowering($platform->productions($profile), new Leaves(), $profile);
25        $rule = new ListRule($lowering);
26
27        self::assertCount(3, $rule->expressions($platform->parser($profile)->parse('SELECT 1 IN (1, 2, 3, 4)')->find('expr_list')[0]));
28        self::assertSame([], $rule->expressions($platform->parser($profile)->parse('SELECT GEOMETRYCOLLECTION()')->find('opt_expr_list')[0]));
29    }
30}
31