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 12
12
13
13
namespace Fresh \DoctrineEnumBundle \DependencyInjection \Compiler ;
14
14
15
+ use Doctrine \DBAL \Types \EnumType ;
16
+ use Doctrine \DBAL \Types \Types ;
15
17
use Doctrine \Persistence \ManagerRegistry ;
16
18
use Fresh \DoctrineEnumBundle \Exception \InvalidArgumentException ;
17
19
use Symfony \Component \DependencyInjection \Compiler \CompilerPassInterface ;
@@ -39,8 +41,9 @@ public function process(ContainerBuilder $container): void
39
41
foreach ($ doctrine ->getConnectionNames () as $ connectionName ) {
40
42
$ definition = $ container ->getDefinition ($ connectionName );
41
43
$ 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 ;
44
47
$ definition ->setArgument (3 , $ mappingTypes );
45
48
}
46
49
}
Original file line number Diff line number Diff line change 12
12
13
13
namespace Fresh \DoctrineEnumBundle \Tests \DependencyInjection \Compiler ;
14
14
15
+ use Doctrine \DBAL \Types \Types ;
15
16
use Doctrine \Persistence \ManagerRegistry ;
16
17
use Fresh \DoctrineEnumBundle \DependencyInjection \Compiler \RegisterEnumTypePass ;
17
18
use Fresh \DoctrineEnumBundle \Exception \InvalidArgumentException ;
@@ -79,7 +80,7 @@ public function processSuccessful(): void
79
80
$ default
80
81
->expects (self ::once ())
81
82
->method ('setArgument ' )
82
- ->with (3 , ['test ' => '_test ' , 'enum ' => ' string ' ])
83
+ ->with (3 , ['test ' => '_test ' , 'enum ' => Types:: ENUM ])
83
84
;
84
85
85
86
$ custom1 = $ this ->createMock (Definition::class);
@@ -92,15 +93,15 @@ public function processSuccessful(): void
92
93
$ custom1
93
94
->expects (self ::once ())
94
95
->method ('setArgument ' )
95
- ->with (3 , ['test ' => '_test ' , 'enum ' => ' string ' ])
96
+ ->with (3 , ['test ' => '_test ' , 'enum ' => Types:: ENUM ])
96
97
;
97
98
98
99
$ custom2 = $ this ->createMock (Definition::class);
99
100
$ custom2
100
101
->expects (self ::once ())
101
102
->method ('getArgument ' )
102
103
->with (3 )
103
- ->willReturn (['test ' => '_test ' , 'enum ' => ' string ' ])
104
+ ->willReturn (['test ' => '_test ' , 'enum ' => Types:: ENUM ])
104
105
;
105
106
$ custom2
106
107
->expects (self ::never ())
You can’t perform that action at this time.
0 commit comments