‪TYPO3CMS  ‪main
ModuleFactoryTest.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 
20 use PHPUnit\Framework\Attributes\Test;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
26 final class ‪ModuleFactoryTest extends UnitTestCase
27 {
29 
30  protected function ‪setUp(): void
31  {
32  parent::setUp();
33  $this->subject = new ‪ModuleFactory(
34  $this->createMock(IconRegistry::class),
36  );
37  }
38 
39  #[Test]
41  {
42  $moduleConfiguration = [
43  'module_from_extension' => [
44  'parent' => 'old_name',
45  'path' => '/module/my-module',
46  ],
47  'new_name' => [
48  'path' => '/module/new',
49  'aliases' => ['old_name'],
50  ],
51  'new_list_module' => [
52  'aliases' => ['web_list', 'web_list_x'],
53  ],
54  'content' => [
55  'aliases' => ['web'],
56  ],
57  'web_info' => [
58  'parent' => 'web',
59  'position' => ['before' => 'web_list', 'after' => 'old_name'],
60  ],
61  'new_info_overview' => [
62  'parent' => 'web_info',
63  'position' => ['before' => 'invalid_name'],
64  'aliases' => ['web_info_overview'],
65  ],
66  'web_info_ext' => [
67  'parent' => 'new_info',
68  'position' => ['before' => 'web_info_overview'],
69  ],
70  'foo' => [
71  'parent' => 'duplicated',
72  ],
73  'foo_bar' => [
74  'parent' => 'web_list_x',
75  'aliases' => ['duplicated'],
76  ],
77  'bar_baz' => [
78  'position' => ['after' => 'foo_bar'],
79  'aliases' => ['duplicated'],
80  ],
81  ];
82  $expectedModuleConfiguration = [
83  'module_from_extension' => [
84  'parent' => 'new_name',
85  'path' => '/module/my-module',
86  ],
87  'new_name' => [
88  'path' => '/module/new',
89  'aliases' => ['old_name'],
90  ],
91  'new_list_module' => [
92  'aliases' => ['web_list', 'web_list_x'],
93  ],
94  'content' => [
95  'aliases' => ['web'],
96  ],
97  'web_info' => [
98  'parent' => 'content',
99  'position' => ['before' => 'new_list_module', 'after' => 'new_name'],
100  ],
101  'new_info_overview' => [
102  'parent' => 'web_info',
103  'position' => ['before' => 'invalid_name'],
104  'aliases' => ['web_info_overview'],
105  ],
106  'web_info_ext' => [
107  'parent' => 'new_info',
108  'position' => ['before' => 'new_info_overview'],
109  ],
110  'foo' => [
111  'parent' => 'bar_baz',
112  ],
113  'foo_bar' => [
114  'parent' => 'new_list_module',
115  'aliases' => ['duplicated'],
116  ],
117  'bar_baz' => [
118  'position' => ['after' => 'foo_bar'],
119  'aliases' => ['duplicated'],
120  ],
121  ];
122  $moduleConfiguration = $this->subject->adaptAliasMappingFromModuleConfiguration($moduleConfiguration);
123  self::assertEquals($expectedModuleConfiguration, $moduleConfiguration);
124  }
125 }
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleFactoryTest\setUp
‪setUp()
Definition: ModuleFactoryTest.php:30
‪TYPO3\CMS\Backend\Module\ModuleFactory
Definition: ModuleFactory.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleFactoryTest
Definition: ModuleFactoryTest.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleFactoryTest\adaptAliasMappingFromModuleConfigurationMapsAliasesProperly
‪adaptAliasMappingFromModuleConfigurationMapsAliasesProperly()
Definition: ModuleFactoryTest.php:40
‪TYPO3\CMS\Core\Imaging\IconRegistry
Definition: IconRegistry.php:32
‪TYPO3\CMS\Core\EventDispatcher\NoopEventDispatcher
Definition: NoopEventDispatcher.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleFactoryTest\$subject
‪ModuleFactory $subject
Definition: ModuleFactoryTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Module
Definition: ModuleFactoryTest.php:18