@@ -234,6 +234,18 @@ public function testConfigurationWithoutRootNode(): void
234
234
$ this ->addToAssertionCount (1 );
235
235
}
236
236
237
+ public function testEmptyConfigFromMoreThanOneSource ()
238
+ {
239
+ $ container = new ContainerBuilder ();
240
+ $ container ->registerExtension (new EnvExtension (new ConfigurationWithArrayNodeRequiringOneElement ()));
241
+ $ container ->loadFromExtension ('env_extension ' , array ());
242
+ $ container ->loadFromExtension ('env_extension ' , array ());
243
+
244
+ $ this ->doProcess ($ container );
245
+
246
+ $ this ->addToAssertionCount (1 );
247
+ }
248
+
237
249
public function testDiscardedEnvInConfig (): void
238
250
{
239
251
$ container = new ContainerBuilder ();
@@ -313,6 +325,24 @@ public function getConfigTreeBuilder()
313
325
}
314
326
}
315
327
328
+ class ConfigurationWithArrayNodeRequiringOneElement implements ConfigurationInterface
329
+ {
330
+ public function getConfigTreeBuilder ()
331
+ {
332
+ $ treeBuilder = new TreeBuilder ();
333
+ $ treeBuilder ->root ('env_extension ' )
334
+ ->children ()
335
+ ->arrayNode ('nodes ' )
336
+ ->isRequired ()
337
+ ->requiresAtLeastOneElement ()
338
+ ->scalarPrototype ()->end ()
339
+ ->end ()
340
+ ->end ();
341
+
342
+ return $ treeBuilder ;
343
+ }
344
+ }
345
+
316
346
class EnvExtension extends Extension
317
347
{
318
348
private $ configuration ;
@@ -335,6 +365,10 @@ public function getConfiguration(array $config, ContainerBuilder $container)
335
365
336
366
public function load (array $ configs , ContainerBuilder $ container )
337
367
{
368
+ if (!array_filter ($ configs )) {
369
+ return ;
370
+ }
371
+
338
372
try {
339
373
$ this ->config = $ this ->processConfiguration ($ this ->getConfiguration ($ configs , $ container ), $ configs );
340
374
} catch (TreeWithoutRootNodeException $ e ) {
0 commit comments