[BUGFIX] Add missing namespace parts
[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\Utility\GeneralUtility;
19 use TYPO3\CMS\Lang\LanguageService;
20
21 class ContentVisibleFieldsTest extends \TYPO3\Components\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 'image_compression',
53 'image_effects',
54 'imageorient',
55 'imagecols',
56 'image_noRows',
57 ];
58
59 protected static $contentFieldsByType = [
60 'header' => [
61 'additionalFields' => ['subheader'],
62 ],
63 'bullets' => [
64 'additionalFields' => ['bodytext'],
65 ],
66 'table' => [
67 'additionalFields' => [
68 'bodytext',
69 'table_delimiter',
70 'table_enclosure',
71 'table_caption',
72 'table_caption',
73 'cols',
74 'table_header_position',
75 'table_tfoot',
76 ],
77 ],
78 'uploads' => [
79 'additionalFields' => [
80 'media',
81 'file_collections',
82 'filelink_sorting',
83 'target',
84 ],
85 ],
86 'menu' => [
87 'additionalFields' => [
88 'menu_type',
89 'pages',
90 'accessibility_title',
91 'accessibility_bypass',
92 'accessibility_bypass_text',
93 ],
94 ],
95 'shortcut' => [
96 'additionalFields' => [
97 'header',
98 'records'
99 ],
100 'disableHeaderFields' => true,
101 ],
102 'list' => [
103 'additionalFields' => [
104 'list_type',
105 'pages',
106 'recursive',
107 ],
108 ],
109 'div' => [
110 'additionalFields' => [
111 'header',
112 ],
113 'disableHeaderFields' => true,
114 ],
115 'html' => [
116 'additionalFields' => [
117 'bodytext',
118 ],
119 'disableHeaderFields' => true,
120 ],
121 ];
122
123 /**
124 * @test
125 */
126 public function contentFormContainsExpectedFields()
127 {
128 $this->setUpBackendUserFromFixture(1);
129 $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
130
131 $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
132
133 foreach (static::$contentFieldsByType as $contentType => $fieldConfig) {
134 $expectedFields = static::$commonContentFields;
135
136 if (empty($fieldConfig['disableHeaderFields'])) {
137 $expectedFields = array_merge($expectedFields, static::$headerFields);
138 }
139
140 if (!empty($fieldConfig['useImageFields'])) {
141 $expectedFields = array_merge($expectedFields, static::$imageFields);
142 }
143
144 if (!empty($fieldConfig['additionalFields'])) {
145 $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
146 }
147
148 $formResult = $formEngineTestService->createNewRecordForm('tt_content', ['CType' => $contentType]);
149 foreach ($expectedFields as $expectedField) {
150 $this->assertNotFalse(
151 $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
152 'The field ' . $expectedField . ' is not in the form HTML'
153 );
154 }
155 }
156 }
157 }