|
10 | 10 | use Doctrine\DBAL\Types\BlobType;
|
11 | 11 | use Doctrine\DBAL\Types\Type;
|
12 | 12 | use Doctrine\DBAL\Types\Types;
|
| 13 | +use ReflectionMethod; |
13 | 14 |
|
| 15 | +use function array_map; |
14 | 16 | use function array_shift;
|
| 17 | +use function assert; |
15 | 18 | use function dirname;
|
16 | 19 |
|
17 | 20 | class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
|
@@ -371,4 +374,57 @@ public function testShorthandInForeignKeyReferenceWithMultipleColumns(): void
|
371 | 374 | $createTableTrackSql,
|
372 | 375 | );
|
373 | 376 | }
|
| 377 | + |
| 378 | + public function testListTableNoSchemaEmulation(): void |
| 379 | + { |
| 380 | + $this->dropTableIfExists('`list_table_no_schema_emulation.test`'); |
| 381 | + |
| 382 | + $ddl = <<<'DDL' |
| 383 | + CREATE TABLE `list_table_no_schema_emulation.test` ( |
| 384 | + id INTEGER, |
| 385 | + parent_id INTEGER, |
| 386 | + PRIMARY KEY (id), |
| 387 | + FOREIGN KEY (parent_id) REFERENCES `list_table_no_schema_emulation.test` (id) |
| 388 | + ); |
| 389 | + DDL; |
| 390 | + $dd2 = <<<'DDL' |
| 391 | + CREATE INDEX i ON `list_table_no_schema_emulation.test` (parent_id); |
| 392 | + DDL; |
| 393 | + |
| 394 | + $this->connection->executeStatement($ddl); |
| 395 | + $this->connection->executeStatement($dd2); |
| 396 | + |
| 397 | + $databasePlatform = $this->connection->getDatabasePlatform(); |
| 398 | + assert($databasePlatform instanceof SqlitePlatform); |
| 399 | + $databasePlatform->disableSchemaEmulation(); |
| 400 | + |
| 401 | + $schemaManager = $this->schemaManager; |
| 402 | + $refl = new ReflectionMethod($schemaManager, 'selectTableColumns'); |
| 403 | + $refl->setAccessible(true); |
| 404 | + $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
| 405 | + ->fetchAllAssociative(); |
| 406 | + |
| 407 | + self::assertSame([ |
| 408 | + ['list_table_no_schema_emulation.test', 'id'], |
| 409 | + ['list_table_no_schema_emulation.test', 'parent_id'], |
| 410 | + ], array_map(static fn (array $row) => [$row['table_name'], $row['name']], $res)); |
| 411 | + |
| 412 | + $refl = new ReflectionMethod($schemaManager, 'selectIndexColumns'); |
| 413 | + $refl->setAccessible(true); |
| 414 | + $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
| 415 | + ->fetchAllAssociative(); |
| 416 | + |
| 417 | + self::assertSame([ |
| 418 | + ['list_table_no_schema_emulation.test', 'i'], |
| 419 | + ], array_map(static fn (array $row) => [$row['table_name'], $row['name']], $res)); |
| 420 | + |
| 421 | + $refl = new ReflectionMethod($schemaManager, 'selectForeignKeyColumns'); |
| 422 | + $refl->setAccessible(true); |
| 423 | + $res = $refl->invoke($schemaManager, 'main', 'list_table_no_schema_emulation.test') |
| 424 | + ->fetchAllAssociative(); |
| 425 | + |
| 426 | + self::assertSame([ |
| 427 | + ['list_table_no_schema_emulation.test', 'parent_id', 'id'], |
| 428 | + ], array_map(static fn (array $row) => [$row['table_name'], $row['from'], $row['to']], $res)); |
| 429 | + } |
374 | 430 | }
|
0 commit comments