Revert "[TASK] Avoid slow array functions in loops"
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Functional / Tca / ContentVisibleFieldsTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\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\Localization\LanguageService;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21 class ContentVisibleFieldsTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
22 {
23 protected static $commonContentFields = [
24 'CType',
25 'colPos',
26 'sys_language_uid',
27 'layout',
28 'hidden',
29 'sectionIndex',
30 'linkToTop',
31 'starttime',
32 'endtime',
33 'fe_group',
34 'editlock',
35 'rowDescription',
36 'categories',
37 ];
38
39 protected static $headerFields = [
40 'header',
41 'header_layout',
42 'date',
43 'header_link',
44 ];
45
46 protected static $imageFields = [
47 'image',
48 'image_zoom',
49 'imagewidth',
50 'imageheight',
51 'imageborder',
52 'imageorient',
53 'imagecols',
54 ];
55
56 protected static $contentFieldsByType = [
57 'header' => [
58 'additionalFields' => ['subheader'],
59 ],
60 'bullets' => [
61 'additionalFields' => ['bodytext'],
62 ],
63 'table' => [
64 'additionalFields' => [
65 'bodytext',
66 'table_delimiter',
67 'table_enclosure',
68 'table_caption',
69 'table_caption',
70 'cols',
71 'table_header_position',
72 'table_tfoot',
73 ],
74 ],
75 'uploads' => [
76 'additionalFields' => [
77 'media',
78 'file_collections',
79 'filelink_sorting',
80 'target',
81 ],
82 ],
83 'shortcut' => [
84 'additionalFields' => [
85 'header',
86 'records'
87 ],
88 'disableHeaderFields' => true,
89 ],
90 'list' => [
91 'additionalFields' => [
92 'list_type',
93 'pages',
94 'recursive',
95 ],
96 ],
97 'div' => [
98 'additionalFields' => [
99 'header',
100 ],
101 'disableHeaderFields' => true,
102 ],
103 'html' => [
104 'additionalFields' => [
105 'bodytext',
106 ],
107 'disableHeaderFields' => true,
108 ],
109 ];
110
111 /**
112 * @test
113 */
114 public function contentFormContainsExpectedFields()
115 {
116 $this->setUpBackendUserFromFixture(1);
117 $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
118
119 $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
120
121 foreach (static::$contentFieldsByType as $contentType => $fieldConfig) {
122 $expectedFields = static::$commonContentFields;
123
124 if (empty($fieldConfig['disableHeaderFields'])) {
125 $expectedFields = array_merge($expectedFields, static::$headerFields);
126 }
127
128 if (!empty($fieldConfig['useImageFields'])) {
129 $expectedFields = array_merge($expectedFields, static::$imageFields);
130 }
131
132 if (!empty($fieldConfig['additionalFields'])) {
133 $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
134 }
135
136 $formResult = $formEngineTestService->createNewRecordForm('tt_content', ['CType' => $contentType]);
137 foreach ($expectedFields as $expectedField) {
138 $this->assertNotFalse(
139 $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
140 'The field ' . $expectedField . ' is not in the form HTML'
141 );
142 }
143 }
144 }
145 }