2 namespace TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Form\Mvc\Configuration\Exception\CycleInheritancesException
;
18 use TYPO3\CMS\Form\Mvc\Configuration\InheritancesResolverService
;
23 class InheritancesResolverServiceTest
extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
26 * @var InheritancesResolverService
30 protected function setUp()
32 $this->subject
= new InheritancesResolverService();
37 * Test for the explicit example in service class comment
39 public function getDocExampleInheritance()
52 'key2' => 'another_value'
66 'key2' => 'another_value',
72 $this->assertSame($expected, $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
78 public function getMergedConfigurationSimpleInheritance()
113 $this->assertSame($expected, $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
119 public function getMergedConfigurationSimpleInheritanceOverrideValue()
127 '__inheritances' => [
128 10 => 'Form.klaus01',
130 'key' => 'value override',
141 'key' => 'value override',
146 $this->assertSame($expected, $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
152 public function getMergedConfigurationSimpleInheritanceRemoveValue()
170 '__inheritances' => [
171 10 => 'Form.klaus01',
211 $this->assertSame($expected, $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
217 public function getMergedConfigurationSimpleMixin()
225 '__inheritances' => [
226 10 => 'Form.mixin01',
231 '__inheritances' => [
232 10 => 'Form.mixin01',
255 $this->assertSame($expected, $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
261 public function getMergedConfigurationAdvancedMixin()
266 'key01' => 'value01',
267 'key02' => 'value02',
270 '__inheritances' => [
271 10 => 'Form.mixin01',
275 'key03' => 'value03',
279 '__inheritances' => [
280 10 => 'Form.mixin01',
282 'key01' => 'value01 override 01',
285 '__inheritances' => [
286 10 => 'Form.klaus01',
287 20 => 'Form.mixin03',
289 'key01' => 'value01 override 02',
291 'horst01' => 'gerda01'
294 '__inheritances' => [
295 10 => 'Form.mixin02',
301 '__inheritances' => [
302 10 => 'Form.klaus02',
311 'key01' => 'value01',
312 'key02' => 'value02',
315 'key01' => 'value01',
316 'key02' => 'value02',
319 'key03' => 'value03',
322 'key01' => 'value01 override 01',
323 'key02' => 'value02',
326 'key01' => 'value01 override 02',
328 'horst01' => 'gerda01'
331 'key01' => 'value01',
336 'key01' => 'value01 override 02',
338 'horst01' => 'gerda01'
341 'key01' => 'value01',
348 $this->assertSame($expected, $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input));
354 public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnSameLevelIsFound()
361 '__inheritances' => [
362 10 => 'TYPO3.CMS.Form.anotherKey',
366 '__inheritances' => [
367 10 => 'TYPO3.CMS.Form.someKey',
375 $this->expectException(CycleInheritancesException
::class);
376 $this->expectExceptionCode(1474900797);
378 $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);
384 public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnSameLevelWithGapIsFound()
391 '__inheritances' => [
392 10 => 'TYPO3.CMS.Form.klaus2',
396 '__inheritances' => [
397 10 => 'TYPO3.CMS.Form.mixin1',
401 '__inheritances' => [
402 10 => 'TYPO3.CMS.Form.mixin2',
406 '__inheritances' => [
407 10 => 'TYPO3.CMS.Form.klaus2',
415 $this->expectException(CycleInheritancesException
::class);
416 $this->expectExceptionCode(1474900799);
418 $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);
424 public function getResolvedConfigurationThrowsExceptionIfCycleDepenciesOnHigherLevelIsFound()
433 '__inheritances' => [
434 10 => 'TYPO3.CMS.Form.mixin01',
439 '__inheritances' => [
440 10 => 'TYPO3.CMS.Form.klaus1',
443 '__inheritances' => [
444 10 => 'TYPO3.CMS.Form.mixin01',
445 20 => 'TYPO3.CMS.Form.mixin02',
450 'liselotte01' => 'value',
453 '__inheritances' => [
454 10 => 'TYPO3.CMS.Form.klaus2',
456 'liselotte02' => 'value',
463 $this->expectException(CycleInheritancesException
::class);
464 $this->expectExceptionCode(1474900797);
466 $this->subject
->reset()->setReferenceConfiguration($input)->getResolvedConfiguration($input);