packages/sql-formatter/tests/Unit/Core/Syntax/RulesTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Core\Syntax;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\TestWith;
9use PHPUnit\Framework\TestCase;
10use SqlFormatter\Core\Syntax\Rules;
11
12#[CoversClass(Rules::class)]
13#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Core\Formatter::class)]
14#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Core\Compact\Settings::class)]
15#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Platform\MySql\Dialect::class)]
16#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Platform\PostgreSql\Dialect::class)]
17#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Platform\Sqlite\Dialect::class)]
18#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Facade\DialectFactory::class)]
19final class RulesTest extends TestCase
20{
21    #[TestWith(['joined_table', true])]
22    #[TestWith(['joinop', true])]
23    #[TestWith(['columnref', false])]
24    public function testHasRecognizesConfiguredGrammarOwners(string $name, bool $expected): void
25    {
26        self::assertSame($expected, (new Rules(['joins' => ['joined_table', 'joinop']], []))->has('joins', $name));
27    }
28}
29