[TASK] Enable backendlayouts/ tsConfig on doktype menu separator
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / Tca / PagesVisibleFieldsTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Tca;
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\Tests\Functional\Form\FormTestService;
18 use TYPO3\CMS\Core\Localization\LanguageService;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Frontend\Page\PageRepository;
21
22 class PagesVisibleFieldsTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
23 {
24 /**
25 * These form fields a visisble in the default page types.
26 *
27 * @var array
28 */
29 protected static $defaultPageFormFields = [
30 'title',
31 'nav_title',
32 'subtitle',
33 'hidden',
34 'nav_hide',
35 'starttime',
36 'endtime',
37 'extendToSubpages',
38 'fe_group',
39 'fe_login_mode',
40 'abstract',
41 'keywords',
42 'description',
43 'author',
44 'author_email',
45 'layout',
46 'newUntil',
47 'backend_layout',
48 'backend_layout_next_level',
49 'content_from_pid',
50 'alias',
51 'target',
52 'cache_timeout',
53 'cache_tags',
54 'no_cache',
55 'l18n_cfg',
56 'is_siteroot',
57 'no_search',
58 'editlock',
59 'php_tree_stop',
60 'module',
61 'media',
62 'tsconfig_includes',
63 'TSconfig',
64 'categories',
65 ];
66
67 /**
68 * Configuration of hidden / additional form fields per page type.
69 *
70 * @var array
71 */
72 protected static $pageFormFields = [
73 PageRepository::DOKTYPE_BE_USER_SECTION => [],
74 PageRepository::DOKTYPE_DEFAULT => [],
75 PageRepository::DOKTYPE_SHORTCUT => [
76 'additionalFields' => [
77 'shortcut_mode',
78 'shortcut',
79 ],
80 'hiddenFields' => [
81 'keywords',
82 'description',
83 'content_from_pid',
84 'cache_timeout',
85 'cache_tags',
86 'no_cache',
87 'module',
88 ],
89 ],
90 PageRepository::DOKTYPE_MOUNTPOINT => [
91 'additionalFields' => [
92 'mount_pid_ol',
93 'mount_pid',
94 ],
95 'hiddenFields' => [
96 'keywords',
97 'description',
98 'content_from_pid',
99 'cache_timeout',
100 'cache_tags',
101 'no_cache',
102 'module',
103 ],
104 ],
105 PageRepository::DOKTYPE_LINK => [
106 'additionalFields' => [
107 'url',
108 ],
109 'hiddenFields' => [
110 'keywords',
111 'description',
112 'content_from_pid',
113 'cache_timeout',
114 'cache_tags',
115 'no_cache',
116 'module',
117 ],
118 ],
119 PageRepository::DOKTYPE_SYSFOLDER => [
120 'hiddenFields' => [
121 'nav_title',
122 'subtitle',
123 'nav_hide',
124 'starttime',
125 'endtime',
126 'extendToSubpages',
127 'fe_group',
128 'fe_login_mode',
129 'abstract',
130 'keywords',
131 'description',
132 'author',
133 'author_email',
134 'layout',
135 'newUntil',
136 'content_from_pid',
137 'cache_timeout',
138 'cache_tags',
139 'no_cache',
140 'content_from_pid',
141 'alias',
142 'target',
143 'cache_timeout',
144 'cache_tags',
145 'no_cache',
146 'l18n_cfg',
147 'is_siteroot',
148 'no_search',
149 'php_tree_stop',
150 ],
151 ],
152 PageRepository::DOKTYPE_RECYCLER => [
153 'hiddenFields' => [
154 'nav_title',
155 'subtitle',
156 'nav_hide',
157 'starttime',
158 'endtime',
159 'extendToSubpages',
160 'fe_group',
161 'fe_login_mode',
162 'abstract',
163 'keywords',
164 'description',
165 'author',
166 'author_email',
167 'layout',
168 'newUntil',
169 'backend_layout',
170 'backend_layout_next_level',
171 'content_from_pid',
172 'cache_timeout',
173 'cache_tags',
174 'no_cache',
175 'content_from_pid',
176 'alias',
177 'target',
178 'cache_timeout',
179 'cache_tags',
180 'no_cache',
181 'l18n_cfg',
182 'is_siteroot',
183 'no_search',
184 'php_tree_stop',
185 'module',
186 'media',
187 'tsconfig_includes',
188 'TSconfig',
189 ],
190 ],
191 PageRepository::DOKTYPE_SPACER => [
192 'hiddenFields' => [
193 'nav_title',
194 'subtitle',
195 'abstract',
196 'keywords',
197 'description',
198 'author',
199 'author_email',
200 'layout',
201 'newUntil',
202 'module',
203 'content_from_pid',
204 'cache_timeout',
205 'cache_tags',
206 'no_cache',
207 'content_from_pid',
208 'alias',
209 'target',
210 'cache_timeout',
211 'cache_tags',
212 'no_cache',
213 'l18n_cfg',
214 'is_siteroot',
215 'no_search',
216 'php_tree_stop',
217 'media',
218 ],
219 ],
220 ];
221
222 /**
223 * @return array
224 */
225 public function pagesFormContainsExpectedFieldsDataProvider(): array
226 {
227 $pageTypes = [];
228
229 foreach (static::$pageFormFields as $doktype => $fieldConfig) {
230 $expectedFields = static::$defaultPageFormFields;
231 $hiddenFields = [];
232 if (array_key_exists('additionalFields', $fieldConfig)) {
233 $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
234 }
235 if (array_key_exists('hiddenFields', $fieldConfig)) {
236 $hiddenFields = $fieldConfig['hiddenFields'];
237 $expectedFields = array_diff($expectedFields, $hiddenFields);
238 }
239 $pageTypes['page doktype ' . $doktype] = [$doktype, $expectedFields, $hiddenFields];
240 }
241
242 return $pageTypes;
243 }
244
245 /**
246 * @test
247 * @dataProvider pagesFormContainsExpectedFieldsDataProvider
248 * @param int $doktype
249 * @param array $expectedFields
250 * @param array $hiddenFields
251 */
252 public function pagesFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
253 {
254 $this->setUpBackendUserFromFixture(1);
255 $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
256
257 $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
258 $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]);
259
260 foreach ($expectedFields as $expectedField) {
261 $this->assertNotFalse(
262 $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
263 'The field ' . $expectedField . ' is not in the HTML'
264 );
265 }
266
267 foreach ($hiddenFields as $hiddenField) {
268 $this->assertFalse(
269 $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
270 'The field ' . $hiddenField . ' is in the HTML'
271 );
272 }
273 }
274 }