File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
DependencyInjection/Compiler
Tests/DependencyInjection/Compiler Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 1212
1313namespace Fresh \DoctrineEnumBundle \DependencyInjection \Compiler ;
1414
15+ use Doctrine \DBAL \Types \EnumType ;
16+ use Doctrine \DBAL \Types \Types ;
1517use Doctrine \Persistence \ManagerRegistry ;
1618use Fresh \DoctrineEnumBundle \Exception \InvalidArgumentException ;
1719use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
@@ -39,8 +41,9 @@ public function process(ContainerBuilder $container): void
3941 foreach ($ doctrine ->getConnectionNames () as $ connectionName ) {
4042 $ definition = $ container ->getDefinition ($ connectionName );
4143 $ mappingTypes = (array ) $ definition ->getArgument (3 );
42- if (!isset ($ mappingTypes ['enum ' ]) || 'string ' !== $ mappingTypes ['enum ' ]) {
43- $ mappingTypes ['enum ' ] = 'string ' ;
44+ $ expectedType = class_exists (EnumType::class) ? Types::ENUM : 'string ' ;
45+ if (!isset ($ mappingTypes ['enum ' ]) || $ expectedType !== $ mappingTypes ['enum ' ]) {
46+ $ mappingTypes ['enum ' ] = $ expectedType ;
4447 $ definition ->setArgument (3 , $ mappingTypes );
4548 }
4649 }
Original file line number Diff line number Diff line change 1212
1313namespace Fresh \DoctrineEnumBundle \Tests \DependencyInjection \Compiler ;
1414
15+ use Doctrine \DBAL \Types \Types ;
1516use Doctrine \Persistence \ManagerRegistry ;
1617use Fresh \DoctrineEnumBundle \DependencyInjection \Compiler \RegisterEnumTypePass ;
1718use Fresh \DoctrineEnumBundle \Exception \InvalidArgumentException ;
@@ -79,7 +80,7 @@ public function processSuccessful(): void
7980 $ default
8081 ->expects (self ::once ())
8182 ->method ('setArgument ' )
82- ->with (3 , ['test ' => '_test ' , 'enum ' => ' string ' ])
83+ ->with (3 , ['test ' => '_test ' , 'enum ' => Types:: ENUM ])
8384 ;
8485
8586 $ custom1 = $ this ->createMock (Definition::class);
@@ -92,15 +93,15 @@ public function processSuccessful(): void
9293 $ custom1
9394 ->expects (self ::once ())
9495 ->method ('setArgument ' )
95- ->with (3 , ['test ' => '_test ' , 'enum ' => ' string ' ])
96+ ->with (3 , ['test ' => '_test ' , 'enum ' => Types:: ENUM ])
9697 ;
9798
9899 $ custom2 = $ this ->createMock (Definition::class);
99100 $ custom2
100101 ->expects (self ::once ())
101102 ->method ('getArgument ' )
102103 ->with (3 )
103- ->willReturn (['test ' => '_test ' , 'enum ' => ' string ' ])
104+ ->willReturn (['test ' => '_test ' , 'enum ' => Types:: ENUM ])
104105 ;
105106 $ custom2
106107 ->expects (self ::never ())
You can’t perform that action at this time.
0 commit comments