* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Config\Tests\Definition; use PHPUnit\Framework\TestCase; use Symfony\Component\Config\Definition\Builder\TreeBuilder; class MergeTest extends 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() ->end() ->end() ->buildTree() ; $a = array( 'foo' => 'bar', ); $b = array( 'foo' => 'moo', ); $tree->merge($a, $b); } public function testUnsetKey() { $tb = new TreeBuilder(); $tree = $tb ->root('root', 'array') ->children() ->node('foo', 'scalar')->end() ->node('bar', 'scalar')->end() ->node('unsettable', 'array') ->canBeUnset() ->children() ->node('foo', 'scalar')->end() ->node('bar', 'scalar')->end() ->end() ->end() ->node('unsetted', 'array') ->canBeUnset() ->prototype('scalar')->end() ->end() ->end() ->end() ->buildTree() ; $a = array( 'foo' => 'bar', 'unsettable' => array( 'foo' => 'a', 'bar' => 'b', ), 'unsetted' => false, ); $b = array( 'foo' => 'moo', 'bar' => 'b', 'unsettable' => false, 'unsetted' => array('a', 'b'), ); $this->assertEquals(array( 'foo' => 'moo', 'bar' => 'b', 'unsettable' => false, 'unsetted' => array('a', 'b'), ), $tree->merge($a, $b)); } /** * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException */ public function testDoesNotAllowNewKeysInSubsequentConfigs() { $tb = new TreeBuilder(); $tree = $tb ->root('config', 'array') ->children() ->node('test', 'array') ->disallowNewKeysInSubsequentConfigs() ->useAttributeAsKey('key') ->prototype('array') ->children() ->node('value', 'scalar')->end() ->end() ->end() ->end() ->end() ->end() ->buildTree(); $a = array( 'test' => array( 'a' => array('value' => 'foo'), ), ); $b = array( 'test' => array( 'b' => array('value' => 'foo'), ), ); $tree->merge($a, $b); } public function testPerformsNoDeepMerging() { $tb = new TreeBuilder(); $tree = $tb ->root('config', 'array') ->children() ->node('no_deep_merging', 'array') ->performNoDeepMerging() ->children() ->node('foo', 'scalar')->end() ->node('bar', 'scalar')->end() ->end() ->end() ->end() ->end() ->buildTree() ; $a = array( 'no_deep_merging' => array( 'foo' => 'a', 'bar' => 'b', ), ); $b = array( 'no_deep_merging' => array( 'c' => 'd', ), ); $this->assertEquals(array( 'no_deep_merging' => array( 'c' => 'd', ), ), $tree->merge($a, $b)); } public function testPrototypeWithoutAKeyAttribute() { $tb = new TreeBuilder(); $tree = $tb ->root('config', 'array') ->children() ->arrayNode('append_elements') ->prototype('scalar')->end() ->end() ->end() ->end() ->buildTree() ; $a = array( 'append_elements' => array('a', 'b'), ); $b = array( 'append_elements' => array('c', 'd'), ); $this->assertEquals(array('append_elements' => array('a', 'b', 'c', 'd')), $tree->merge($a, $b)); } } __halt_compiler();----SIGNATURE:----uvY0BocjP2wf3obt9P8CeyGbo2xkIvz6UYsq9mGtjFwvpuOLaU/fZYGX2VtmTnvGAZ4EI06N/LE2ZjLWHkuCz73cWuhp1hxinRDdWL29rTITRafRvXT7zTKpZyiTLR5Az3n9ivX64QNNb2uVrkYqlRly/k22uoO/yUkpJIN4oomQcCLX8AA3q2hD6L3yTuoKPlzigA2YyV/Z2A6/qz312f690uWZVqI258HT7wo8J8P8TSRBnMKb2B5OChBLjbP6gFwjpY+nn0OAmxqnPU23ftuw5EN+tJA1yd21uEFwT4BusWffffMyVjNFQMzNT24LHmm2gIHR8z+xlgcUMQRFtlNJXOvV15nUCGuGUeR6yXRwSyUn0psWH+0yLgx4puLXHz5tgbNOU6QMIegLti9hDV7dAJ6ZKJgkFEjchqbvvraf79boILd9D2Cg5rks1f5Cyl5bXQmkiggYVFGBuUNR+wbf678dPoJtZ/VLszbgPP3ARhEyxeYOO2AueEaAO2ChUtTZI7Z433uz1AcxORv3hbNpuzMEL/LIHDixZn8gqsAF38GXoSr8VphNha/GQPalMV2aqYRZ4B17rmfyCY1L7DHPlTNNm0B7UKs/AmdZ0xUAoI4GsaKcNX9lKsqBGa/oxJeDhUowIM1KLkiW62M/61UZTHQ+FF7jZbmnEMf5N0I=----ATTACHMENT:----NjU2MjY1NTUxMTE1NjA5OCA2MjQ3ODgzMjk2ODE4NjUgODMwNDk2NjYxNDI1NjU1OQ==