Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception when configuration is used without doctrine/orm nor doctrine/common #881

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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));
}
}