733f600850f5a0f74d2aeb76e9d91c648479c606
[yaffs-website] / vendor / symfony / config / Tests / Definition / FinalizationTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Config\Tests\Definition;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16 use Symfony\Component\Config\Definition\Processor;
17 use Symfony\Component\Config\Definition\NodeInterface;
18
19 class FinalizationTest extends TestCase
20 {
21     public function testUnsetKeyWithDeepHierarchy()
22     {
23         $tb = new TreeBuilder();
24         $tree = $tb
25             ->root('config', 'array')
26                 ->children()
27                     ->node('level1', 'array')
28                         ->canBeUnset()
29                         ->children()
30                             ->node('level2', 'array')
31                                 ->canBeUnset()
32                                 ->children()
33                                     ->node('somevalue', 'scalar')->end()
34                                     ->node('anothervalue', 'scalar')->end()
35                                 ->end()
36                             ->end()
37                             ->node('level1_scalar', 'scalar')->end()
38                         ->end()
39                     ->end()
40                 ->end()
41             ->end()
42             ->buildTree()
43         ;
44
45         $a = array(
46             'level1' => array(
47                 'level2' => array(
48                     'somevalue' => 'foo',
49                     'anothervalue' => 'bar',
50                 ),
51                 'level1_scalar' => 'foo',
52             ),
53         );
54
55         $b = array(
56             'level1' => array(
57                 'level2' => false,
58             ),
59         );
60
61         $this->assertEquals(array(
62             'level1' => array(
63                 'level1_scalar' => 'foo',
64             ),
65         ), $this->process($tree, array($a, $b)));
66     }
67
68     protected function process(NodeInterface $tree, array $configs)
69     {
70         $processor = new Processor();
71
72         return $processor->process($tree, $configs);
73     }
74 }