[Config] Fix nested prototyped array nodes

This commit is contained in:
Victor Berchet 2012-02-20 18:01:14 +01:00
parent 675e5eb6e0
commit bc122bdb2d
2 changed files with 12 additions and 1 deletions

View File

@ -307,7 +307,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
if (false !== $this->addDefaultChildren) {
$node->setAddChildrenIfNoneSet($this->addDefaultChildren);
if ($this->prototype instanceof static) {
if ($this->prototype instanceof static && null === $this->prototype->prototype) {
$this->prototype->addDefaultsIfNotSet();
}
}

View File

@ -89,6 +89,17 @@ class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array(array()), $tree->getDefaultValue());
}
public function testNestedPrototypedArrayNodes()
{
$node = new ArrayNodeDefinition('root');
$node
->addDefaultChildrenWhenNoneSet()
->prototype('array')
->prototype('array')
;
$tree = $node->getNode();
}
protected function getField($object, $field)
{
$reflection = new \ReflectionProperty($object, $field);