packages/sql-formatter/tests/Unit/Core/FormatOptionsTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Core;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\TestWith;
9use PHPUnit\Framework\TestCase;
10use SqlFormatter\Core\FormatOptions;
11use SqlFormatter\Core\Style;
12
13#[CoversClass(FormatOptions::class)]
14#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Core\Formatter::class)]
15#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Core\Compact\Settings::class)]
16#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Platform\MySql\Dialect::class)]
17#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Platform\PostgreSql\Dialect::class)]
18#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Platform\Sqlite\Dialect::class)]
19#[\PHPUnit\Framework\Attributes\UsesClass(\SqlFormatter\Facade\DialectFactory::class)]
20final class FormatOptionsTest extends TestCase
21{
22 public function testDefaultLayout(): void
23 {
24 $options = new FormatOptions();
25 self::assertSame(Style::Expanded, $options->style);
26 self::assertSame(4, $options->indentWidth);
27 }
28
29 #[TestWith([1])]
30 #[TestWith([16])]
31 public function testIndentLimits(int $width): void
32 {
33 $options = new FormatOptions(Style::River, $width);
34 self::assertSame($width, $options->indentWidth);
35 self::assertSame(Style::River, $options->style);
36 }
37
38}
39