[!!!][TASK] Remove DB field pages.no_cache
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Functional / Tca / PagesLanguageOverlayVisibleFieldsTest.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 PagesLanguageOverlayVisibleFieldsTest 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 $defaultPagesLanguageOverlayFields = [
30 'title',
31 'nav_title',
32 'subtitle',
33 'hidden',
34 'starttime',
35 'endtime',
36 'abstract',
37 'keywords',
38 'description',
39 'author',
40 'author_email',
41 'media',
42 ];
43
44 /**
45 * Configuration of hidden / additional form fields per page type.
46 *
47 * @var array
48 */
49 protected static $pageFormFields = [
50 PageRepository::DOKTYPE_BE_USER_SECTION => [],
51 PageRepository::DOKTYPE_DEFAULT => [],
52 PageRepository::DOKTYPE_SHORTCUT => [
53 'additionalFields' => [
54 'shortcut_mode',
55 'shortcut',
56 ],
57 'hiddenFields' => [
58 'keywords',
59 'description',
60 'content_from_pid',
61 'cache_timeout',
62 'cache_tags',
63 'module',
64 ],
65 ],
66 PageRepository::DOKTYPE_MOUNTPOINT => [
67 'hiddenFields' => [
68 'keywords',
69 'description',
70 'content_from_pid',
71 'cache_timeout',
72 'cache_tags',
73 'module',
74 ],
75 ],
76 PageRepository::DOKTYPE_LINK => [
77 'additionalFields' => [
78 'url',
79 ],
80 'hiddenFields' => [
81 'keywords',
82 'description',
83 'content_from_pid',
84 'cache_timeout',
85 'cache_tags',
86 'module',
87 ],
88 ],
89 PageRepository::DOKTYPE_SYSFOLDER => [
90 'hiddenFields' => [
91 'nav_title',
92 'subtitle',
93 'starttime',
94 'endtime',
95 'abstract',
96 'keywords',
97 'description',
98 'author',
99 'author_email',
100 ],
101 ],
102 PageRepository::DOKTYPE_RECYCLER => [
103 'hiddenFields' => [
104 'nav_title',
105 'subtitle',
106 'starttime',
107 'endtime',
108 'abstract',
109 'keywords',
110 'description',
111 'author',
112 'author_email',
113 'media',
114 ],
115 ],
116 PageRepository::DOKTYPE_SPACER => [
117 'hiddenFields' => [
118 'nav_title',
119 'subtitle',
120 'abstract',
121 'keywords',
122 'description',
123 'author',
124 'author_email',
125 'media',
126 ],
127 ],
128 ];
129
130 /**
131 * @return array
132 */
133 public function pagesLanguageOverlayFormContainsExpectedFieldsDataProvider(): array
134 {
135 $pageTypes = [];
136
137 foreach (static::$pageFormFields as $doktype => $fieldConfig) {
138 $expectedFields = static::$defaultPagesLanguageOverlayFields;
139 $hiddenFields = [];
140 if (array_key_exists('additionalFields', $fieldConfig)) {
141 $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
142 }
143 if (array_key_exists('hiddenFields', $fieldConfig)) {
144 $hiddenFields = $fieldConfig['hiddenFields'];
145 $expectedFields = array_diff($expectedFields, $hiddenFields);
146 }
147 $pageTypes['page doktype ' . $doktype] = [$doktype, $expectedFields, $hiddenFields];
148 }
149
150 return $pageTypes;
151 }
152
153 /**
154 * @test
155 * @dataProvider pagesLanguageOverlayFormContainsExpectedFieldsDataProvider
156 * @param int $doktype
157 * @param array $expectedFields
158 * @param array $hiddenFields
159 */
160 public function pagesLanguageOverlayFormContainsExpectedFields(
161 int $doktype,
162 array $expectedFields,
163 array $hiddenFields
164 ) {
165 $this->setUpBackendUserFromFixture(1);
166 $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
167
168 $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
169 $formResult = $formEngineTestService->createNewRecordForm('pages_language_overlay', ['doktype' => $doktype]);
170
171 foreach ($expectedFields as $expectedField) {
172 $this->assertNotFalse(
173 $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
174 'The field ' . $expectedField . ' is not in the form HTML'
175 );
176 }
177
178 foreach ($hiddenFields as $hiddenField) {
179 $this->assertFalse(
180 $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
181 'The field ' . $hiddenField . ' is in the form HTML'
182 );
183 }
184 }
185 }