minor #31945 [DI][5.0] Fix suspicious test (ro0NL)
This PR was merged into the 5.0-dev branch.
Discussion
----------
[DI][5.0] Fix suspicious test
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
Cleanup of #31944 for 5.0
Commits
-------
98c25dd340
[DI][5.0] Fix suspicious test
This commit is contained in:
commit
d81ab9b262
@ -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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
}
|
@ -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) {
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
BaseNode::resetPlaceholders();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
public function getConfig()
|
||||
|
Reference in New Issue
Block a user