‪TYPO3CMS  11.5
ModuleLoaderTest.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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪ModuleLoaderTest extends UnitTestCase
27 {
28  protected function ‪setUp(): void
29  {
30  parent::setUp();
31  ‪$GLOBALS['LANG'] = new \stdClass();
32  ‪$GLOBALS['LANG']->lang = 'it';
33  }
34 
38  public function ‪addModuleLabelsDataProvider(): array
39  {
40  return [
41  'extbase only with string' => [
42  'extbasemodule',
43  'EXT:myext/Resources/Private/Language/modules.xlf',
44  [
45  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
46  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
47  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
48  ],
49  ],
50  'array with LLLs and proper names' => [
51  'singlereferences',
52  [
53  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:myshortdescription',
54  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mydescription',
55  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mytitle',
56  ],
57  [
58  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:myshortdescription',
59  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mydescription',
60  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mytitle',
61  ],
62  ],
63  'XLF reference inside [ll_ref] - classic' => [
64  'classicmodule',
65  [
66  'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
67  ],
68  [
69  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
70  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
71  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
72  ],
73  ],
74  'XLF reference inside [default][ll_ref] - classic with default' => [
75  'classicmodule',
76  [
77  'default' => [
78  'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
79  ],
80  ],
81  [
82  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
83  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
84  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
85  ],
86  ],
87  'XLF reference inside [it][ll_ref] - classic with italian' => [
88  'classicmodule',
89  [
90  'it' => [
91  'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
92  ],
93  ],
94  [
95  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
96  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
97  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
98  ],
99  ],
100  'classic inline labels' => [
101  'classic_inline_labels',
102  [
103  'default' => [
104  'labels' => [
105  'tablabel' => 'My short description!',
106  'tabdescr' => 'My description!',
107  ],
108  'tabs' => [
109  'tab' => 'My title',
110  ],
111  ],
112  ],
113  [
114  'shortdescription' => 'My short description!',
115  'description' => 'My description!',
116  'title' => 'My title',
117  ],
118  ],
119  'classic inline labels in italian completely' => [
120  'classic_italian_labels',
121  [
122  'default' => [
123  'labels' => [
124  'tablabel' => 'My short description!',
125  'tabdescr' => 'My description!',
126  ],
127  'tabs' => [
128  'tab' => 'My title',
129  ],
130  ],
131  'it' => [
132  'labels' => [
133  'tablabel' => 'Mama Mia short description!',
134  'tabdescr' => 'Mama Mia description!',
135  ],
136  'tabs' => [
137  'tab' => 'Mama Mia',
138  ],
139  ],
140  ],
141  [
142  'shortdescription' => 'Mama Mia short description!',
143  'description' => 'Mama Mia description!',
144  'title' => 'Mama Mia',
145  ],
146  ],
147  'classic inline labels in italian partially' => [
148  'classic_italian_labels',
149  [
150  'default' => [
151  'labels' => [
152  'tablabel' => 'My short description!',
153  'tabdescr' => 'My original description!',
154  ],
155  'tabs' => [
156  'tab' => 'My title',
157  ],
158  ],
159  'it' => [
160  'labels' => [
161  'tablabel' => 'Mama Mia short description!',
162  ],
163  'tabs' => [
164  'tab' => 'Mama Mia',
165  ],
166  ],
167  ],
168  [
169  'shortdescription' => 'Mama Mia short description!',
170  'description' => 'My original description!',
171  'title' => 'Mama Mia',
172  ],
173  ],
174  ];
175  }
176 
185  public function ‪validateLabelsString(string $moduleName, $labels, array $expectedResult): void
186  {
187  $moduleLoader = new ‪ModuleLoader();
188  $moduleLoader->addLabelsForModule($moduleName, $labels);
189  self::assertEquals($expectedResult, $moduleLoader->getLabelsForModule($moduleName));
190  }
191 }
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleLoaderTest\validateLabelsString
‪validateLabelsString(string $moduleName, $labels, array $expectedResult)
Definition: ModuleLoaderTest.php:185
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleLoaderTest
Definition: ModuleLoaderTest.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleLoaderTest\setUp
‪setUp()
Definition: ModuleLoaderTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleLoaderTest\addModuleLabelsDataProvider
‪array addModuleLabelsDataProvider()
Definition: ModuleLoaderTest.php:38
‪TYPO3\CMS\Backend\Module\ModuleLoader
Definition: ModuleLoader.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Module
Definition: ModuleLoaderTest.php:18