‪TYPO3CMS  9.5
PagesVisibleFieldsTest.php
Go to the documentation of this file.
1 <?php
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 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
23 class ‪PagesVisibleFieldsTest extends FunctionalTestCase
24 {
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 
71  protected static ‪$pageFormFields = [
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  ],
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  ],
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  ],
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  ],
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  ],
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 
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 
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 }
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_MOUNTPOINT
‪const DOKTYPE_MOUNTPOINT
Definition: PageRepository.php:172
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest\$defaultPageFormFields
‪static array $defaultPageFormFields
Definition: PagesVisibleFieldsTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\Tca
Definition: BackendGroupsVisibleFieldsTest.php:2
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_SHORTCUT
‪const DOKTYPE_SHORTCUT
Definition: PageRepository.php:170
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_SPACER
‪const DOKTYPE_SPACER
Definition: PageRepository.php:173
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest
Definition: PagesVisibleFieldsTest.php:24
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest\pagesFormContainsExpectedFieldsDataProvider
‪array pagesFormContainsExpectedFieldsDataProvider()
Definition: PagesVisibleFieldsTest.php:213
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest\$pageFormFields
‪static array $pageFormFields
Definition: PagesVisibleFieldsTest.php:69
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest\pagesFormContainsExpectedFields
‪pagesFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
Definition: PagesVisibleFieldsTest.php:240
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_LINK
‪const DOKTYPE_LINK
Definition: PageRepository.php:169
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_SYSFOLDER
‪const DOKTYPE_SYSFOLDER
Definition: PageRepository.php:174
‪TYPO3\CMS\Frontend\Page\PageRepository
Definition: PageRepository.php:53
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_DEFAULT
‪const DOKTYPE_DEFAULT
Definition: PageRepository.php:168
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService
Definition: FormTestService.php:26
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_RECYCLER
‪const DOKTYPE_RECYCLER
Definition: PageRepository.php:175
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_BE_USER_SECTION
‪const DOKTYPE_BE_USER_SECTION
Definition: PageRepository.php:171