4a8eaf038c09ea696d5e334a0204482cefcab290
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Module / ModuleLoaderTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Module;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
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.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Module\ModuleLoader;
18
19 /**
20 * Test case
21 */
22 class ModuleLoaderTest extends \TYPO3\Components\TestingFramework\Core\UnitTestCase
23 {
24 protected function setUp()
25 {
26 $GLOBALS['LANG'] = new \stdClass();
27 $GLOBALS['LANG']->lang = 'it';
28 }
29
30 /**
31 * @return array
32 */
33 public function addModuleLabelsDataProvider()
34 {
35 return [
36 'extbase only with string' => [
37 'extbasemodule',
38 'EXT:myext/Resources/Private/Language/modules.xlf',
39 [
40 'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
41 'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
42 'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
43 ],
44 ],
45 'array with LLLs and proper names' => [
46 'singlereferences',
47 [
48 'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:myshortdescription',
49 'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mydescription',
50 'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mytitle',
51 ],
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 'XLF reference inside [ll_ref] - classic' => [
59 'classicmodule',
60 [
61 'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
62 ],
63 [
64 'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
65 'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
66 'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
67 ],
68 ],
69 'XLF reference inside [default][ll_ref] - classic with default' => [
70 'classicmodule',
71 [
72 'default' => [
73 'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
74 ],
75 ],
76 [
77 'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
78 'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
79 'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
80 ],
81 ],
82 'XLF reference inside [it][ll_ref] - classic with italian' => [
83 'classicmodule',
84 [
85 'it' => [
86 'll_ref' => 'EXT:myext/Resources/Private/Language/modules.xlf',
87 ],
88 ],
89 [
90 'shortdescription' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tablabel',
91 'description' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_labels_tabdescr',
92 'title' => 'EXT:myext/Resources/Private/Language/modules.xlf:mlang_tabs_tab',
93 ],
94 ],
95 'classic inline labels' => [
96 'classic_inline_labels',
97 [
98 'default' => [
99 'labels' => [
100 'tablabel' => 'My short description!',
101 'tabdescr' => 'My description!',
102 ],
103 'tabs' => [
104 'tab' => 'My title',
105 ],
106 ],
107 ],
108 [
109 'shortdescription' => 'My short description!',
110 'description' => 'My description!',
111 'title' => 'My title',
112 ],
113 ],
114 'classic inline labels in italian completely' => [
115 'classic_italian_labels',
116 [
117 'default' => [
118 'labels' => [
119 'tablabel' => 'My short description!',
120 'tabdescr' => 'My description!',
121 ],
122 'tabs' => [
123 'tab' => 'My title',
124 ],
125 ],
126 'it' => [
127 'labels' => [
128 'tablabel' => 'Mama Mia short description!',
129 'tabdescr' => 'Mama Mia description!',
130 ],
131 'tabs' => [
132 'tab' => 'Mama Mia',
133 ],
134 ],
135 ],
136 [
137 'shortdescription' => 'Mama Mia short description!',
138 'description' => 'Mama Mia description!',
139 'title' => 'Mama Mia',
140 ],
141 ],
142 'classic inline labels in italian partially' => [
143 'classic_italian_labels',
144 [
145 'default' => [
146 'labels' => [
147 'tablabel' => 'My short description!',
148 'tabdescr' => 'My original description!',
149 ],
150 'tabs' => [
151 'tab' => 'My title',
152 ],
153 ],
154 'it' => [
155 'labels' => [
156 'tablabel' => 'Mama Mia short description!',
157 ],
158 'tabs' => [
159 'tab' => 'Mama Mia',
160 ],
161 ],
162 ],
163 [
164 'shortdescription' => 'Mama Mia short description!',
165 'description' => 'My original description!',
166 'title' => 'Mama Mia',
167 ],
168 ],
169 ];
170 }
171
172 /**
173 * @test
174 * @dataProvider addModuleLabelsDataProvider
175 *
176 * @param string $moduleName
177 * @param string|array $labels
178 * @param array $expectedResult
179 */
180 public function validateLabelsString($moduleName, $labels, array $expectedResult)
181 {
182 $moduleLoader = new ModuleLoader();
183 $moduleLoader->addLabelsForModule($moduleName, $labels);
184 $this->assertEquals($expectedResult, $moduleLoader->getLabelsForModule($moduleName));
185 }
186 }