‪TYPO3CMS  11.5
InheritancesResolverServiceTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪InheritancesResolverServiceTest extends UnitTestCase
28 {
32  protected ‪$subject;
33 
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  $this->subject = new ‪InheritancesResolverService();
38  }
39 
44  public function ‪getDocExampleInheritance(): void
45  {
46  $input = [
47  'Form' => [
48  'part1' => [
49  'key1' => 'value1',
50  'key2' => 'value2',
51  'key3' => 'value3',
52  ],
53  'part2' => [
54  '__inheritances' => [
55  10 => 'Form.part1',
56  ],
57  'key2' => 'another_value',
58  ],
59  ],
60  ];
61 
62  $expected = [
63  'Form' => [
64  'part1' => [
65  'key1' => 'value1',
66  'key2' => 'value2',
67  'key3' => 'value3',
68  ],
69  'part2' => [
70  'key1' => 'value1',
71  'key2' => 'another_value',
72  'key3' => 'value3',
73  ],
74  ],
75  ];
76 
77  self::assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
78  }
79 
83  public function ‪getMergedConfigurationSimpleInheritance(): void
84  {
85  $input = [
86  'Form' => [
87  'klaus01' => [
88  'key01' => 'value',
89  'key02' => [
90  'key03' => 'value',
91  ],
92  ],
93  'klaus02' => [
94  '__inheritances' => [
95  10 => 'Form.klaus01',
96  ],
97  ],
98  ],
99  ];
100 
101  $expected = [
102  'Form' => [
103  'klaus01' => [
104  'key01' => 'value',
105  'key02' => [
106  'key03' => 'value',
107  ],
108  ],
109  'klaus02' => [
110  'key01' => 'value',
111  'key02' => [
112  'key03' => 'value',
113  ],
114  ],
115  ],
116  ];
117 
118  self::assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
119  }
120 
125  {
126  $input = [
127  'Form' => [
128  'klaus01' => [
129  'key' => 'value',
130  ],
131  'klaus02' => [
132  '__inheritances' => [
133  10 => 'Form.klaus01',
134  ],
135  'key' => 'value override',
136  ],
137  ],
138  ];
139 
140  $expected = [
141  'Form' => [
142  'klaus01' => [
143  'key' => 'value',
144  ],
145  'klaus02' => [
146  'key' => 'value override',
147  ],
148  ],
149  ];
150 
151  self::assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
152  }
153 
158  {
159  $input = [
160  'Form' => [
161  'klaus01' => [
162  'key01' => [
163  'key02' => 'value',
164  ],
165  'key02' => [
166  10 => [
167  'key' => 'value',
168  ],
169  20 => [
170  'key' => 'value',
171  ],
172  ],
173  ],
174  'klaus02' => [
175  '__inheritances' => [
176  10 => 'Form.klaus01',
177  ],
178  'key01' => null,
179  'key02' => [
180  10 => null,
181  20 => [
182  'key' => null,
183  ],
184  ],
185  ],
186  ],
187  ];
188 
189  $expected = [
190  'Form' => [
191  'klaus01' => [
192  'key01' => [
193  'key02' => 'value',
194  ],
195  'key02' => [
196  10 => [
197  'key' => 'value',
198  ],
199  20 => [
200  'key' => 'value',
201  ],
202  ],
203  ],
204  'klaus02' => [
205  'key01' => null,
206  'key02' => [
207  10 => null,
208  20 => [
209  'key' => null,
210  ],
211  ],
212  ],
213  ],
214  ];
215 
216  self::assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
217  }
218 
222  public function ‪getMergedConfigurationSimpleMixin(): void
223  {
224  $input = [
225  'Form' => [
226  'mixin01' => [
227  'key' => 'value',
228  ],
229  'klaus01' => [
230  '__inheritances' => [
231  10 => 'Form.mixin01',
232  ],
233  ],
234  'klaus02' => [
235  'key' => [
236  '__inheritances' => [
237  10 => 'Form.mixin01',
238  ],
239  ],
240  ],
241  ],
242  ];
243 
244  $expected = [
245  'Form' => [
246  'mixin01' => [
247  'key' => 'value',
248  ],
249  'klaus01' => [
250  'key' => 'value',
251  ],
252  'klaus02' => [
253  'key' => [
254  'key' => 'value',
255  ],
256  ],
257  ],
258  ];
259 
260  self::assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
261  }
262 
266  public function ‪getMergedConfigurationAdvancedMixin(): void
267  {
268  $input = [
269  'Form' => [
270  'mixin01' => [
271  'key01' => 'value01',
272  'key02' => 'value02',
273  ],
274  'mixin02' => [
275  '__inheritances' => [
276  10 => 'Form.mixin01',
277  ],
278  ],
279  'mixin03' => [
280  'key03' => 'value03',
281  ],
282 
283  'klaus01' => [
284  '__inheritances' => [
285  10 => 'Form.mixin01',
286  ],
287  'key01' => 'value01 override 01',
288  ],
289  'klaus02' => [
290  '__inheritances' => [
291  10 => 'Form.klaus01',
292  20 => 'Form.mixin03',
293  ],
294  'key01' => 'value01 override 02',
295  'key02' => [
296  'horst01' => 'gerda01',
297  ],
298  'key03' => [
299  '__inheritances' => [
300  10 => 'Form.mixin02',
301  ],
302  'key02' => null,
303  ],
304  ],
305  'klaus03' => [
306  '__inheritances' => [
307  10 => 'Form.klaus02',
308  ],
309  ],
310  ],
311  ];
312 
313  $expected = [
314  'Form' => [
315  'mixin01' => [
316  'key01' => 'value01',
317  'key02' => 'value02',
318  ],
319  'mixin02' => [
320  'key01' => 'value01',
321  'key02' => 'value02',
322  ],
323  'mixin03' => [
324  'key03' => 'value03',
325  ],
326  'klaus01' => [
327  'key01' => 'value01 override 01',
328  'key02' => 'value02',
329  ],
330  'klaus02' => [
331  'key01' => 'value01 override 02',
332  'key02' => [
333  'horst01' => 'gerda01',
334  ],
335  'key03' => [
336  'key01' => 'value01',
337  'key02' => null,
338  ],
339  ],
340  'klaus03' => [
341  'key01' => 'value01 override 02',
342  'key02' => [
343  'horst01' => 'gerda01',
344  ],
345  'key03' => [
346  'key01' => 'value01',
347  'key02' => null,
348  ],
349  ],
350  ],
351  ];
352 
353  self::assertSame($expected, $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
354  }
355 
360  {
361  $input = [
362  'TYPO3' => [
363  'CMS' => [
364  'Form' => [
365  'someKey' => [
366  '__inheritances' => [
367  10 => 'TYPO3.CMS.Form.anotherKey',
368  ],
369  ],
370  'anotherKey' => [
371  '__inheritances' => [
372  10 => 'TYPO3.CMS.Form.someKey',
373  ],
374  ],
375  ],
376  ],
377  ],
378  ];
379 
380  $this->expectException(CycleInheritancesException::class);
381  $this->expectExceptionCode(1474900797);
382 
383  $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);
384  }
385 
390  {
391  $input = [
392  'TYPO3' => [
393  'CMS' => [
394  'Form' => [
395  'klaus1' => [
396  '__inheritances' => [
397  10 => 'TYPO3.CMS.Form.klaus2',
398  ],
399  ],
400  'klaus2' => [
401  '__inheritances' => [
402  10 => 'TYPO3.CMS.Form.mixin1',
403  ],
404  ],
405  'mixin1' => [
406  '__inheritances' => [
407  10 => 'TYPO3.CMS.Form.mixin2',
408  ],
409  ],
410  'mixin2' => [
411  '__inheritances' => [
412  10 => 'TYPO3.CMS.Form.klaus2',
413  ],
414  ],
415  ],
416  ],
417  ],
418  ];
419 
420  $this->expectException(CycleInheritancesException::class);
421  $this->expectExceptionCode(1474900799);
422 
423  $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);
424  }
425 
430  {
431  $input = [
432  'TYPO3' => [
433  'CMS' => [
434  'Form' => [
435  'klaus1' => [
436  'key01' => 'value',
437  'key02' => [
438  '__inheritances' => [
439  10 => 'TYPO3.CMS.Form.mixin01',
440  ],
441  ],
442  ],
443  'klaus2' => [
444  '__inheritances' => [
445  10 => 'TYPO3.CMS.Form.klaus1',
446  ],
447  'key02' => [
448  '__inheritances' => [
449  10 => 'TYPO3.CMS.Form.mixin01',
450  20 => 'TYPO3.CMS.Form.mixin02',
451  ],
452  ],
453  ],
454  'mixin01' => [
455  'liselotte01' => 'value',
456  ],
457  'mixin02' => [
458  '__inheritances' => [
459  10 => 'TYPO3.CMS.Form.klaus2',
460  ],
461  'liselotte02' => 'value',
462  ],
463  ],
464  ],
465  ],
466  ];
467 
468  $this->expectException(CycleInheritancesException::class);
469  $this->expectExceptionCode(1474900797);
470 
471  $this->subject->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);
472  }
473 }
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getMergedConfigurationSimpleMixin
‪getMergedConfigurationSimpleMixin()
Definition: InheritancesResolverServiceTest.php:221
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration
Definition: ConfigurationManagerTest.php:18
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getMergedConfigurationSimpleInheritanceOverrideValue
‪getMergedConfigurationSimpleInheritanceOverrideValue()
Definition: InheritancesResolverServiceTest.php:123
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getResolvedConfigurationThrowsExceptionIfCycleDependenciesOnSameLevelIsFound
‪getResolvedConfigurationThrowsExceptionIfCycleDependenciesOnSameLevelIsFound()
Definition: InheritancesResolverServiceTest.php:358
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getMergedConfigurationSimpleInheritance
‪getMergedConfigurationSimpleInheritance()
Definition: InheritancesResolverServiceTest.php:82
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\setUp
‪setUp()
Definition: InheritancesResolverServiceTest.php:33
‪TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService
Definition: InheritancesResolverService.php:64
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getMergedConfigurationSimpleInheritanceRemoveValue
‪getMergedConfigurationSimpleInheritanceRemoveValue()
Definition: InheritancesResolverServiceTest.php:156
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getDocExampleInheritance
‪getDocExampleInheritance()
Definition: InheritancesResolverServiceTest.php:43
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\$subject
‪InheritancesResolverService $subject
Definition: InheritancesResolverServiceTest.php:31
‪TYPO3\CMS\Form\Mvc\Configuration\Exception\CycleInheritancesException
Definition: CycleInheritancesException.php:28
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getResolvedConfigurationThrowsExceptionIfCycleDependenciesOnSameLevelWithGapIsFound
‪getResolvedConfigurationThrowsExceptionIfCycleDependenciesOnSameLevelWithGapIsFound()
Definition: InheritancesResolverServiceTest.php:388
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getMergedConfigurationAdvancedMixin
‪getMergedConfigurationAdvancedMixin()
Definition: InheritancesResolverServiceTest.php:265
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest
Definition: InheritancesResolverServiceTest.php:28
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\InheritancesResolverServiceTest\getResolvedConfigurationThrowsExceptionIfCycleDependenciesOnHigherLevelIsFound
‪getResolvedConfigurationThrowsExceptionIfCycleDependenciesOnHigherLevelIsFound()
Definition: InheritancesResolverServiceTest.php:428