packages/sql-fixture/tests/Unit/Schema/SchemaNotFoundExceptionTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Schema;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Test;
9use PHPUnit\Framework\TestCase;
10use SqlFixture\Schema\SchemaNotFoundException;
11
12#[CoversClass(SchemaNotFoundException::class)]
13final class SchemaNotFoundExceptionTest extends TestCase
14{
15 #[Test]
16 public function testForTableNamesTheMissingTable(): void
17 {
18 self::assertSame(
19 'Schema not found for table: order',
20 (new SchemaNotFoundException('order'))->getMessage()
21 );
22 }
23
24 #[Test]
25 public function testListsKnownTablesAlphabetically(): void
26 {
27 self::assertSame(
28 'Schema not found for table: order. Known tables: customer, product',
29 (new SchemaNotFoundException('order', ['product', 'customer']))->getMessage()
30 );
31 }
32
33 public function testRetainsTheMissingTableAndAvailableSchemas(): void
34 {
35 $exception = new SchemaNotFoundException('orders', ['products', 'customers']);
36 self::assertSame('orders', $exception->tableName);
37 self::assertSame(['customers', 'products'], $exception->knownTables);
38 }
39}
40