packages/sql-semantics-mysql/tests/Unit/Statement/Expression/Operator/IntervalTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Expression\Operator;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Contract\ParameterStyle;
11use SqlSemantics\Platform\MySql\Model\Rendering\Lexical;
12use SqlSemantics\Platform\MySql\Model\Rendering\Output;
13use SqlSemantics\Platform\MySql\Platform;
14use SqlSemantics\Platform\MySql\Statement\Expression\IntervalUnit;
15use SqlSemantics\Platform\MySql\Statement\Expression\Operator\Interval;
16use SqlSemantics\Platform\MySql\Statement\Literal\StringLiteral;
17
18#[CoversClass(Interval::class)]
19#[Medium]
20final class IntervalTest extends TestCase
21{
22 public function testRenderWritesTheQuantityAndTheUnit(): void
23 {
24 $platform = new Platform();
25 $out = new Output($platform->codec($platform->profile('mysql-8.4.7', null, ParameterStyle::Native)));
26 (new Interval(new StringLiteral(['1:30']), IntervalUnit::HourMinute))->render($out);
27
28 self::assertSame("INTERVAL '1:30' HOUR_MINUTE", (new Lexical())->join($out->pieces()));
29 }
30}
31