8000 [DI][5.0] Fix suspicious test · symfony/symfony@98c25dd · GitHub
[go: up one dir, main page]

Skip to content

Commit 98c25dd

Browse files
committed
[DI][5.0] Fix suspicious test
1 parent e33ee9d commit 98c25dd

File tree

4 files changed

+2
-70
lines changed

4 files changed

+2
-70
lines changed

src/Symfony/Component/Config/Definition/Builder/TreeBuilder.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Config\Definition\Builder;
1313

14-
use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException;
1514
use Symfony\Component\Config\Definition\NodeInterface;
1615

1716
/**
@@ -35,10 +34,6 @@ public function __construct(string $name, string $type = 'array', NodeBuilder $b
3534
*/
3635
public function getRootNode(): NodeDefinition
3736
{
38-
if (null === $this->root) {
39-
throw new \RuntimeException(sprintf('Calling %s() before creating the root node is not supported, migrate to the new constructor signature instead.', __METHOD__));
40-
}
41-
4237
return $this->root;
4338
}
4439

@@ -51,7 +46,6 @@ public function getRootNode(): NodeDefinition
5146
*/
5247
public function buildTree()
5348
{
54-
$this->assertTreeHasRootNode();
5549
if (null !== $this->tree) {
5650
return $this->tree;
5751
}
@@ -61,21 +55,9 @@ public function buildTree()
6155

6256
public function setPathSeparator(string $separator)
6357
{
64-
$this->assertTreeHasRootNode();
65-
6658
// unset last built as changing path separator changes all nodes
6759
$this->tree = null;
6860

6961
$this->root->setPathSeparator($separator);
7062
}
71-
72-
/**
73-
* @throws \RuntimeException if root node is not defined
74-
*/
75-
private function assertTreeHasRootNode()
76-
{
77-
if (null === $this->root) {
78-
throw new TreeWithoutRootNodeException('The configuration tree has no root node.');
79-
}
80-
}
8163
}

src/Symfony/Component/Config/Definition/Exception/TreeWithoutRootNodeException.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Symfony/Component/DependencyInjection/Compiler/ValidateEnvPlaceholdersPass.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\Config\Definition\BaseNode;
15-
use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException;
1615
use Symfony\Component\Config\Definition\Processor;
1716
use Symfony\Component\DependencyInjection\ContainerBuilder;
1817
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
@@ -80,10 +79,7 @@ public function process(ContainerBuilder $container)
8079
continue;
8180
}
8281

83-
try {
84-
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
85-
} catch (TreeWithoutRootNodeException $e) {
86-
}
82+
$this->extensionConfig[$name] = $processor->processConfiguration($configuration, $config);
8783
}
8884
} finally {
8985
BaseNode::resetPlaceholders();

src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1616
use Symfony\Component\Config\Definition\ConfigurationInterface;
17-
use Symfony\Component\Config\Definition\Exception\TreeWithoutRootNodeException;
1817
use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;
1918
use Symfony\Component\DependencyInjection\Compiler\RegisterEnvVarProcessorsPass;
2019
use Symfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass;
@@ -274,20 +273,6 @@ public function testEnvWithVariableNode(): void
274273
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
275274
}
276275

277-
/**
278-
* @group legacy
279-
*/
280-
public function testConfigurationWithoutRootNode(): void
281-
{
282-
$container = new ContainerBuilder();
283-
$container->registerExtension(new EnvExtension(new EnvConfigurationWithoutRootNode()));
284-
$container->loadFromExtension('env_extension');
285-
286-
$this->doProcess($container);
287-
288-
$this->addToAssertionCount(1);
289-
}
290-
291276
public function testEmptyConfigFromMoreThanOneSource()
292277
{
293278
$container = new ContainerBuilder();
@@ -386,14 +371,6 @@ public function getConfigTreeBuilder()
386371
}
387372
}
388373

389-
class EnvConfigurationWithoutRootNode implements ConfigurationInterface
390-
{
391-
public function getConfigTreeBuilder()
392-
{
393-
return new TreeBuilder('env_extension');
394-
}
395-
}
396-
397374
class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInterface
398375
{
399376
public function getConfigTreeBuilder()
@@ -438,11 +415,7 @@ public function load(array $configs, ContainerBuilder $container)
438415
return;
439416
}
440417

441-
try {
442-
$this->config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs);
443-
} catch (TreeWithoutRootNodeException $e) {
444-
$this->config = null;
445-
}
418+
$this->config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs);
446419
}
447420

448421
public function getConfig()

0 commit comments

Comments
 (0)
0