packages/sql-catalog/tests/Unit/Core/Php/SyntaxExceptionTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Core\Php;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9use RuntimeException;
10use SqlCatalog\Core\Php\SyntaxException;
11
12#[CoversClass(SyntaxException::class)]
13final class SyntaxExceptionTest extends TestCase
14{
15 public function testMessageNamesTheFileAndTheReason(): void
16 {
17 $exception = new SyntaxException('a.php', 'unexpected token');
18 self::assertSame('Cannot parse "a.php": unexpected token.', $exception->getMessage());
19 self::assertSame('a.php', $exception->path);
20 }
21
22 public function testTheWrappedErrorIsKept(): void
23 {
24 $previous = new RuntimeException('inner');
25 self::assertSame($previous, (new SyntaxException('a.php', 'broken', $previous))->getPrevious());
26 }
27}
28