packages/sql-semantics-mysql/tests/Unit/Statement/Call/CallArgumentTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Call;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
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\Model\Statement\Identifier\Name;
14use SqlSemantics\Platform\MySql\Platform;
15use SqlSemantics\Platform\MySql\Statement\Call\CallArgument;
16use SqlSemantics\Platform\MySql\Statement\Name\ColumnUse;
17
18#[CoversClass(CallArgument::class)]
19#[Small]
20final class CallArgumentTest extends TestCase
21{
22 public function testRenderWritesTheAlias(): void
23 {
24 $platform = new Platform();
25 $profile = $platform->profile('mysql-8.4.7', null, ParameterStyle::Native);
26 $out = new Output($platform->codec($profile));
27 (new CallArgument(new ColumnUse(new Name('a')), new Name('total')))->render($out);
28
29 self::assertSame('a AS total', (new Lexical())->join($out->pieces()));
30 }
31}
32