[BUGFIX] Fix several typos in php comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / Tca / PagesVisibleFieldsTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\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\Domain\Repository\PageRepository;
19 use TYPO3\CMS\Core\Localization\LanguageService;
20 use TYPO3\CMS\Core\Utility\GeneralUtility;
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22
23 class PagesVisibleFieldsTest extends FunctionalTestCase
24 {
25 /**
26 * These form fields are visible in the default page types.
27 *
28 * @var array
29 */
30 protected static $defaultPageFormFields = [
31 'title',
32 'nav_title',
33 'subtitle',
34 'hidden',
35 'nav_hide',
36 'starttime',
37 'endtime',
38 'extendToSubpages',
39 'fe_group',
40 'fe_login_mode',
41 'abstract',
42 'keywords',
43 'description',
44 'author',
45 'author_email',
46 'layout',
47 'newUntil',
48 'backend_layout',
49 'backend_layout_next_level',
50 'content_from_pid',
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 'target',
137 'cache_timeout',
138 'cache_tags',
139 'l18n_cfg',
140 'is_siteroot',
141 'no_search',
142 'php_tree_stop',
143 ],
144 ],
145 PageRepository::DOKTYPE_RECYCLER => [
146 'hiddenFields' => [
147 'nav_title',
148 'subtitle',
149 'nav_hide',
150 'starttime',
151 'endtime',
152 'extendToSubpages',
153 'fe_group',
154 'fe_login_mode',
155 'abstract',
156 'keywords',
157 'description',
158 'author',
159 'author_email',
160 'layout',
161 'newUntil',
162 'backend_layout',
163 'backend_layout_next_level',
164 'content_from_pid',
165 'cache_timeout',
166 'cache_tags',
167 'content_from_pid',
168 'target',
169 'cache_timeout',
170 'cache_tags',
171 'l18n_cfg',
172 'is_siteroot',
173 'no_search',
174 'php_tree_stop',
175 'module',
176 'media',
177 'tsconfig_includes',
178 'TSconfig',
179 ],
180 ],
181 PageRepository::DOKTYPE_SPACER => [
182 'hiddenFields' => [
183 'nav_title',
184 'subtitle',
185 'abstract',
186 'keywords',
187 'description',
188 'author',
189 'author_email',
190 'layout',
191 'newUntil',
192 'module',
193 'content_from_pid',
194 'cache_timeout',
195 'cache_tags',
196 'content_from_pid',
197 'target',
198 'cache_timeout',
199 'cache_tags',
200 'l18n_cfg',
201 'is_siteroot',
202 'no_search',
203 'php_tree_stop',
204 'media',
205 ],
206 ],
207 ];
208
209 /**
210 * @return array
211 */
212 public function pagesFormContainsExpectedFieldsDataProvider(): array
213 {
214 $pageTypes = [];
215
216 foreach (static::$pageFormFields as $doktype => $fieldConfig) {
217 $expectedFields = static::$defaultPageFormFields;
218 $hiddenFields = [];
219 if (array_key_exists('additionalFields', $fieldConfig)) {
220 $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
221 }
222 if (array_key_exists('hiddenFields', $fieldConfig)) {
223 $hiddenFields = $fieldConfig['hiddenFields'];
224 $expectedFields = array_diff($expectedFields, $hiddenFields);
225 }
226 $pageTypes['page doktype ' . $doktype] = [$doktype, $expectedFields, $hiddenFields];
227 }
228
229 return $pageTypes;
230 }
231
232 /**
233 * @test
234 * @dataProvider pagesFormContainsExpectedFieldsDataProvider
235 * @param int $doktype
236 * @param array $expectedFields
237 * @param array $hiddenFields
238 */
239 public function pagesFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
240 {
241 $this->setUpBackendUserFromFixture(1);
242 $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
243
244 $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
245 $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]);
246
247 foreach ($expectedFields as $expectedField) {
248 $this->assertNotFalse(
249 $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
250 'The field ' . $expectedField . ' is not in the HTML'
251 );
252 }
253
254 foreach ($hiddenFields as $hiddenField) {
255 $this->assertFalse(
256 $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
257 'The field ' . $hiddenField . ' is in the HTML'
258 );
259 }
260 }
261 }