This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/DependencyInjection/Configuration/ArrayNodeTest.php
Christophe Coevoet cb0fa406aa Added unit tests
2011-02-12 21:56:22 +01:00

52 lines
1.5 KiB
PHP

<?php
namespace Symfony\Tests\Component\DependencyInjection\Configuration;
use Symfony\Component\DependencyInjection\Configuration\ArrayNode;
class ArrayNodeTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException Symfony\Component\DependencyInjection\Configuration\Exception\InvalidTypeException
*/
public function testNormalizeThrowsExceptionWhenFalseIsNotAllowed()
{
$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());
}
}