packages/sql-semantics-postgres/tests/Unit/Statement/Object/Problem/AttributeProblemTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Object\Problem;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\PostgreSql\Statement\Object\Problem\AttributeProblem;
11use SqlSemantics\Platform\PostgreSql\Statement\Object\Problem\AttributeProblemKind;
12
13#[CoversClass(AttributeProblem::class)]
14#[Small]
15final class AttributeProblemTest extends TestCase
16{
17 public function testMessageInsertsEverySubject(): void
18 {
19 self::assertSame('invalid argument for internallength: "fixed"', (new AttributeProblem(AttributeProblemKind::InvalidLength, ['internallength', 'fixed']))->message());
20 }
21
22 public function testWarningFollowsTheKind(): void
23 {
24 self::assertSame([true, false], [(new AttributeProblem(AttributeProblemKind::UnrecognizedAggregateAttribute, ['x']))->warning(), (new AttributeProblem(AttributeProblemKind::UnrecognizedCollationAttribute, ['x']))->warning()]);
25 }
26
27 public function testRejectsAMissingSubject(): void
28 {
29 $this->expectExceptionMessage('A problem has one subject for each place in its message.');
30 new AttributeProblem(AttributeProblemKind::NotAName);
31 }
32}
33