TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
InheritancesResolverServiceTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
25 {
29  protected $subject;
30 
31  protected function setUp()
32  {
33  $this->subject = new InheritancesResolverService();
34  }
35 
40  {
41  $input = [
42  'Form' => [
43  'klaus01' => [
44  'key01' => 'value',
45  'key02' => [
46  'key03' => 'value',
47  ],
48  ],
49  'klaus02' => [
50  '__inheritances' => [
51  10 => 'Form.klaus01',
52  ],
53  ],
54  ],
55  ];
56 
57  $expected = [
58  'Form' => [
59  'klaus01' => [
60  'key01' => 'value',
61  'key02' => [
62  'key03' => 'value'
63  ],
64  ],
65  'klaus02' => [
66  'key01' => 'value',
67  'key02' => [
68  'key03' => 'value',
69  ],
70  ],
71  ],
72  ];
73 
74  $this->assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
75  }
76 
81  {
82  $input = [
83  'Form' => [
84  'klaus01' => [
85  'key' => 'value',
86  ],
87  'klaus02' => [
88  '__inheritances' => [
89  10 => 'Form.klaus01',
90  ],
91  'key' => 'value override',
92  ],
93  ],
94  ];
95 
96  $expected = [
97  'Form' => [
98  'klaus01' => [
99  'key' => 'value',
100  ],
101  'klaus02' => [
102  'key' => 'value override',
103  ],
104  ],
105  ];
106 
107  $this->assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
108  }
109 
114  {
115  $input = [
116  'Form' => [
117  'klaus01' => [
118  'key01' => [
119  'key02' => 'value',
120  ],
121  'key02' => [
122  10 => [
123  'key' => 'value',
124  ],
125  20 => [
126  'key' => 'value',
127  ],
128  ],
129  ],
130  'klaus02' => [
131  '__inheritances' => [
132  10 => 'Form.klaus01',
133  ],
134  'key01' => null,
135  'key02' => [
136  10 => null,
137  20 => [
138  'key' => null,
139  ],
140  ],
141  ],
142  ],
143  ];
144 
145  $expected = [
146  'Form' => [
147  'klaus01' => [
148  'key01' => [
149  'key02' => 'value',
150  ],
151  'key02' => [
152  10 => [
153  'key' => 'value',
154  ],
155  20 => [
156  'key' => 'value',
157  ],
158  ],
159  ],
160  'klaus02' => [
161  'key01' => null,
162  'key02' => [
163  10 => null,
164  20 => [
165  'key' => null,
166  ],
167  ],
168  ],
169  ],
170  ];
171 
172  $this->assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
173  }
174 
179  {
180  $input = [
181  'Form' => [
182  'mixin01' => [
183  'key' => 'value',
184  ],
185  'klaus01' => [
186  '__inheritances' => [
187  10 => 'Form.mixin01',
188  ],
189  ],
190  'klaus02' => [
191  'key' => [
192  '__inheritances' => [
193  10 => 'Form.mixin01',
194  ],
195  ],
196  ],
197  ],
198  ];
199 
200  $expected = [
201  'Form' => [
202  'mixin01' => [
203  'key' => 'value',
204  ],
205  'klaus01' => [
206  'key' => 'value',
207  ],
208  'klaus02' => [
209  'key' => [
210  'key' => 'value',
211  ],
212  ],
213  ],
214  ];
215 
216  $this->assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
217  }
218 
223  {
224  $input = [
225  'Form' => [
226  'mixin01' => [
227  'key01' => 'value01',
228  'key02' => 'value02',
229  ],
230  'mixin02' => [
231  '__inheritances' => [
232  10 => 'Form.mixin01',
233  ],
234  ],
235  'mixin03' => [
236  'key03' => 'value03',
237  ],
238 
239  'klaus01' => [
240  '__inheritances' => [
241  10 => 'Form.mixin01',
242  ],
243  'key01' => 'value01 override 01',
244  ],
245  'klaus02' => [
246  '__inheritances' => [
247  10 => 'Form.klaus01',
248  20 => 'Form.mixin03',
249  ],
250  'key01' => 'value01 override 02',
251  'key02' => [
252  'horst01' => 'gerda01'
253  ],
254  'key03' => [
255  '__inheritances' => [
256  10 => 'Form.mixin02',
257  ],
258  'key02' => null,
259  ],
260  ],
261  'klaus03' => [
262  '__inheritances' => [
263  10 => 'Form.klaus02',
264  ],
265  ],
266  ],
267  ];
268 
269  $expected = [
270  'Form' => [
271  'mixin01' => [
272  'key01' => 'value01',
273  'key02' => 'value02',
274  ],
275  'mixin02' => [
276  'key01' => 'value01',
277  'key02' => 'value02',
278  ],
279  'mixin03' => [
280  'key03' => 'value03',
281  ],
282  'klaus01' => [
283  'key01' => 'value01 override 01',
284  'key02' => 'value02',
285  ],
286  'klaus02' => [
287  'key01' => 'value01 override 02',
288  'key02' => [
289  'horst01' => 'gerda01'
290  ],
291  'key03' => [
292  'key01' => 'value01',
293  'key02' => null,
294  ],
295  ],
296  'klaus03' => [
297  'key01' => 'value01 override 02',
298  'key02' => [
299  'horst01' => 'gerda01'
300  ],
301  'key03' => [
302  'key01' => 'value01',
303  'key02' => null,
304  ],
305  ],
306  ],
307  ];
308 
309  $this->assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
310  }
311 
316  {
317  $input = [
318  'TYPO3' => [
319  'CMS' => [
320  'Form' => [
321  'someKey' => [
322  '__inheritances' => [
323  10 => 'TYPO3.CMS.Form.anotherKey',
324  ],
325  ],
326  'anotherKey' => [
327  '__inheritances' => [
328  10 => 'TYPO3.CMS.Form.someKey',
329  ],
330  ],
331  ],
332  ],
333  ],
334  ];
335 
336  $this->expectException(CycleInheritancesException::class);
337  $this->expectExceptionCode(1474900797);
338 
339  $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);
340  }
341 
346  {
347  $input = [
348  'TYPO3' => [
349  'CMS' => [
350  'Form' => [
351  'klaus1' => [
352  '__inheritances' => [
353  10 => 'TYPO3.CMS.Form.klaus2',
354  ],
355  ],
356  'klaus2' => [
357  '__inheritances' => [
358  10 => 'TYPO3.CMS.Form.mixin1',
359  ],
360  ],
361  'mixin1' => [
362  '__inheritances' => [
363  10 => 'TYPO3.CMS.Form.mixin2',
364  ],
365  ],
366  'mixin2' => [
367  '__inheritances' => [
368  10 => 'TYPO3.CMS.Form.klaus2',
369  ],
370  ],
371  ],
372  ],
373  ],
374  ];
375 
376  $this->expectException(CycleInheritancesException::class);
377  $this->expectExceptionCode(1474900799);
378 
379  $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);
380  }
381 
386  {
387  $input = [
388  'TYPO3' => [
389  'CMS' => [
390  'Form' => [
391  'klaus1' => [
392  'key01' => 'value',
393  'key02' => [
394  '__inheritances' => [
395  10 => 'TYPO3.CMS.Form.mixin01',
396  ],
397  ],
398  ],
399  'klaus2' => [
400  '__inheritances' => [
401  10 => 'TYPO3.CMS.Form.klaus1',
402  ],
403  'key02' => [
404  '__inheritances' => [
405  10 => 'TYPO3.CMS.Form.mixin01',
406  20 => 'TYPO3.CMS.Form.mixin02',
407  ],
408  ],
409  ],
410  'mixin01' => [
411  'liselotte01' => 'value',
412  ],
413  'mixin02' => [
414  '__inheritances' => [
415  10 => 'TYPO3.CMS.Form.klaus2',
416  ],
417  'liselotte02' => 'value',
418  ],
419  ],
420  ],
421  ],
422  ];
423 
424  $this->expectException(CycleInheritancesException::class);
425  $this->expectExceptionCode(1474900797);
426 
427  $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);
428  }
429 }