diff --git a/DependencyInjection/Compiler/RegisterEnumTypePass.php b/DependencyInjection/Compiler/RegisterEnumTypePass.php index 1e78ea3..c398484 100644 --- a/DependencyInjection/Compiler/RegisterEnumTypePass.php +++ b/DependencyInjection/Compiler/RegisterEnumTypePass.php @@ -41,11 +41,12 @@ public function process(ContainerBuilder $container): void /* @see \Doctrine\Bundle\DoctrineBundle\ConnectionFactory::createConnection */ foreach ($doctrine->getConnectionNames() as $connectionName) { $definition = $container->getDefinition($connectionName); - $mappingTypes = (array) $definition->getArgument(3); + $lastArgument = count($definition->getArguments()) - 1; + $mappingTypes = (array) $definition->getArgument($lastArgument); $expectedType = class_exists(EnumType::class) ? Types::ENUM : 'string'; if (!isset($mappingTypes['enum']) || $expectedType !== $mappingTypes['enum']) { $mappingTypes['enum'] = $expectedType; - $definition->setArgument(3, $mappingTypes); + $definition->setArgument($lastArgument, $mappingTypes); } } } diff --git a/Tests/DependencyInjection/Compiler/RegisterEnumTypePassTest.php b/Tests/DependencyInjection/Compiler/RegisterEnumTypePassTest.php index abc746a..c158fa0 100755 --- a/Tests/DependencyInjection/Compiler/RegisterEnumTypePassTest.php +++ b/Tests/DependencyInjection/Compiler/RegisterEnumTypePassTest.php @@ -23,6 +23,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Reference; /** * RegisterEnumTypePassTest. @@ -72,6 +73,16 @@ public function processSuccessful(): void ; $default = $this->createMock(Definition::class); + $default + ->expects(self::once()) + ->method('getArguments') + ->willReturn([ + ['url' => 'mysql:\\\\'], + new Reference('doctrine.dbal.default_connection.configuration'), + null, + [], + ]) + ; $default ->expects(self::once()) ->method('getArgument') @@ -85,6 +96,16 @@ public function processSuccessful(): void ; $custom1 = $this->createMock(Definition::class); + $custom1 + ->expects(self::once()) + ->method('getArguments') + ->willReturn([ + ['url' => 'mysql:\\\\'], + new Reference('doctrine.dbal.custom1_connection.configuration'), + null, + [], + ]) + ; $custom1 ->expects(self::once()) ->method('getArgument') @@ -98,6 +119,16 @@ public function processSuccessful(): void ; $custom2 = $this->createMock(Definition::class); + $custom2 + ->expects(self::once()) + ->method('getArguments') + ->willReturn([ + ['url' => 'mysql:\\\\'], + new Reference('doctrine.dbal.custom2_connection.configuration'), + null, + [], + ]) + ; $custom2 ->expects(self::once()) ->method('getArgument')