File tree 3 files changed +26
-0
lines changed
DependencyInjection/Tests/Compiler
3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,14 @@ protected function allowPlaceholders(): bool
476
476
return true ;
477
477
}
478
478
479
+ /**
480
+ * Tests if a placeholder is being handled currently.
481
+ */
482
+ protected function isHandlingPlaceholder (): bool
483
+ {
484
+ return null !== $ this ->handlingPlaceholder ;
485
+ }
486
+
479
487
/**
480
488
* Gets allowed dynamic types for this node.
481
489
*/
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ protected function validateType($value)
52
52
*/
53
53
protected function isValueEmpty ($ value )
54
54
{
55
+ if ($ this ->isHandlingPlaceholder ()) {
56
+ return false ;
57
+ }
58
+
55
59
return null === $ value || '' === $ value ;
56
60
}
57
61
Original file line number Diff line number Diff line change @@ -196,6 +196,19 @@ public function testEnvIsNotUnset()
196
196
$ this ->assertSame ($ expected , $ container ->resolveEnvPlaceholders ($ ext ->getConfig ()));
197
197
}
198
198
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
+
199
212
private function doProcess (ContainerBuilder $ container ): void
200
213
{
201
214
(new MergeExtensionConfigurationPass ())->process ($ container );
@@ -213,6 +226,7 @@ public function getConfigTreeBuilder()
213
226
$ rootNode
214
227
->children ()
215
228
->scalarNode ('scalar_node ' )->end ()
229
+ ->scalarNode ('scalar_node_not_empty ' )->cannotBeEmpty ()->end ()
216
230
->integerNode ('int_node ' )->end ()
217
231
->floatNode ('float_node ' )->end ()
218
232
->booleanNode ('bool_node ' )->end ()
You can’t perform that action at this time.
0 commit comments