packages/ztd-query-postgres/tests/Unit/Schema/Reflection/Key/ForeignKeyRowTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Schema\Reflection\Key;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9
10#[CoversClass(\ZtdQuery\Platform\Postgres\Schema\Reflection\Key\ForeignKeyRow::class)]
11final class ForeignKeyRowTest extends TestCase
12{
13 public function testParseValidatesAllReferencedMetadata(): void
14 {
15 self::assertSame(['name' => 'fk_user', 'column' => 'user_id', 'table' => 'users', 'referencedColumn' => 'id', 'onUpdate' => 'CASCADE', 'onDelete' => 'RESTRICT'], (new \ZtdQuery\Platform\Postgres\Schema\Reflection\Key\ForeignKeyRow())->parse(['constraint_name' => 'fk_user', 'column_name' => 'user_id', 'foreign_table_name' => 'users', 'foreign_column_name' => 'id', 'update_rule' => 'CASCADE', 'delete_rule' => 'RESTRICT']));
16 self::assertNull((new \ZtdQuery\Platform\Postgres\Schema\Reflection\Key\ForeignKeyRow())->parse(['constraint_name' => 'incomplete']));
17 }
18}
19