소스 검색

Added unit tests

Christophe Coevoet 14 년 전
부모
커밋
cb0fa406aa
1개의 변경된 파일35개의 추가작업 그리고 0개의 파일을 삭제
  1. 35 0
      tests/Symfony/Tests/Component/DependencyInjection/Configuration/ArrayNodeTest.php

+ 35 - 0
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());
+    }
 }