@@ -570,6 +570,42 @@ 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+
592+ return str_starts_with (strtolower ($ assetName ), $ prefix );
593+ },
594+ );
595+
596+ $ schema = $ this ->schemaManager ->introspectSchema ();
597+
598+ // Test that only filtered schemas are included in the introspection
599+ self ::assertCount ($ expectedCount , $ schema ->getNamespaces ());
600+ }
601+
602+ /** @return iterable<string, array{string, int}> */
603+ public static function schemaFilterProvider (): iterable
604+ {
605+ yield 'One schema ' => ['filter_schema_1 ' , 1 ];
606+ yield 'Two schemas ' => ['filter_schema_ ' , 2 ];
607+ }
608+
573609 /** @throws Exception */
574610 public function testAlterTableScenario (): void
575611 {
@@ -1020,6 +1056,12 @@ protected function createTestTable(string $name, array $data = []): Table
10201056 return $ table ;
10211057 }
10221058
1059+ /** @param non-empty-string $name */
1060+ protected function createTestSchema (string $ name ): void
1061+ {
1062+ $ this ->dropAndCreateSchema (UnqualifiedName::unquoted ($ name ));
1063+ }
1064+
10231065 /**
10241066 * @param non-empty-string $unquotedName
10251067 * @param mixed[] $options
0 commit comments