packages/ztd-query-postgres/tests/Unit/Schema/Reflection/Key/IndexDefinitionsTest.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\IndexDefinitions::class)]
11final class IndexDefinitionsTest extends TestCase
12{
13 public function testKeepsSqlAndPartialMetadataSeparate(): void
14 {
15 $index = new \ZtdQuery\Schema\Key\PartialUniqueIndex('active_email', ['email'], 'active');
16 $definitions = new \ZtdQuery\Platform\Postgres\Schema\Reflection\Key\IndexDefinitions(['CONSTRAINT "unique_id" UNIQUE ("id")'], ['active_email' => $index]);
17 self::assertSame(['CONSTRAINT "unique_id" UNIQUE ("id")'], $definitions->sql);
18 self::assertSame(['active_email' => $index], $definitions->partialIndexes);
19 }
20}
21