Skip to content

Commit 03b5686

Browse files
committed
[DI][Config] Fix empty env validation
1 parent fd3ec88 commit 03b5686

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Tests/Compiler/ValidateEnvPlaceholdersPassTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@ public function testEnvIsNotUnset()
196196
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
197197
}
198198

199+
public function testEmptyEnvWithCannotBeEmptyForScalarNode(): void
200+
{
201+
$container = new ContainerBuilder();
202+
$container->registerExtension($ext = new EnvExtension());
203+
$container->prependExtensionConfig('env_extension', $expected = array(
204+
'scalar_node_not_empty' => '%env(SOME)%',
205+
));
206+
207+
$this->doProcess($container);
208+
209+
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
210+
}
211+
199212
private function doProcess(ContainerBuilder $container): void
200213
{
201214
(new MergeExtensionConfigurationPass())->process($container);
@@ -213,6 +226,7 @@ public function getConfigTreeBuilder()
213226
$rootNode
214227
->children()
215228
->scalarNode('scalar_node')->end()
229+
->scalarNode('scalar_node_not_empty')->cannotBeEmpty()->end()
216230
->integerNode('int_node')->end()
217231
->floatNode('float_node')->end()
218232
->booleanNode('bool_node')->end()

0 commit comments

Comments
 (0)