packages/sql-semantics-mysql/tests/Unit/Statement/Call/WindowSpecificationTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Call;
6
7use PHPUnit\Framework\Attributes\CoversNothing;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Construction\Derivation;
11use SqlSemantics\Platform\MySql\Model\Contract\ParameterStyle;
12use SqlSemantics\Platform\MySql\Model\Statement\Type\Nullability;
13use SqlSemantics\Platform\MySql\Platform;
14use SqlSemantics\Platform\MySql\Statement\Call\Window\WindowSpec;
15use SqlSemantics\Platform\MySql\Statement\Call\WindowSpecification;
16use SqlSemantics\Platform\MySql\Statement\Literal\NumberLiteral;
17use SqlSemantics\Platform\MySql\Statement\Query\OrderItem;
18
19#[CoversNothing]
20#[Small]
21final class WindowSpecificationTest extends TestCase
22{
23 public function testDeriveWindowDerivesTheExpressions(): void
24 {
25 $platform = new Platform();
26 $derivation = new Derivation($platform->context($platform->profile('mysql-8.4.7', null, ParameterStyle::Native), null, [], false));
27 $partition = new NumberLiteral('1');
28 (new WindowSpec(null, [new OrderItem($partition)]))->deriveWindow($derivation, $derivation->environment());
29
30 self::assertSame(Nullability::NotNull, $derivation->facts()->scalar($partition)->nullability);
31 self::assertContains(WindowSpecification::class, class_implements(WindowSpec::class));
32 }
33}
34