packages/ztd-query-core/tests/Unit/Exception/SchemaNotFoundExceptionTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Exception;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9use ZtdQuery\Exception\SchemaNotFoundException;
10
11#[CoversClass(SchemaNotFoundException::class)]
12final class SchemaNotFoundExceptionTest extends TestCase
13{
14 public function testGetMessageReturnsFormattedMessage(): void
15 {
16 $exception = new SchemaNotFoundException(
17 'SELECT * FROM users',
18 'users'
19 );
20
21 self::assertSame("Table 'users' does not exist.", $exception->getMessage());
22 }
23
24 public function testGetSqlReturnsOriginalSql(): void
25 {
26 $sql = 'SELECT * FROM users';
27 $exception = new SchemaNotFoundException($sql, 'users');
28
29 self::assertSame($sql, $exception->getSql());
30 }
31
32 public function testGetTableNameReturnsTableName(): void
33 {
34 $exception = new SchemaNotFoundException('sql', 'users');
35
36 self::assertSame('users', $exception->getTableName());
37 }
38
39}
40