|
4 | 4 |
|
5 | 5 | use Doctrine\DBAL\Connection;
|
6 | 6 | use Doctrine\DBAL\Platforms\SqlitePlatform;
|
| 7 | +use Doctrine\DBAL\Result; |
7 | 8 | use Doctrine\DBAL\Schema\SqliteSchemaManager;
|
8 | 9 | use PHPUnit\Framework\TestCase;
|
9 | 10 | use ReflectionMethod;
|
@@ -340,4 +341,33 @@ public static function getDataColumnComment(): iterable
|
340 | 341 | ],
|
341 | 342 | ];
|
342 | 343 | }
|
| 344 | + |
| 345 | + /** |
| 346 | + * TODO move to functional test once SqliteSchemaManager::selectForeignKeyColumns can honor database/schema name |
| 347 | + * https://github.com/doctrine/dbal/blob/3.8.3/src/Schema/SqliteSchemaManager.php#L740 |
| 348 | + */ |
| 349 | + public function testListTableForeignKeysDefaultDatabasePassing(): void |
| 350 | + { |
| 351 | + $conn = $this->createMock(Connection::class); |
| 352 | + |
| 353 | + $manager = new class ($conn, new SqlitePlatform()) extends SqliteSchemaManager { |
| 354 | + public static string $passedDatabaseName; |
| 355 | + |
| 356 | + protected function selectForeignKeyColumns(string $databaseName, ?string $tableName = null): Result |
| 357 | + { |
| 358 | + self::$passedDatabaseName = $databaseName; |
| 359 | + |
| 360 | + return parent::selectForeignKeyColumns($databaseName, $tableName); |
| 361 | + } |
| 362 | + }; |
| 363 | + |
| 364 | + $manager->listTableForeignKeys('t'); |
| 365 | + self::assertSame('main', $manager::$passedDatabaseName); |
| 366 | + |
| 367 | + $manager->listTableForeignKeys('t', 'd'); |
| 368 | + self::assertSame('d', $manager::$passedDatabaseName); |
| 369 | + |
| 370 | + $manager->listTableForeignKeys('t'); |
| 371 | + self::assertSame('main', $manager::$passedDatabaseName); |
| 372 | + } |
343 | 373 | }
|
0 commit comments