|
7 | 7 | use Doctrine\DBAL\Platforms\SqlitePlatform;
|
8 | 8 | use Doctrine\DBAL\Schema\Column;
|
9 | 9 | use Doctrine\DBAL\Schema\ForeignKeyConstraint;
|
| 10 | +use Doctrine\DBAL\Schema\SqliteSchemaManager; |
10 | 11 | use Doctrine\DBAL\Schema\Table;
|
11 | 12 | use Doctrine\DBAL\Schema\TableDiff;
|
12 | 13 | use Doctrine\DBAL\Types\BlobType;
|
13 | 14 | use Doctrine\DBAL\Types\Type;
|
14 | 15 | use Doctrine\DBAL\Types\Types;
|
15 |
| -use ReflectionMethod; |
16 | 16 |
|
17 | 17 | use function array_keys;
|
18 | 18 | use function array_map;
|
@@ -421,33 +421,58 @@ public function testListTableNoSchemaEmulation(): void
|
421 | 421 | CREATE INDEX i ON `list_table_no_schema_emulation.test` (parent_id);
|
422 | 422 | DDL);
|
423 | 423 |
|
424 |
| - $schemaManager = $this->schemaManager; |
425 |
| - $refl = new ReflectionMethod($schemaManager, 'selectTableColumns'); |
426 |
| - $refl->setAccessible(true); |
427 |
| - $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
428 |
| - ->fetchAllAssociative(); |
429 |
| - |
430 |
| - self::assertSame([ |
431 |
| - ['list_table_no_schema_emulation.test', 'id'], |
432 |
| - ['list_table_no_schema_emulation.test', 'parent_id'], |
433 |
| - ], array_map(static fn (array $row) => [$row['table_name'], $row['name']], $res)); |
434 |
| - |
435 |
| - $refl = new ReflectionMethod($schemaManager, 'selectIndexColumns'); |
436 |
| - $refl->setAccessible(true); |
437 |
| - $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
438 |
| - ->fetchAllAssociative(); |
439 |
| - |
440 |
| - self::assertSame([ |
441 |
| - ['list_table_no_schema_emulation.test', 'i'], |
442 |
| - ], array_map(static fn (array $row) => [$row['table_name'], $row['name']], $res)); |
443 |
| - |
444 |
| - $refl = new ReflectionMethod($schemaManager, 'selectForeignKeyColumns'); |
445 |
| - $refl->setAccessible(true); |
446 |
| - $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
447 |
| - ->fetchAllAssociative(); |
448 |
| - |
449 |
| - self::assertSame([ |
450 |
| - ['list_table_no_schema_emulation.test', 'parent_id', 'id'], |
451 |
| - ], array_map(static fn (array $row) => [$row['table_name'], $row['from'], $row['to']], $res)); |
| 424 | + $customSqliteSchemaManager = new class ($this->connection, $databasePlatform) extends SqliteSchemaManager { |
| 425 | + /** @return list<array<string, mixed>> */ |
| 426 | + public function selectTableColumnsWithSchema(): array |
| 427 | + { |
| 428 | + return $this->selectTableColumns('main', 'list_table_no_schema_emulation.test') |
| 429 | + ->fetchAllAssociative(); |
| 430 | + } |
| 431 | + |
| 432 | + /** @return list<array<string, mixed>> */ |
| 433 | + public function selectIndexColumnsWithSchema(): array |
| 434 | + { |
| 435 | + return $this->selectIndexColumns('main', 'list_table_no_schema_emulation.test') |
| 436 | + ->fetchAllAssociative(); |
| 437 | + } |
| 438 | + |
| 439 | + /** @return list<array<string, mixed>> */ |
| 440 | + public function selectForeignKeyColumnsWithSchema(): array |
| 441 | + { |
| 442 | + return $this->selectForeignKeyColumns('main', 'list_table_no_schema_emulation.test') |
| 443 | + ->fetchAllAssociative(); |
| 444 | + } |
| 445 | + }; |
| 446 | + |
| 447 | + self::assertSame( |
| 448 | + [ |
| 449 | + ['list_table_no_schema_emulation.test', 'id'], |
| 450 | + ['list_table_no_schema_emulation.test', 'parent_id'], |
| 451 | + ], |
| 452 | + array_map( |
| 453 | + static fn (array $row) => [$row['table_name'], $row['name']], |
| 454 | + $customSqliteSchemaManager->selectTableColumnsWithSchema(), |
| 455 | + ), |
| 456 | + ); |
| 457 | + |
| 458 | + self::assertSame( |
| 459 | + [ |
| 460 | + ['list_table_no_schema_emulation.test', 'i'], |
| 461 | + ], |
| 462 | + array_map( |
| 463 | + static fn (array $row) => [$row['table_name'], $row['name']], |
| 464 | + $customSqliteSchemaManager->selectIndexColumnsWithSchema(), |
| 465 | + ), |
| 466 | + ); |
| 467 | + |
| 468 | + self::assertSame( |
| 469 | + [ |
| 470 | + ['list_table_no_schema_emulation.test', 'parent_id', 'id'], |
| 471 | + ], |
| 472 | + array_map( |
| 473 | + static fn (array $row) => [$row['table_name'], $row['from'], $row['to']], |
| 474 | + $customSqliteSchemaManager->selectForeignKeyColumnsWithSchema(), |
| 475 | + ), |
| 476 | + ); |
452 | 477 | }
|
453 | 478 | }
|
0 commit comments