From cb0fa406aaef8cf33ab8211f1dd7868b329a66d8 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 12 Feb 2011 14:37:44 +0100 Subject: [PATCH] Added unit tests --- .../Configuration/ArrayNodeTest.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/Symfony/Tests/Component/DependencyInjection/Configuration/ArrayNodeTest.php b/tests/Symfony/Tests/Component/DependencyInjection/Configuration/ArrayNodeTest.php index da3155493e..d5d087b60d 100644 --- a/tests/Symfony/Tests/Component/DependencyInjection/Configuration/ArrayNodeTest.php +++ b/tests/Symfony/Tests/Component/DependencyInjection/Configuration/ArrayNodeTest.php @@ -14,4 +14,39 @@ class ArrayNodeTest extends \PHPUnit_Framework_TestCase $node = new ArrayNode('root'); $node->normalize(false); } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetDefaultValueThrowsExceptionWhenNotAnArray() + { + $node = new ArrayNode('root'); + $node->setDefaultValue('test'); + } + + /** + * @expectedException RuntimeException + */ + public function testSetDefaultValueThrowsExceptionWhenNotAnPrototype() + { + $node = new ArrayNode('root'); + $node->setDefaultValue(array ('test')); + } + + public function testGetDefaultValueReturnsAnEmptyArrayForPrototypes() + { + $node = new ArrayNode('root'); + $prototype = new ArrayNode(null, $node); + $node->setPrototype($prototype); + $this->assertEmpty($node->getDefaultValue()); + } + + public function testGetDefaultValueReturnsDefaultValueForPrototypes() + { + $node = new ArrayNode('root'); + $prototype = new ArrayNode(null, $node); + $node->setPrototype($prototype); + $node->setDefaultValue(array ('test')); + $this->assertEquals(array ('test'), $node->getDefaultValue()); + } } \ No newline at end of file