1 | <?php |
||
18 | class ConfigurationTest extends TestCase |
||
19 | { |
||
20 | public function testOptions() |
||
29 | |||
30 | public function testBreadcrumbsChildRouteDefaultsToEdit() |
||
36 | |||
37 | public function testOptionsWithInvalidFormat() |
||
47 | |||
48 | public function testCustomTemplatesPerAdmin() |
||
64 | |||
65 | public function testAdminServicesDefault() |
||
94 | |||
95 | public function testDashboardWithoutRoles() |
||
101 | |||
102 | public function testDashboardWithRoles() |
||
115 | |||
116 | public function testDashboardGroups() |
||
117 | { |
||
118 | $config = $this->process([[ |
||
119 | 'dashboard' => [ |
||
120 | 'groups' => [ |
||
121 | 'bar' => [ |
||
122 | 'label' => 'foo', |
||
123 | 'icon' => '<i class="fa fa-edit"></i>', |
||
124 | 'items' => [ |
||
125 | 'item1', |
||
126 | 'item2', |
||
127 | [ |
||
128 | 'label' => 'fooLabel', |
||
129 | 'route' => 'fooRoute', |
||
130 | 'route_params' => ['bar' => 'foo'], |
||
131 | 'route_absolute' => true, |
||
132 | ], |
||
133 | [ |
||
134 | 'label' => 'barLabel', |
||
135 | 'route' => 'barRoute', |
||
136 | ], |
||
137 | ], |
||
138 | ], |
||
139 | ], |
||
140 | ], |
||
141 | ]]); |
||
142 | |||
143 | $this->assertCount(4, $config['dashboard']['groups']['bar']['items']); |
||
144 | $this->assertSame( |
||
145 | $config['dashboard']['groups']['bar']['items'][0], |
||
146 | [ |
||
147 | 'admin' => 'item1', |
||
148 | 'label' => '', |
||
149 | 'route' => '', |
||
150 | 'route_params' => [], |
||
151 | 'route_absolute' => false, |
||
152 | 'roles' => [], |
||
153 | ] |
||
154 | ); |
||
155 | $this->assertSame( |
||
156 | $config['dashboard']['groups']['bar']['items'][1], |
||
157 | [ |
||
158 | 'admin' => 'item2', |
||
159 | 'label' => '', |
||
160 | 'route' => '', |
||
161 | 'route_params' => [], |
||
162 | 'route_absolute' => false, |
||
163 | 'roles' => [], |
||
164 | ] |
||
165 | ); |
||
166 | $this->assertSame( |
||
167 | $config['dashboard']['groups']['bar']['items'][2], |
||
168 | [ |
||
169 | 'label' => 'fooLabel', |
||
170 | 'route' => 'fooRoute', |
||
171 | 'route_params' => ['bar' => 'foo'], |
||
172 | 'route_absolute' => true, |
||
173 | 'admin' => '', |
||
174 | 'roles' => [], |
||
175 | ] |
||
176 | ); |
||
177 | $this->assertSame( |
||
178 | $config['dashboard']['groups']['bar']['items'][3], |
||
179 | [ |
||
180 | 'label' => 'barLabel', |
||
181 | 'route' => 'barRoute', |
||
182 | 'route_params' => [], |
||
183 | 'admin' => '', |
||
184 | 'roles' => [], |
||
185 | 'route_absolute' => false, |
||
186 | ] |
||
187 | ); |
||
188 | } |
||
189 | |||
190 | public function testDashboardGroupsWithBadItemsParams() |
||
191 | { |
||
192 | $this->expectException('\InvalidArgumentException', 'Expected either parameters "route" and "label" for array items'); |
||
193 | |||
194 | $config = $this->process([[ |
||
195 | 'dashboard' => [ |
||
196 | 'groups' => [ |
||
197 | 'bar' => [ |
||
198 | 'label' => 'foo', |
||
199 | 'icon' => '<i class="fa fa-edit"></i>', |
||
200 | 'items' => [ |
||
201 | 'item1', |
||
202 | 'item2', |
||
203 | [ |
||
204 | 'route' => 'fooRoute', |
||
205 | ], |
||
206 | ], |
||
207 | ], |
||
208 | ], |
||
209 | ], |
||
210 | ]]); |
||
211 | } |
||
212 | |||
213 | public function testSecurityConfigurationDefaults() |
||
220 | |||
221 | /** |
||
222 | * Processes an array of configurations and returns a compiled version. |
||
223 | * |
||
224 | * @param array $configs An array of raw configurations |
||
225 | * |
||
226 | * @return array A normalized array |
||
227 | */ |
||
228 | protected function process($configs) |
||
234 | } |
||
235 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.