‪TYPO3CMS  10.4
PagesVisibleFieldsTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 
24 class ‪PagesVisibleFieldsTest extends FunctionalTestCase
25 {
31  protected static ‪$defaultPageFormFields = [
32  'title',
33  'nav_title',
34  'subtitle',
35  'hidden',
36  'nav_hide',
37  'starttime',
38  'endtime',
39  'extendToSubpages',
40  'fe_group',
41  'fe_login_mode',
42  'abstract',
43  'keywords',
44  'description',
45  'author',
46  'author_email',
47  'layout',
48  'newUntil',
49  'backend_layout',
50  'backend_layout_next_level',
51  'content_from_pid',
52  'target',
53  'cache_timeout',
54  'cache_tags',
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 
72  protected static ‪$pageFormFields = [
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  'module',
87  ],
88  ],
90  'additionalFields' => [
91  'mount_pid_ol',
92  'mount_pid',
93  ],
94  'hiddenFields' => [
95  'keywords',
96  'description',
97  'content_from_pid',
98  'cache_timeout',
99  'cache_tags',
100  'module',
101  ],
102  ],
104  'additionalFields' => [
105  'url',
106  ],
107  'hiddenFields' => [
108  'keywords',
109  'description',
110  'content_from_pid',
111  'cache_timeout',
112  'cache_tags',
113  'module',
114  ],
115  ],
117  'hiddenFields' => [
118  'nav_title',
119  'subtitle',
120  'nav_hide',
121  'starttime',
122  'endtime',
123  'extendToSubpages',
124  'fe_group',
125  'fe_login_mode',
126  'abstract',
127  'keywords',
128  'description',
129  'author',
130  'author_email',
131  'layout',
132  'newUntil',
133  'content_from_pid',
134  'cache_timeout',
135  'cache_tags',
136  'content_from_pid',
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  'target',
170  'cache_timeout',
171  'cache_tags',
172  'l18n_cfg',
173  'is_siteroot',
174  'no_search',
175  'php_tree_stop',
176  'module',
177  'media',
178  'tsconfig_includes',
179  'TSconfig',
180  ],
181  ],
183  'hiddenFields' => [
184  'nav_title',
185  'subtitle',
186  'abstract',
187  'keywords',
188  'description',
189  'author',
190  'author_email',
191  'layout',
192  'newUntil',
193  'module',
194  'content_from_pid',
195  'cache_timeout',
196  'cache_tags',
197  'content_from_pid',
198  'target',
199  'cache_timeout',
200  'cache_tags',
201  'l18n_cfg',
202  'is_siteroot',
203  'no_search',
204  'php_tree_stop',
205  'media',
206  ],
207  ],
208  ];
209 
213  public function ‪pagesFormContainsExpectedFieldsDataProvider(): array
214  {
215  $pageTypes = [];
216 
217  foreach (static::$pageFormFields as $doktype => $fieldConfig) {
218  $expectedFields = static::$defaultPageFormFields;
219  $hiddenFields = [];
220  if (array_key_exists('additionalFields', $fieldConfig)) {
221  $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
222  }
223  if (array_key_exists('hiddenFields', $fieldConfig)) {
224  $hiddenFields = $fieldConfig['hiddenFields'];
225  $expectedFields = array_diff($expectedFields, $hiddenFields);
226  }
227  $pageTypes['page doktype ' . $doktype] = [$doktype, $expectedFields, $hiddenFields];
228  }
229 
230  return $pageTypes;
231  }
232 
240  public function ‪pagesFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
241  {
242  $this->setUpBackendUserFromFixture(1);
243  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
244 
245  $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
246  $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]);
247 
248  foreach ($expectedFields as $expectedField) {
249  self::assertNotFalse(
250  $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
251  'The field ' . $expectedField . ' is not in the HTML'
252  );
253  }
254 
255  foreach ($hiddenFields as $hiddenField) {
256  self::assertFalse(
257  $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
258  'The field ' . $hiddenField . ' is in the HTML'
259  );
260  }
261  }
262 }
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest\$defaultPageFormFields
‪static array $defaultPageFormFields
Definition: PagesVisibleFieldsTest.php:30
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_DEFAULT
‪const DOKTYPE_DEFAULT
Definition: PageRepository.php:103
‪TYPO3\CMS\Core\Tests\Functional\Tca
Definition: BackendGroupsVisibleFieldsTest.php:16
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_SHORTCUT
‪const DOKTYPE_SHORTCUT
Definition: PageRepository.php:105
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_LINK
‪const DOKTYPE_LINK
Definition: PageRepository.php:104
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest
Definition: PagesVisibleFieldsTest.php:25
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest\pagesFormContainsExpectedFieldsDataProvider
‪array pagesFormContainsExpectedFieldsDataProvider()
Definition: PagesVisibleFieldsTest.php:211
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest\$pageFormFields
‪static array $pageFormFields
Definition: PagesVisibleFieldsTest.php:70
‪TYPO3\CMS\Core\Tests\Functional\Tca\PagesVisibleFieldsTest\pagesFormContainsExpectedFields
‪pagesFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
Definition: PagesVisibleFieldsTest.php:238
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_MOUNTPOINT
‪const DOKTYPE_MOUNTPOINT
Definition: PageRepository.php:107
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_SPACER
‪const DOKTYPE_SPACER
Definition: PageRepository.php:108
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_BE_USER_SECTION
‪const DOKTYPE_BE_USER_SECTION
Definition: PageRepository.php:106
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_SYSFOLDER
‪const DOKTYPE_SYSFOLDER
Definition: PageRepository.php:109
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService
Definition: FormTestService.php:27
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Domain\Repository\PageRepository
Definition: PageRepository.php:52
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_RECYCLER
‪const DOKTYPE_RECYCLER
Definition: PageRepository.php:110