Forráskód Böngészése

Changed default logging param to kernel.debug and fixed container unit test

Christophe Coevoet 14 éve
szülő
commit
e522424967

+ 7 - 2
src/Symfony/Bundle/DoctrineBundle/DependencyInjection/Configuration.php

@@ -24,13 +24,18 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
  */
 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 @@ class Configuration
                 ->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()
         ;
 

+ 1 - 1
src/Symfony/Bundle/DoctrineBundle/DependencyInjection/DoctrineExtension.php

@@ -34,7 +34,7 @@ class DoctrineExtension extends AbstractDoctrineExtension
     {
         $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);

+ 1 - 0
src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php

@@ -658,6 +658,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase
         }
 
         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

+ 17 - 15
src/Symfony/Bundle/DoctrineBundle/Tests/TestCase.php

@@ -50,31 +50,33 @@ class TestCase extends \PHPUnit_Framework_TestCase
     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'));