[!!!][TASK] Move pages.url_scheme to compatibility7
[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\Utility\GeneralUtility;
19 use TYPO3\CMS\Frontend\Page\PageRepository;
20 use TYPO3\CMS\Lang\LanguageService;
21
22 class PagesVisibleFieldsTest extends \TYPO3\CMS\Components\TestingFramework\Core\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 'urltype',
108 'url',
109 ],
110 'hiddenFields' => [
111 'keywords',
112 'description',
113 'content_from_pid',
114 'cache_timeout',
115 'cache_tags',
116 'no_cache',
117 'module',
118 ],
119 ],
120 PageRepository::DOKTYPE_SYSFOLDER => [
121 'hiddenFields' => [
122 'nav_title',
123 'subtitle',
124 'nav_hide',
125 'starttime',
126 'endtime',
127 'extendToSubpages',
128 'fe_group',
129 'fe_login_mode',
130 'abstract',
131 'keywords',
132 'description',
133 'author',
134 'author_email',
135 'layout',
136 'newUntil',
137 'content_from_pid',
138 'cache_timeout',
139 'cache_tags',
140 'no_cache',
141 'content_from_pid',
142 'alias',
143 'target',
144 'cache_timeout',
145 'cache_tags',
146 'no_cache',
147 'l18n_cfg',
148 'is_siteroot',
149 'no_search',
150 'php_tree_stop',
151 ],
152 ],
153 PageRepository::DOKTYPE_RECYCLER => [
154 'hiddenFields' => [
155 'nav_title',
156 'subtitle',
157 'nav_hide',
158 'starttime',
159 'endtime',
160 'extendToSubpages',
161 'fe_group',
162 'fe_login_mode',
163 'abstract',
164 'keywords',
165 'description',
166 'author',
167 'author_email',
168 'layout',
169 'newUntil',
170 'backend_layout',
171 'backend_layout_next_level',
172 'content_from_pid',
173 'cache_timeout',
174 'cache_tags',
175 'no_cache',
176 'content_from_pid',
177 'alias',
178 'target',
179 'cache_timeout',
180 'cache_tags',
181 'no_cache',
182 'l18n_cfg',
183 'is_siteroot',
184 'no_search',
185 'php_tree_stop',
186 'module',
187 'media',
188 'tsconfig_includes',
189 'TSconfig',
190 ],
191 ],
192 PageRepository::DOKTYPE_SPACER => [
193 'hiddenFields' => [
194 'nav_title',
195 'subtitle',
196 'abstract',
197 'keywords',
198 'description',
199 'author',
200 'author_email',
201 'layout',
202 'newUntil',
203 'backend_layout',
204 'backend_layout_next_level',
205 'module',
206 'content_from_pid',
207 'cache_timeout',
208 'cache_tags',
209 'no_cache',
210 'content_from_pid',
211 'alias',
212 'target',
213 'cache_timeout',
214 'cache_tags',
215 'no_cache',
216 'l18n_cfg',
217 'is_siteroot',
218 'no_search',
219 'php_tree_stop',
220 'media',
221 'tsconfig_includes',
222 'TSconfig',
223 ],
224 ],
225 ];
226
227 /**
228 * @return array
229 */
230 public function pagesFormContainsExpectedFieldsDataProvider(): array
231 {
232 $pageTypes = [];
233
234 foreach (static::$pageFormFields as $doktype => $fieldConfig) {
235 $expectedFields = static::$defaultPageFormFields;
236 $hiddenFields = [];
237 if (array_key_exists('additionalFields', $fieldConfig)) {
238 $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
239 }
240 if (array_key_exists('hiddenFields', $fieldConfig)) {
241 $hiddenFields = $fieldConfig['hiddenFields'];
242 $expectedFields = array_diff($expectedFields, $hiddenFields);
243 }
244 $pageTypes['page doktype ' . $doktype] = [$doktype, $expectedFields, $hiddenFields];
245 }
246
247 return $pageTypes;
248 }
249
250 /**
251 * @test
252 * @dataProvider pagesFormContainsExpectedFieldsDataProvider
253 * @param int $doktype
254 * @param array $expectedFields
255 * @param array $hiddenFields
256 */
257 public function pagesFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
258 {
259 $this->setUpBackendUserFromFixture(1);
260 $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
261
262 $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
263 $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]);
264
265 foreach ($expectedFields as $expectedField) {
266 $this->assertNotFalse(
267 $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
268 'The field ' . $expectedField . ' is not in the HTML'
269 );
270 }
271
272 foreach ($hiddenFields as $hiddenField) {
273 $this->assertFalse(
274 $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
275 'The field ' . $hiddenField . ' is in the HTML'
276 );
277 }
278 }
279 }