Skip to content

Commit

Permalink
[DI][5.0] Fix suspicious test
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL committed Jun 7, 2019
1 parent e33ee9d commit 98c25dd
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 70 deletions.
18 changes: 0 additions & 18 deletions src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\Config\Definition\Builder;

use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException;
use Symfony\Component\Config\Definition\NodeInterface;

/**
Expand All @@ -35,10 +34,6 @@ public function __construct(string $name, string $type = 'array', NodeBuilder $b
*/
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;
}

Expand All @@ -51,7 +46,6 @@ public function getRootNode(): NodeDefinition
*/
public function buildTree()
{
$this->assertTreeHasRootNode();
if (null !== $this->tree) {
return $this->tree;
}
Expand All @@ -61,21 +55,9 @@ public function buildTree()

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.');
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,10 +79,7 @@ public function process(ContainerBuilder $container)
continue;
}

try {
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
} catch (TreeWithoutRootNodeException $e) {
}
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
}
} finally {
BaseNode::resetPlaceholders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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;
Expand Down Expand Up @@ -274,20 +273,6 @@ public function testEnvWithVariableNode(): void
$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();
Expand Down Expand Up @@ -386,14 +371,6 @@ public function getConfigTreeBuilder()
}
}

class EnvConfigurationWithoutRootNode implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
return new TreeBuilder('env_extension');
}
}

class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInterface
{
public function getConfigTreeBuilder()
Expand Down Expand Up @@ -438,11 +415,7 @@ public function load(array $configs, ContainerBuilder $container)
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()
Expand Down

0 comments on commit 98c25dd

Please sign in to comment.