packages/sql-semantics-mysql/tests/Unit/SqlNamesTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Medium;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name;
11use SqlSemantics\Platform\MySql\Model\Statement\Identifier\QualifiedName;
12use SqlSemantics\Platform\MySql\Semantics;
13use SqlSemantics\Platform\MySql\SqlNames;
14
15#[CoversClass(SqlNames::class)]
16#[Medium]
17final class SqlNamesTest extends TestCase
18{
19    public function testTableQuotesTheNameInTheSelectedDatabase(): void
20    {
21        $name = new QualifiedName(new Name('order items'), new Name('shop'));
22
23        self::assertSame('shop.`order items`', SqlNames::table($name, (new Semantics())->profile()));
24    }
25}
26