packages/sql-fixture/tests/Unit/Plan/Exception/UnboundedSelfReferenceExceptionTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Plan\Exception;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\UsesClass;
9use PHPUnit\Framework\TestCase;
10
11#[CoversClass(\SqlFixture\Plan\Exception\UnboundedSelfReferenceException::class)]
12#[UsesClass(\SqlFixture\Plan\PlanStructureException::class)]
13#[UsesClass(\SqlFixture\Plan\Exception\DuplicateColumnBindingException::class)]
14#[UsesClass(\SqlFixture\Plan\Exception\CyclicDependencyException::class)]
15final class UnboundedSelfReferenceExceptionTest extends TestCase
16{
17 public function testDescribesUnboundedSelfReference(): void
18 {
19 $exception = new \SqlFixture\Plan\Exception\UnboundedSelfReferenceException(
20 'category',
21 'category.id < category.parent_id'
22 );
23 $message = $exception->getMessage();
24
25 self::assertSame(
26 'The relation category.id < category.parent_id makes every category row need '
27 . 'another one, without end. Mark the child optional with ? so the chain can stop.',
28 $message
29 );
30 self::assertSame('category', $exception->table);
31 self::assertSame('category.id < category.parent_id', $exception->written);
32 }
33}
34