Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 726bc28

Browse files
Eric COURTIALfabpot
Eric COURTIAL
authored andcommitted
[Config] Allow using environment variables in EnumNode
1 parent 5fbd0dc commit 726bc28

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/Symfony/Component/Config/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.1
5+
---
6+
7+
* Allow using environment variables in `EnumNode`
8+
49
6.0
510
---
611

src/Symfony/Component/Config/Definition/EnumNode.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,4 @@ protected function finalizeValue(mixed $value): mixed
5454

5555
return $value;
5656
}
57-
58-
/**
59-
* {@inheritdoc}
60-
*/
61-
protected function allowPlaceholders(): bool
62-
{
63-
return false;
64-
}
6557
}

src/Symfony/Component/Config/Tests/Definition/EnumNodeTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,20 @@ public function testFinalizeWithInvalidValue()
5555
$node = new EnumNode('foo', null, ['foo', 'bar']);
5656
$node->finalize('foobar');
5757
}
58+
59+
public function testWithPlaceHolderWithValidValue()
60+
{
61+
$node = new EnumNode('cookie_samesite', null, ['lax', 'strict', 'none']);
62+
EnumNode::setPlaceholder('custom', ['string' => 'lax']);
63+
$this->assertSame('custom', $node->finalize('custom'));
64+
}
65+
66+
public function testWithPlaceHolderWithInvalidValue()
67+
{
68+
$node = new EnumNode('cookie_samesite', null, ['lax', 'strict', 'none']);
69+
EnumNode::setPlaceholder('custom', ['string' => 'foo']);
70+
$this->expectException(InvalidConfigurationException::class);
71+
$this->expectExceptionMessage('The value "foo" is not allowed for path "cookie_samesite". Permissible values: "lax", "strict", "none"');
72+
$node->finalize('custom');
73+
}
5874
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,6 @@ public function testConcatenatedEnvInConfig()
153153
$this->assertSame(['scalar_node' => $expected], $container->resolveEnvPlaceholders($ext->getConfig()));
154154
}
155155

156-
public function testEnvIsIncompatibleWithEnumNode()
157-
{
158-
$this->expectException(InvalidConfigurationException::class);
159-
$this->expectExceptionMessage('A dynamic value is not compatible with a "Symfony\Component\Config\Definition\EnumNode" node type at path "env_extension.enum_node".');
160-
$container = new ContainerBuilder();
161-
$container->registerExtension(new EnvExtension());
162-
$container->prependExtensionConfig('env_extension', [
163-
'enum_node' => '%env(FOO)%',
164-
]);
165-
166-
$this->doProcess($container);
167-
}
168-
169156
public function testEnvIsIncompatibleWithArrayNode()
170157
{
171158
$this->expectException(InvalidConfigurationException::class);

0 commit comments

Comments
 (0)