packages/sql-fixture/tests/Unit/Plan/Exception/CyclicDependencyExceptionTest.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\CyclicDependencyException::class)]
12#[UsesClass(\SqlFixture\Plan\PlanStructureException::class)]
13#[UsesClass(\SqlFixture\Plan\Exception\DuplicateColumnBindingException::class)]
14#[UsesClass(\SqlFixture\Plan\Exception\UnboundedSelfReferenceException::class)]
15final class CyclicDependencyExceptionTest extends TestCase
16{
17    public function testDescribesCyclicDependency(): void
18    {
19        $exception = new \SqlFixture\Plan\Exception\CyclicDependencyException(['a', 'b', 'c']);
20        $message = $exception->getMessage();
21
22        self::assertSame(
23            'The plan contains cyclic dependencies among: a, b, c. No generation order satisfies them.',
24            $message
25        );
26        self::assertSame(['a', 'b', 'c'], $exception->blockedTables);
27    }
28}
29