From 872d308e9c7f8cd60e3857ac277cbc4a898ec959 Mon Sep 17 00:00:00 2001 From: Noel GUILBERT Date: Mon, 18 Jul 2011 19:51:17 +1200 Subject: [PATCH] [DoctrineBundle] Allowed to configure dql functions without using the multiple entity mangers syntax --- .../DependencyInjection/Configuration.php | 2 +- .../AbstractDoctrineExtensionTest.php | 13 +++++++++++++ .../config/yml/orm_single_em_dql_functions.yml | 12 ++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_single_em_dql_functions.yml diff --git a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php index 357a717ae5cb..231eb90ebedf 100644 --- a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php @@ -163,7 +163,7 @@ private function addOrmSection(ArrayNodeDefinition $node) 'query_cache_driver', 'query-cache-driver', 'auto_mapping', 'auto-mapping', 'mappings', 'mapping', - 'connection' + 'connection', 'dql' ) as $key) { if (array_key_exists($key, $v)) { $entityManager[$key] = $v[$key]; diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index 4d79903c73aa..7884dd52f91a 100755 --- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -661,6 +661,19 @@ public function testSetCustomFunctions() $this->assertDICDefinitionMethodCallOnce($definition, 'addCustomDatetimeFunction', array('test_datetime', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestDatetimeFunction')); } + public function testSingleEMSetCustomFunctions() + { + $container = $this->getContainer(array('YamlBundle')); + + $loader = new DoctrineExtension(); + $container->registerExtension($loader); + $this->loadFromFile($container, 'orm_single_em_dql_functions'); + $this->compileContainer($container); + + $definition = $container->getDefinition('doctrine.orm.default_configuration'); + $this->assertDICDefinitionMethodCallOnce($definition, 'addCustomStringFunction', array('test_string', 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction')); + } + public function testAddCustomHydrationMode() { $container = $this->getContainer(array('YamlBundle')); diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_single_em_dql_functions.yml b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_single_em_dql_functions.yml new file mode 100644 index 000000000000..fab2d69731c0 --- /dev/null +++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/Fixtures/config/yml/orm_single_em_dql_functions.yml @@ -0,0 +1,12 @@ +doctrine: + dbal: + default_connection: default + connections: + default: + dbname: db + + orm: + dql: + string_functions: + test_string: Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction +