Fixes the valid placeholder types for variable node
This commit is contained in:
parent
9a999553a5
commit
9fbdcdbeb9
@ -539,7 +539,7 @@ abstract class BaseNode implements NodeInterface
|
|||||||
$knownTypes = array_keys(self::$placeholders[$this->handlingPlaceholder]);
|
$knownTypes = array_keys(self::$placeholders[$this->handlingPlaceholder]);
|
||||||
$validTypes = $this->getValidPlaceholderTypes();
|
$validTypes = $this->getValidPlaceholderTypes();
|
||||||
|
|
||||||
if (array_diff($knownTypes, $validTypes)) {
|
if ($validTypes && array_diff($knownTypes, $validTypes)) {
|
||||||
$e = new InvalidTypeException(sprintf(
|
$e = new InvalidTypeException(sprintf(
|
||||||
'Invalid type for path "%s". Expected %s, but got %s.',
|
'Invalid type for path "%s". Expected %s, but got %s.',
|
||||||
$this->getPath(),
|
$this->getPath(),
|
||||||
|
@ -209,6 +209,19 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
|
|||||||
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
|
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testEnvWithVariableNode(): void
|
||||||
|
{
|
||||||
|
$container = new ContainerBuilder();
|
||||||
|
$container->registerExtension($ext = new EnvExtension());
|
||||||
|
$container->prependExtensionConfig('env_extension', $expected = array(
|
||||||
|
'variable_node' => '%env(SOME)%',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->doProcess($container);
|
||||||
|
|
||||||
|
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
|
||||||
|
}
|
||||||
|
|
||||||
private function doProcess(ContainerBuilder $container): void
|
private function doProcess(ContainerBuilder $container): void
|
||||||
{
|
{
|
||||||
(new MergeExtensionConfigurationPass())->process($container);
|
(new MergeExtensionConfigurationPass())->process($container);
|
||||||
@ -247,6 +260,7 @@ class EnvConfiguration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->arrayNode('simple_array_node')->end()
|
->arrayNode('simple_array_node')->end()
|
||||||
->enumNode('enum_node')->values(array('a', 'b'))->end()
|
->enumNode('enum_node')->values(array('a', 'b'))->end()
|
||||||
|
->variableNode('variable_node')->end()
|
||||||
->end();
|
->end();
|
||||||
|
|
||||||
return $treeBuilder;
|
return $treeBuilder;
|
||||||
|
Reference in New Issue
Block a user