1212use Doctrine \Bundle \DoctrineBundle \DependencyInjection \DoctrineExtension ;
1313use Doctrine \Bundle \DoctrineBundle \Tests \Builder \BundleConfigurationBuilder ;
1414use Doctrine \Bundle \DoctrineBundle \Tests \DependencyInjection \Fixtures \DbalType ;
15+ use Doctrine \Bundle \DoctrineBundle \Tests \DependencyInjection \Fixtures \DbalTypeNoName ;
1516use Doctrine \Bundle \DoctrineBundle \Tests \DependencyInjection \Fixtures \Php8EntityListener ;
1617use Doctrine \Bundle \DoctrineBundle \Tests \DependencyInjection \Fixtures \Php8EventListener ;
1718use Doctrine \DBAL \Connection ;
@@ -949,7 +950,8 @@ public static function cacheConfigurationProvider(): array
949950 ];
950951 }
951952
952- public function testAsDatabaseTypeAttribute (): void
953+ #[DataProvider('provideDatabaseTypeAttribute ' )]
954+ public function testAsDatabaseTypeAttribute (string $ typeClassname , string $ expectedName ): void
953955 {
954956 $ container = $ this ->getContainer ();
955957 $ extension = new DoctrineExtension ();
@@ -967,17 +969,27 @@ public function testAsDatabaseTypeAttribute(): void
967969 : $ container ->getAutoconfiguredAttributes ();
968970 $ this ->assertInstanceOf (Closure::class, $ attributes [AsDatabaseType::class]);
969971
970- $ reflector = new ReflectionClass (DbalType::class);
972+ /** @var class-string $typeClassname */
973+ $ reflector = new ReflectionClass ($ typeClassname );
971974 $ definition = new ChildDefinition ('' );
972975 $ attribute = $ reflector ->getAttributes (AsDatabaseType::class)[0 ]->newInstance ();
973976
974- $ attributes [AsDatabaseType::class]($ definition , $ attribute );
977+ $ attributes [AsDatabaseType::class]($ definition , $ attribute, $ reflector );
975978
976- $ expected = ['name ' => ' dbal_type ' ];
979+ $ expected = ['name ' => $ expectedName ];
977980 $ this ->assertSame ([$ expected ], $ definition ->getTag ('doctrine.dbal.type ' ));
978981 $ this ->assertSame ([['source ' => 'by tag "doctrine.dbal.type" ' ]], $ definition ->getTag ('container.excluded ' ));
979982 }
980983
984+ /** @return array<array{0: class-string, 1: string}> */
985+ public static function provideDatabaseTypeAttribute (): array
986+ {
987+ return [
988+ 'with name ' => [DbalType::class, 'dbal_type ' ],
989+ 'without name ' => [DbalTypeNoName::class, DbalTypeNoName::class],
990+ ];
991+ }
992+
981993 /** @return array<array{0: class-string}> */
982994 public static function provideAttributeExcludedFromContainer (): array
983995 {
0 commit comments