diff --git a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php index 652a153a3d..a7929ceb35 100644 --- a/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/ArrayNodeTest.php @@ -161,4 +161,41 @@ class ArrayNodeTest extends \PHPUnit_Framework_TestCase ), ); } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Child nodes must be named. + */ + public function testAddChildEmptyName() + { + $node = new ArrayNode('root'); + + $childNode = new ArrayNode(''); + $node->addChild($childNode); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage A child node named "foo" already exists. + */ + public function testAddChildNameAlreadyExists() + { + $node = new ArrayNode('root'); + + $childNode = new ArrayNode('foo'); + $node->addChild($childNode); + + $childNodeWithSameName = new ArrayNode('foo'); + $node->addChild($childNodeWithSameName); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage The node at path "foo" has no default value. + */ + public function testGetDefaultValueWithoutDefaultValue() + { + $node = new ArrayNode('foo'); + $node->getDefaultValue(); + } }