Skip to content

Commit

Permalink
Merge pull request doctrine#881 from webnet-fr/configuration-without-…
Browse files Browse the repository at this point in the history
…common-package

Fix exception when configuration is used without doctrine/orm nor doctrine/common
  • Loading branch information
alcaeus committed Jan 7, 2019
2 parents 4725c6d + 00c8ebf commit 98551d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions DependencyInjection/Configuration.php
Expand Up @@ -302,8 +302,6 @@ private function configureDbalDriverNode(ArrayNodeDefinition $node)
*/
private function addOrmSection(ArrayNodeDefinition $node)
{
$generationModes = $this->getAutoGenerateModes();

$node
->children()
->arrayNode('orm')
Expand Down Expand Up @@ -341,7 +339,9 @@ private function addOrmSection(ArrayNodeDefinition $node)
->scalarNode('auto_generate_proxy_classes')->defaultValue(false)
->info('Auto generate mode possible values are: "NEVER", "ALWAYS", "FILE_NOT_EXISTS", "EVAL"')
->validate()
->ifTrue(static function ($v) use ($generationModes) {
->ifTrue(function ($v) {
$generationModes = $this->getAutoGenerateModes();

if (is_int($v) && in_array($v, $generationModes['values']/*array(0, 1, 2, 3)*/)) {
return false;
}
Expand Down
30 changes: 30 additions & 0 deletions Tests/DependencyInjection/ConfigurationTest.php
@@ -0,0 +1,30 @@
<?php

namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection;

use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Configuration;
use PHPUnit\Framework\TestCase;

class ConfigurationTest extends TestCase
{
/**
* Whether or not this test should preserve the global state when
* running in a separate PHP process.
*
* PHPUnit hack to avoid currently loaded classes to leak to
* testGetConfigTreeBuilderDoNotUseDoctrineCommon that is run in separate process.
*
* @var bool
*/
protected $preserveGlobalState = false;

/**
* @runInSeparateProcess
*/
public function testGetConfigTreeBuilderDoNotUseDoctrineCommon()
{
$configuration = new Configuration(true);
$configuration->getConfigTreeBuilder();
$this->assertFalse(class_exists('Doctrine\Common\Proxy\AbstractProxyFactory', false));
}
}

0 comments on commit 98551d7

Please sign in to comment.