TYPO3 CMS  TYPO3_8-7
ContentVisibleFieldsTest.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 
20 
21 class ContentVisibleFieldsTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
22 {
26  protected $coreExtensionsToLoad = ['css_styled_content'];
27 
31  protected static $commonContentFields = [
32  'CType',
33  'colPos',
34  'sys_language_uid',
35  'layout',
36  'hidden',
37  'sectionIndex',
38  'linkToTop',
39  'starttime',
40  'endtime',
41  'fe_group',
42  'editlock',
43  'rowDescription',
44  'categories',
45  ];
46 
50  protected static $headerFields = [
51  'header',
52  'header_layout',
53  'header_position',
54  'date',
55  'header_link',
56  ];
57 
61  protected static $imageFields = [
62  'image',
63  'image_zoom',
64  'imagewidth',
65  'imageheight',
66  'imageborder',
67  'imageorient',
68  'imagecols',
69  ];
70 
74  protected static $contentFieldsByType = [
75  'header' => [
76  'additionalFields' => ['subheader'],
77  ],
78  'text' => [
79  'additionalFields' => ['bodytext'],
80  ],
81  'textpic' => [
82  'additionalFields' => ['bodytext'],
83  ],
84  'image' => [
85  'useImageFields' => true,
86  ],
87  'bullets' => [
88  'additionalFields' => ['bodytext'],
89  ],
90  'table' => [
91  'additionalFields' => [
92  'cols',
93  'bodytext',
94  ],
95  ],
96  'uploads' => [
97  'additionalFields' => [
98  'media',
99  'file_collections',
100  'filelink_sorting',
101  'target',
102  ],
103  ],
104  'shortcut' => [
105  'additionalFields' => [
106  'header',
107  'records'
108  ],
109  'disableHeaderFields' => true,
110  ],
111  'list' => [
112  'additionalFields' => [
113  'list_type',
114  'pages',
115  'recursive',
116  ],
117  ],
118  'div' => [
119  'additionalFields' => [
120  'header',
121  ],
122  'disableHeaderFields' => true,
123  ],
124  'html' => [
125  'additionalFields' => [
126  'bodytext',
127  ],
128  'disableHeaderFields' => true,
129  ],
130  ];
131 
136  {
137  $this->setUpBackendUserFromFixture(1);
138  $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
139 
140  $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
141 
142  foreach (static::$contentFieldsByType as $contentType => $fieldConfig) {
143  $expectedFields = static::$commonContentFields;
144 
145  if (empty($fieldConfig['disableHeaderFields'])) {
146  $expectedFields = array_merge($expectedFields, static::$headerFields);
147  }
148 
149  if (!empty($fieldConfig['useImageFields'])) {
150  $expectedFields = array_merge($expectedFields, static::$imageFields);
151  }
152 
153  if (!empty($fieldConfig['additionalFields'])) {
154  $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
155  }
156 
157  $formResult = $formEngineTestService->createNewRecordForm('tt_content', ['CType' => $contentType]);
158  foreach ($expectedFields as $expectedField) {
159  $this->assertNotFalse(
160  $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
161  'The field ' . $expectedField . ' is not in the HTML'
162  );
163  }
164  }
165  }
166 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']