packages/sql-semantics-mysql/tests/Unit/Model/Contract/LanguageProfileTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Model\Contract;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Model\Contract\GrammarRelease;
11use SqlSemantics\Platform\MySql\Model\Contract\LanguageProfile;
12use SqlSemantics\Platform\MySql\Model\Contract\LexicalSettings;
13use SqlSemantics\Platform\MySql\Model\Contract\ParameterStyle;
14
15#[CoversClass(LanguageProfile::class)]
16#[Small]
17final class LanguageProfileTest extends TestCase
18{
19    public function testCompatibleWithAcceptsAProfileOfTheSameArtifactsAndSettings(): void
20    {
21        $profile = new LanguageProfile(GrammarRelease::MySql8044, new LexicalSettings(), ParameterStyle::Named);
22        $other = new LanguageProfile(GrammarRelease::MySql8044, new LexicalSettings(), ParameterStyle::Named);
23
24        self::assertTrue($profile->compatibleWith($other));
25        self::assertSame('SQLSEM-DESIGN-001/1.0', $profile->ruleRevision);
26    }
27
28    public function testCompatibleWithRejectsAnotherParameterStyle(): void
29    {
30        $profile = new LanguageProfile(GrammarRelease::MySql8044);
31
32        self::assertFalse($profile->compatibleWith(new LanguageProfile(GrammarRelease::MySql8044, new LexicalSettings(), ParameterStyle::Named)));
33    }
34
35    public function testCompatibleWithRejectsAnotherGrammarRelease(): void
36    {
37        $profile = new LanguageProfile(GrammarRelease::MySql8044);
38
39        self::assertFalse($profile->compatibleWith(new LanguageProfile(GrammarRelease::MySql847)));
40    }
41
42    public function testCompatibleWithRejectsOtherLexicalSettings(): void
43    {
44        $profile = new LanguageProfile(GrammarRelease::MySql8044, new LexicalSettings('ANSI_QUOTES'));
45
46        self::assertFalse($profile->compatibleWith(new LanguageProfile(GrammarRelease::MySql8044)));
47    }
48}
49