From e52242496776a31c1601b3b4443ba2e68a1e3c12 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 25 Feb 2011 11:08:48 +0100 Subject: [PATCH] Changed default logging param to kernel.debug and fixed container unit test --- .../DependencyInjection/Configuration.php | 9 ++++-- .../DependencyInjection/DoctrineExtension.php | 2 +- .../AbstractDoctrineExtensionTest.php | 1 + .../Bundle/DoctrineBundle/Tests/TestCase.php | 32 ++++++++++--------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php index b6e60fd22984..41083679a237 100644 --- a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php @@ -24,13 +24,18 @@ */ class Configuration { + private $kernelDebug; + /** * Generates the configuration tree. * + * @param Boolean $kernelDebug * @return \Symfony\Component\Config\Definition\NodeInterface */ - public function getConfigTree() + public function getConfigTree($kernelDebug) { + $this->kernelDebug = (bool) $kernelDebug; + $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('doctrine', 'array'); @@ -109,7 +114,7 @@ private function getDbalConnectionsNode() ->scalarNode('wrapper_class')->end() ->scalarNode('platform_service')->end() ->scalarNode('charset')->defaultValue('UTF-8')->end() - ->booleanNode('logging')->defaultFalse()->end() + ->booleanNode('logging')->defaultValue($this->kernelDebug)->end() ->end() ; diff --git a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php index 902278f5002e..6bd84f04dc2e 100755 --- a/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php +++ b/src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php @@ -34,7 +34,7 @@ public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $processor = new Processor(); - $config = $processor->process($configuration->getConfigTree(), $configs); + $config = $processor->process($configuration->getConfigTree($container->getParameter('kernel.debug')), $configs); if (!empty($config['dbal'])) { $this->dbalLoad($config['dbal'], $container); diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index 3575a852d524..ee125296f8e7 100755 --- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -658,6 +658,7 @@ protected function getContainer($bundles = 'YamlBundle', $vendor = null) } return new ContainerBuilder(new ParameterBag(array( + 'kernel.debug' => false, 'kernel.bundles' => $map, 'kernel.cache_dir' => sys_get_temp_dir(), 'kernel.root_dir' => __DIR__ . "/../../../../../" // src dir diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/TestCase.php b/src/Symfony/Bundle/DoctrineBundle/Tests/TestCase.php index 8f183c9861df..040630c04b77 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Tests/TestCase.php +++ b/src/Symfony/Bundle/DoctrineBundle/Tests/TestCase.php @@ -50,31 +50,33 @@ protected function createTestEntityManager($paths = array()) public function createYamlBundleTestContainer() { $container = new ContainerBuilder(new ParameterBag(array( + 'kernel.debug' => false, 'kernel.bundles' => array('YamlBundle' => 'Fixtures\Bundles\YamlBundle\YamlBundle'), 'kernel.cache_dir' => sys_get_temp_dir(), 'kernel.root_dir' => __DIR__ . "/../../../../" // src dir ))); $loader = new DoctrineExtension(); $container->registerExtension($loader); - $loader->load(array(array('dbal' => array( - 'connections' => array( - 'default' => array( - 'driver' => 'pdo_mysql', - 'charset' => 'UTF-8', - 'platform-service' => 'my.platform', - ) - ), - 'types' => array( - 'test' => 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType', - ), - ))), $container); - $loader->load(array( - array('orm' => array( + $loader->load(array(array( + 'dbal' => array( + 'connections' => array( + 'default' => array( + 'driver' => 'pdo_mysql', + 'charset' => 'UTF-8', + 'platform-service' => 'my.platform', + ) + ), + 'default_connection' => 'default', + 'types' => array( + 'test' => 'Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType', + ), + ), 'orm' => array( 'mappings' => array('YamlBundle' => array( 'type' => 'yml', 'dir' => __DIR__ . "/DependencyInjection/Fixtures/Bundles/YamlBundle/Resources/config/doctrine/metadata/orm", 'prefix' => 'Fixtures\Bundles\YamlBundle', - ))))), $container); + ))) + )), $container); $container->setDefinition('my.platform', new \Symfony\Component\DependencyInjection\Definition('Doctrine\DBAL\Platforms\MySqlPlatform'));