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