@@ -570,6 +570,41 @@ public function testMigrateSchema(): void
570570 self ::assertTrue ($ schema ->hasTable ('table_to_create ' ));
571571 }
572572
573+ #[DataProvider('schemaFilterProvider ' )]
574+ public function testIntrospectSchemaWithFilter (string $ prefix , int $ expectedCount ): void
575+ {
576+ if (! $ this ->connection ->getDatabasePlatform ()->supportsSchemas ()) {
577+ self ::markTestSkipped ('Platform does not support schemas. ' );
578+ }
579+
580+ // Create test schemas
581+ $ this ->createTestSchema ('filter_schema_1 ' );
582+ $ this ->createTestSchema ('filter_schema_2 ' );
583+
584+ $ this ->markConnectionNotReusable ();
585+
586+ $ this ->connection ->getConfiguration ()->setSchemaAssetsFilter (
587+ static function (string |AbstractAsset $ assetName ) use ($ prefix ): bool {
588+ if ($ assetName instanceof AbstractAsset) {
589+ $ assetName = $ assetName ->getName ();
590+ }
591+ return str_starts_with (strtolower ($ assetName ), $ prefix );
592+ },
593+ );
594+
595+ $ schema = $ this ->schemaManager ->introspectSchema ();
596+
597+ // Test that only filtered schemas are included in the introspection
598+ self ::assertCount ($ expectedCount , $ schema ->getNamespaces ());
599+ }
600+
601+ /** @return iterable<string, array{string, int}> */
602+ public static function schemaFilterProvider (): iterable
603+ {
604+ yield 'One schema ' => ['filter_schema_1 ' , 1 ];
605+ yield 'Two schemas ' => ['filter_schema_ ' , 2 ];
606+ }
607+
573608 /** @throws Exception */
574609 public function testAlterTableScenario (): void
575610 {
@@ -1020,6 +1055,12 @@ protected function createTestTable(string $name, array $data = []): Table
10201055 return $ table ;
10211056 }
10221057
1058+ /** @param non-empty-string $name */
1059+ protected function createTestSchema (string $ name ): void
1060+ {
1061+ $ this ->dropAndCreateSchema (UnqualifiedName::unquoted ($ name ));
1062+ }
1063+
10231064 /**
10241065 * @param non-empty-string $unquotedName
10251066 * @param mixed[] $options
0 commit comments