<?php
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Symfony\Tests\Component\Config\Definition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
class MergeTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException
public function testForbiddenOverwrite()
$tb = new TreeBuilder();
$tree = $tb
->root('root', 'array')
->children()
->node('foo', 'scalar')
->cannotBeOverwritten()
->end()
->buildTree()
;
$a = array(
'foo' => 'bar',
);
$b = array(
'foo' => 'moo',
$tree->merge($a, $b);
}
public function testUnsetKey()
->node('foo', 'scalar')->end()
->node('bar', 'scalar')->end()
->node('unsettable', 'array')
->canBeUnset()
->node('unsetted', 'array')
->prototype('scalar')->end()
'unsettable' => array(
'foo' => 'a',
'bar' => 'b',
),
'unsetted' => false,
'unsettable' => false,
'unsetted' => array('a', 'b'),
$this->assertEquals(array(
), $tree->merge($a, $b));
* @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
public function testDoesNotAllowNewKeysInSubsequentConfigs()
->root('config', 'array')
->node('test', 'array')
->disallowNewKeysInSubsequentConfigs()
->useAttributeAsKey('key')
->prototype('array')
->node('value', 'scalar')->end()
->buildTree();
'test' => array(
'a' => array('value' => 'foo')
)
'b' => array('value' => 'foo')
public function testPerformsNoDeepMerging()
->node('no_deep_merging', 'array')
->performNoDeepMerging()
'no_deep_merging' => array(
'c' => 'd',
public function testPrototypeWithoutAKeyAttribute()
->arrayNode('append_elements')
'append_elements' => array('a', 'b'),
'append_elements' => array('c', 'd'),
$this->assertEquals(array('append_elements' => array('a', 'b', 'c', 'd')), $tree->merge($a, $b));