[DI][5.0] Fix suspicious test

This commit is contained in:
Roland Franssen 2019-06-07 22:39:31 +02:00
parent e33ee9d530
commit 98c25dd340
4 changed files with 2 additions and 70 deletions

View File

@ -11,7 +11,6 @@
namespace Symfony\Component\Config\Definition\Builder;
use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException;
use Symfony\Component\Config\Definition\NodeInterface;
/**
@ -35,10 +34,6 @@ class TreeBuilder implements NodeParentInterface
*/
public function getRootNode(): NodeDefinition
{
if (null === $this->root) {
throw new \RuntimeException(sprintf('Calling %s() before creating the root node is not supported, migrate to the new constructor signature instead.', __METHOD__));
}
return $this->root;
}
@ -51,7 +46,6 @@ class TreeBuilder implements NodeParentInterface
*/
public function buildTree()
{
$this->assertTreeHasRootNode();
if (null !== $this->tree) {
return $this->tree;
}
@ -61,21 +55,9 @@ class TreeBuilder implements NodeParentInterface
public function setPathSeparator(string $separator)
{
$this->assertTreeHasRootNode();
// unset last built as changing path separator changes all nodes
$this->tree = null;
$this->root->setPathSeparator($separator);
}
/**
* @throws \RuntimeException if root node is not defined
*/
private function assertTreeHasRootNode()
{
if (null === $this->root) {
throw new TreeWithoutRootNodeException('The configuration tree has no root node.');
}
}
}

View File

@ -1,19 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Config\Definition\Exception;
/**
* @author Roland Franssen <franssen.roland@gmail.com>
*/
class TreeWithoutRootNodeException extends \RuntimeException
{
}

View File

@ -12,7 +12,6 @@
namespace Symfony\Component\DependencyInjection\Compiler;
use Symfony\Component\Config\Definition\BaseNode;
use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
@ -80,10 +79,7 @@ class ValidateEnvPlaceholdersPass implements CompilerPassInterface
continue;
}
try {
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
} catch (TreeWithoutRootNodeException $e) {
}
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
}
} finally {
BaseNode::resetPlaceholders();

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException;
use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;
use Symfony\Component\DependencyInjection\Compiler\RegisterEnvVarProcessorsPass;
use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass;
@ -274,20 +273,6 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
}
/**
* @group legacy
*/
public function testConfigurationWithoutRootNode(): void
{
$container = new ContainerBuilder();
$container->registerExtension(new EnvExtension(new EnvConfigurationWithoutRootNode()));
$container->loadFromExtension('env_extension');
$this->doProcess($container);
$this->addToAssertionCount(1);
}
public function testEmptyConfigFromMoreThanOneSource()
{
$container = new ContainerBuilder();
@ -386,14 +371,6 @@ class EnvConfiguration implements ConfigurationInterface
}
}
class EnvConfigurationWithoutRootNode implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
return new TreeBuilder('env_extension');
}
}
class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInterface
{
public function getConfigTreeBuilder()
@ -438,11 +415,7 @@ class EnvExtension extends Extension
return;
}
try {
$this->config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs);
} catch (TreeWithoutRootNodeException $e) {
$this->config = null;
}
$this->config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs);
}
public function getConfig()