[Config] Fix enum default value in Yaml dumper

This commit is contained in:
Romain Neutron 2015-09-21 17:02:29 +02:00
parent 0ad587aec3
commit d135d8282d
4 changed files with 5 additions and 1 deletions

View File

@ -88,7 +88,7 @@ class YamlReferenceDumper
}
} elseif ($node instanceof EnumNode) {
$comments[] = 'One of '.implode('; ', array_map('json_encode', $node->getValues()));
$default = '~';
$default = $node->hasDefaultValue() ? Inline::dump($node->getDefaultValue()) : '~';
} else {
$default = '~';

View File

@ -37,6 +37,7 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase
return str_replace("\n", PHP_EOL, <<<EOL
<!-- Namespace: http://example.org/schema/dic/acme_root -->
<!-- scalar-required: Required -->
<!-- enum-with-default: One of "this"; "that" -->
<!-- enum: One of "this"; "that" -->
<config
boolean="true"
@ -48,6 +49,7 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase
scalar-array-empty=""
scalar-array-defaults="elem1,elem2"
scalar-required=""
enum-with-default="this"
enum=""
>

View File

@ -43,6 +43,7 @@ acme_root:
- elem1
- elem2
scalar_required: ~ # Required
enum_with_default: this # One of "this"; "that"
enum: ~ # One of "this"; "that"
# some info

View File

@ -34,6 +34,7 @@ class ExampleConfiguration implements ConfigurationInterface
->scalarNode('scalar_array_empty')->defaultValue(array())->end()
->scalarNode('scalar_array_defaults')->defaultValue(array('elem1', 'elem2'))->end()
->scalarNode('scalar_required')->isRequired()->end()
->enumNode('enum_with_default')->values(array('this', 'that'))->defaultValue('this')->end()
->enumNode('enum')->values(array('this', 'that'))->end()
->arrayNode('array')
->info('some info')