‪TYPO3CMS  10.4
ModuleLoaderTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪ModuleLoaderTest extends UnitTestCase
25 {
26  protected function ‪setUp(): void
27  {
28  parent::setUp();
29  ‪$GLOBALS['LANG'] = new \stdClass();
30  ‪$GLOBALS['LANG']->lang = 'it';
31  }
32 
37  {
38  return [
39  'extbase only with string' => [
40  'extbasemodule',
41  'EXT:myext/Resources/Private/Language/modules.xlf',
42  [
43  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
44  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
45  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
46  ],
47  ],
48  'array with LLLs and proper names' => [
49  'singlereferences',
50  [
51  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:myshortdescription',
52  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mydescription',
53  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mytitle',
54  ],
55  [
56  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:myshortdescription',
57  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mydescription',
58  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mytitle',
59  ],
60  ],
61  'XLF reference inside [ll_ref] - classic' => [
62  'classicmodule',
63  [
64  'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
65  ],
66  [
67  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
68  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
69  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
70  ],
71  ],
72  'XLF reference inside [default][ll_ref] - classic with default' => [
73  'classicmodule',
74  [
75  'default' => [
76  'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
77  ],
78  ],
79  [
80  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
81  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
82  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
83  ],
84  ],
85  'XLF reference inside [it][ll_ref] - classic with italian' => [
86  'classicmodule',
87  [
88  'it' => [
89  'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
90  ],
91  ],
92  [
93  'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
94  'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
95  'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
96  ],
97  ],
98  'classic inline labels' => [
99  'classic_inline_labels',
100  [
101  'default' => [
102  'labels' => [
103  'tablabel' => 'My short description!',
104  'tabdescr' => 'My description!',
105  ],
106  'tabs' => [
107  'tab' => 'My title',
108  ],
109  ],
110  ],
111  [
112  'shortdescription' => 'My short description!',
113  'description' => 'My description!',
114  'title' => 'My title',
115  ],
116  ],
117  'classic inline labels in italian completely' => [
118  'classic_italian_labels',
119  [
120  'default' => [
121  'labels' => [
122  'tablabel' => 'My short description!',
123  'tabdescr' => 'My description!',
124  ],
125  'tabs' => [
126  'tab' => 'My title',
127  ],
128  ],
129  'it' => [
130  'labels' => [
131  'tablabel' => 'Mama Mia short description!',
132  'tabdescr' => 'Mama Mia description!',
133  ],
134  'tabs' => [
135  'tab' => 'Mama Mia',
136  ],
137  ],
138  ],
139  [
140  'shortdescription' => 'Mama Mia short description!',
141  'description' => 'Mama Mia description!',
142  'title' => 'Mama Mia',
143  ],
144  ],
145  'classic inline labels in italian partially' => [
146  'classic_italian_labels',
147  [
148  'default' => [
149  'labels' => [
150  'tablabel' => 'My short description!',
151  'tabdescr' => 'My original description!',
152  ],
153  'tabs' => [
154  'tab' => 'My title',
155  ],
156  ],
157  'it' => [
158  'labels' => [
159  'tablabel' => 'Mama Mia short description!',
160  ],
161  'tabs' => [
162  'tab' => 'Mama Mia',
163  ],
164  ],
165  ],
166  [
167  'shortdescription' => 'Mama Mia short description!',
168  'description' => 'My original description!',
169  'title' => 'Mama Mia',
170  ],
171  ],
172  ];
173  }
174 
183  public function ‪validateLabelsString($moduleName, $labels, array $expectedResult)
184  {
185  $moduleLoader = new ‪ModuleLoader();
186  $moduleLoader->addLabelsForModule($moduleName, $labels);
187  self::assertEquals($expectedResult, $moduleLoader->getLabelsForModule($moduleName));
188  }
189 }
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleLoaderTest
Definition: ModuleLoaderTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleLoaderTest\setUp
‪setUp()
Definition: ModuleLoaderTest.php:26
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleLoaderTest\addModuleLabelsDataProvider
‪array addModuleLabelsDataProvider()
Definition: ModuleLoaderTest.php:36
‪TYPO3\CMS\Backend\Module\ModuleLoader
Definition: ModuleLoader.php:34
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Unit\Module\ModuleLoaderTest\validateLabelsString
‪validateLabelsString($moduleName, $labels, array $expectedResult)
Definition: ModuleLoaderTest.php:183
‪TYPO3\CMS\Backend\Tests\Unit\Module
Definition: ModuleLoaderTest.php:16