1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* (c) Christian Gripp <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Core23\MenuBundle\Tests\DependencyInjection; |
11
|
|
|
|
12
|
|
|
use Core23\MenuBundle\DependencyInjection\Configuration; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
use Symfony\Component\Config\Definition\Processor; |
15
|
|
|
|
16
|
|
|
class ConfigurationTest extends TestCase |
17
|
|
|
{ |
18
|
|
|
public function testOptions(): void |
19
|
|
|
{ |
20
|
|
|
$processor = new Processor(); |
21
|
|
|
|
22
|
|
|
$config = $processor->processConfiguration(new Configuration(), []); |
23
|
|
|
|
24
|
|
|
$expected = [ |
25
|
|
|
'groups' => [ |
26
|
|
|
], |
27
|
|
|
]; |
28
|
|
|
|
29
|
|
|
$this->assertSame($expected, $config); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testGroupsOptions(): void |
33
|
|
|
{ |
34
|
|
|
$processor = new Processor(); |
35
|
|
|
|
36
|
|
|
$config = $processor->processConfiguration(new Configuration(), [[ |
37
|
|
|
'groups' => [ |
38
|
|
|
'test' => [ |
39
|
|
|
'name' => 'FooMenu', |
40
|
|
|
'attributes' => [ |
41
|
|
|
'class' => 'my-class', |
42
|
|
|
], |
43
|
|
|
'items' => [ |
44
|
|
|
'foo' => [ |
45
|
|
|
'label' => 'my-label', |
46
|
|
|
'children' => [ |
47
|
|
|
'subfoo' => [ |
48
|
|
|
'label' => 'my-sub-label', |
49
|
|
|
'route' => 'my-subroute', |
50
|
|
|
], |
51
|
|
|
], |
52
|
|
|
], |
53
|
|
|
'bar' => [ |
54
|
|
|
'label' => 'my-other-label', |
55
|
|
|
'icon' => 'fa fa-home', |
56
|
|
|
'route' => 'my-route', |
57
|
|
|
'routeParams' => ['foo' => 'bar'], |
58
|
|
|
], |
59
|
|
|
], |
60
|
|
|
], |
61
|
|
|
], |
62
|
|
|
]]); |
63
|
|
|
|
64
|
|
|
$expected = [ |
65
|
|
|
'groups' => [ |
66
|
|
|
'test' => [ |
67
|
|
|
'name' => 'FooMenu', |
68
|
|
|
'attributes' => [ |
69
|
|
|
'class' => 'my-class', |
70
|
|
|
], |
71
|
|
|
'items' => [ |
72
|
|
|
'foo' => [ |
73
|
|
|
'label' => 'my-label', |
74
|
|
|
'children' => [ |
75
|
|
|
'subfoo' => [ |
76
|
|
|
'label' => 'my-sub-label', |
77
|
|
|
'route' => 'my-subroute', |
78
|
|
|
'label_catalogue' => false, |
79
|
|
|
'icon' => null, |
80
|
|
|
'class' => null, |
81
|
|
|
'routeParams' => [], |
82
|
|
|
'children' => [], |
83
|
|
|
], |
84
|
|
|
], |
85
|
|
|
'label_catalogue' => false, |
86
|
|
|
'icon' => null, |
87
|
|
|
'class' => null, |
88
|
|
|
'route' => null, |
89
|
|
|
'routeParams' => [], |
90
|
|
|
], |
91
|
|
|
'bar' => [ |
92
|
|
|
'label' => 'my-other-label', |
93
|
|
|
'icon' => 'fa fa-home', |
94
|
|
|
'route' => 'my-route', |
95
|
|
|
'routeParams' => ['foo' => 'bar'], |
96
|
|
|
'label_catalogue' => false, |
97
|
|
|
'class' => null, |
98
|
|
|
'children' => [], |
99
|
|
|
], |
100
|
|
|
], |
101
|
|
|
], |
102
|
|
|
], |
103
|
|
|
]; |
104
|
|
|
|
105
|
|
|
$this->assertSame($expected, $config); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|