Added unit tests

This commit is contained in:
Christophe Coevoet 2011-02-12 14:37:44 +01:00 committed by Fabien Potencier
parent ccd630981f
commit cb0fa406aa
1 changed files with 35 additions and 0 deletions

View File

@ -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());
}
}