packages/sql-fixture/tests/Unit/Plan/Exception/CompositeArityMismatchExceptionTest.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;
10use SqlFixture\Plan\ColumnRef;
11
12#[CoversClass(\SqlFixture\Plan\Exception\CompositeArityMismatchException::class)]
13#[UsesClass(ColumnRef::class)]
14#[UsesClass(\SqlFixture\Plan\PlanSyntaxException::class)]
15#[UsesClass(\SqlFixture\Plan\Exception\EmptyPlanException::class)]
16#[UsesClass(\SqlFixture\Plan\Exception\EmptyTableNameException::class)]
17#[UsesClass(\SqlFixture\Plan\Exception\MissingEndpointColumnsException::class)]
18#[UsesClass(\SqlFixture\Plan\Exception\InvalidTableNameException::class)]
19#[UsesClass(\SqlFixture\Plan\Exception\UnbalancedBracketsException::class)]
20#[UsesClass(\SqlFixture\Plan\Exception\UnexpectedPlanTokenException::class)]
21#[UsesClass(\SqlFixture\Plan\Exception\UnsupportedManyToManyException::class)]
22final class CompositeArityMismatchExceptionTest extends TestCase
23{
24    public function testDescribesCompositeArityMismatch(): void
25    {
26        $exception = new \SqlFixture\Plan\Exception\CompositeArityMismatchException(
27            ColumnRef::of('order', 'shop_id', 'no'),
28            ColumnRef::of('order_detail', 'order_no')
29        );
30        $message = $exception->getMessage();
31
32        self::assertSame(
33            'The relation order.(shop_id, no) ... order_detail.order_no names 2 columns on '
34            . 'one side and 1 on the other.',
35            $message
36        );
37        self::assertEquals(ColumnRef::of('order', 'shop_id', 'no'), $exception->left);
38        self::assertEquals(ColumnRef::of('order_detail', 'order_no'), $exception->right);
39    }
40}
41