packages/sql-fixture/tests/Unit/Plan/Exception/UnexpectedPlanTokenExceptionTest.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\UnexpectedPlanTokenException::class)]
12#[UsesClass(\SqlFixture\Plan\PlanSyntaxException::class)]
13#[UsesClass(\SqlFixture\Plan\Exception\EmptyPlanException::class)]
14#[UsesClass(\SqlFixture\Plan\Exception\EmptyTableNameException::class)]
15#[UsesClass(\SqlFixture\Plan\Exception\MissingEndpointColumnsException::class)]
16#[UsesClass(\SqlFixture\Plan\Exception\InvalidTableNameException::class)]
17#[UsesClass(\SqlFixture\Plan\Exception\UnbalancedBracketsException::class)]
18#[UsesClass(\SqlFixture\Plan\Exception\UnsupportedManyToManyException::class)]
19#[UsesClass(\SqlFixture\Plan\Exception\CompositeArityMismatchException::class)]
20final class UnexpectedPlanTokenExceptionTest extends TestCase
21{
22 public function testDescribesUnexpectedPlanToken(): void
23 {
24 $exception = new \SqlFixture\Plan\Exception\UnexpectedPlanTokenException('order.id ! x.y', 9, "one of '<', '>' or '-'");
25 $message = $exception->getMessage();
26
27 self::assertSame(
28 "Cannot parse the fixture plan at offset 9: expected one of '<', '>' or '-'. "
29 . 'Plan: order.id ! x.y',
30 $message
31 );
32 self::assertSame('order.id ! x.y', $exception->plan);
33 self::assertSame(9, $exception->offset);
34 self::assertSame("one of '<', '>' or '-'", $exception->expected);
35 }
36}
37