[!!!][TASK] Remove DB field pages.no_cache
[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 'l18n_cfg',
55 'is_siteroot',
56 'no_search',
57 'editlock',
58 'php_tree_stop',
59 'module',
60 'media',
61 'tsconfig_includes',
62 'TSconfig',
63 'categories',
64 ];
65
66 /**
67 * Configuration of hidden / additional form fields per page type.
68 *
69 * @var array
70 */
71 protected static $pageFormFields = [
72 PageRepository::DOKTYPE_BE_USER_SECTION => [],
73 PageRepository::DOKTYPE_DEFAULT => [],
74 PageRepository::DOKTYPE_SHORTCUT => [
75 'additionalFields' => [
76 'shortcut_mode',
77 'shortcut',
78 ],
79 'hiddenFields' => [
80 'keywords',
81 'description',
82 'content_from_pid',
83 'cache_timeout',
84 'cache_tags',
85 'module',
86 ],
87 ],
88 PageRepository::DOKTYPE_MOUNTPOINT => [
89 'additionalFields' => [
90 'mount_pid_ol',
91 'mount_pid',
92 ],
93 'hiddenFields' => [
94 'keywords',
95 'description',
96 'content_from_pid',
97 'cache_timeout',
98 'cache_tags',
99 'module',
100 ],
101 ],
102 PageRepository::DOKTYPE_LINK => [
103 'additionalFields' => [
104 'url',
105 ],
106 'hiddenFields' => [
107 'keywords',
108 'description',
109 'content_from_pid',
110 'cache_timeout',
111 'cache_tags',
112 'module',
113 ],
114 ],
115 PageRepository::DOKTYPE_SYSFOLDER => [
116 'hiddenFields' => [
117 'nav_title',
118 'subtitle',
119 'nav_hide',
120 'starttime',
121 'endtime',
122 'extendToSubpages',
123 'fe_group',
124 'fe_login_mode',
125 'abstract',
126 'keywords',
127 'description',
128 'author',
129 'author_email',
130 'layout',
131 'newUntil',
132 'content_from_pid',
133 'cache_timeout',
134 'cache_tags',
135 'content_from_pid',
136 'alias',
137 'target',
138 'cache_timeout',
139 'cache_tags',
140 'l18n_cfg',
141 'is_siteroot',
142 'no_search',
143 'php_tree_stop',
144 ],
145 ],
146 PageRepository::DOKTYPE_RECYCLER => [
147 'hiddenFields' => [
148 'nav_title',
149 'subtitle',
150 'nav_hide',
151 'starttime',
152 'endtime',
153 'extendToSubpages',
154 'fe_group',
155 'fe_login_mode',
156 'abstract',
157 'keywords',
158 'description',
159 'author',
160 'author_email',
161 'layout',
162 'newUntil',
163 'backend_layout',
164 'backend_layout_next_level',
165 'content_from_pid',
166 'cache_timeout',
167 'cache_tags',
168 'content_from_pid',
169 'alias',
170 'target',
171 'cache_timeout',
172 'cache_tags',
173 'l18n_cfg',
174 'is_siteroot',
175 'no_search',
176 'php_tree_stop',
177 'module',
178 'media',
179 'tsconfig_includes',
180 'TSconfig',
181 ],
182 ],
183 PageRepository::DOKTYPE_SPACER => [
184 'hiddenFields' => [
185 'nav_title',
186 'subtitle',
187 'abstract',
188 'keywords',
189 'description',
190 'author',
191 'author_email',
192 'layout',
193 'newUntil',
194 'module',
195 'content_from_pid',
196 'cache_timeout',
197 'cache_tags',
198 'content_from_pid',
199 'alias',
200 'target',
201 'cache_timeout',
202 'cache_tags',
203 'l18n_cfg',
204 'is_siteroot',
205 'no_search',
206 'php_tree_stop',
207 'media',
208 ],
209 ],
210 ];
211
212 /**
213 * @return array
214 */
215 public function pagesFormContainsExpectedFieldsDataProvider(): array
216 {
217 $pageTypes = [];
218
219 foreach (static::$pageFormFields as $doktype => $fieldConfig) {
220 $expectedFields = static::$defaultPageFormFields;
221 $hiddenFields = [];
222 if (array_key_exists('additionalFields', $fieldConfig)) {
223 $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
224 }
225 if (array_key_exists('hiddenFields', $fieldConfig)) {
226 $hiddenFields = $fieldConfig['hiddenFields'];
227 $expectedFields = array_diff($expectedFields, $hiddenFields);
228 }
229 $pageTypes['page doktype ' . $doktype] = [$doktype, $expectedFields, $hiddenFields];
230 }
231
232 return $pageTypes;
233 }
234
235 /**
236 * @test
237 * @dataProvider pagesFormContainsExpectedFieldsDataProvider
238 * @param int $doktype
239 * @param array $expectedFields
240 * @param array $hiddenFields
241 */
242 public function pagesFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
243 {
244 $this->setUpBackendUserFromFixture(1);
245 $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
246
247 $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
248 $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]);
249
250 foreach ($expectedFields as $expectedField) {
251 $this->assertNotFalse(
252 $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
253 'The field ' . $expectedField . ' is not in the HTML'
254 );
255 }
256
257 foreach ($hiddenFields as $hiddenField) {
258 $this->assertFalse(
259 $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
260 'The field ' . $hiddenField . ' is in the HTML'
261 );
262 }
263 }
264 }