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 ;
@@ -950,7 +951,9 @@ public static function cacheConfigurationProvider(): array
950951 ];
951952 }
952953
953- public function testAsDatabaseTypeAttribute (): void
954+ /** @param class-string $typeClassname */
955+ #[DataProvider('provideDatabaseTypeAttribute ' )]
956+ public function testAsDatabaseTypeAttribute (string $ typeClassname , string $ expectedName ): void
954957 {
955958 $ container = $ this ->getContainer ();
956959 $ extension = new DoctrineExtension ();
@@ -968,17 +971,26 @@ public function testAsDatabaseTypeAttribute(): void
968971 : $ container ->getAutoconfiguredAttributes ();
969972 $ this ->assertInstanceOf (Closure::class, $ attributes [AsDatabaseType::class]);
970973
971- $ reflector = new ReflectionClass (DbalType::class );
974+ $ reflector = new ReflectionClass ($ typeClassname );
972975 $ definition = new ChildDefinition ('' );
973976 $ attribute = $ reflector ->getAttributes (AsDatabaseType::class)[0 ]->newInstance ();
974977
975- $ attributes [AsDatabaseType::class]($ definition , $ attribute );
978+ $ attributes [AsDatabaseType::class]($ definition , $ attribute, $ reflector );
976979
977- $ expected = ['name ' => ' dbal_type ' ];
980+ $ expected = ['name ' => $ expectedName ];
978981 $ this ->assertSame ([$ expected ], $ definition ->getTag ('doctrine.dbal.type ' ));
979982 $ this ->assertSame ([['source ' => 'by tag "doctrine.dbal.type" ' ]], $ definition ->getTag ('container.excluded ' ));
980983 }
981984
985+ /** @return array<array{0: class-string, 1: string}> */
986+ public static function provideDatabaseTypeAttribute (): array
987+ {
988+ return [
989+ 'with name ' => [DbalType::class, 'dbal_type ' ],
990+ 'without name ' => [DbalTypeNoName::class, DbalTypeNoName::class],
991+ ];
992+ }
993+
982994 /** @return array<array{0: class-string}> */
983995 public static function provideAttributeExcludedFromContainer (): array
984996 {
0 commit comments