‪TYPO3CMS  10.4
ContentVisibleFieldsTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
23 class ‪ContentVisibleFieldsTest extends FunctionalTestCase
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  'date',
45  'header_link',
46  ];
47 
48  protected static ‪$imageFields = [
49  'image',
50  'image_zoom',
51  'imagewidth',
52  'imageheight',
53  'imageborder',
54  'imageorient',
55  'imagecols',
56  ];
57 
58  protected static ‪$contentFieldsByType = [
59  'header' => [
60  'additionalFields' => ['subheader'],
61  ],
62  'bullets' => [
63  'additionalFields' => ['bodytext'],
64  ],
65  'table' => [
66  'additionalFields' => [
67  'bodytext',
68  'table_delimiter',
69  'table_enclosure',
70  'table_caption',
71  'table_caption',
72  'cols',
73  'table_header_position',
74  'table_tfoot',
75  ],
76  ],
77  'uploads' => [
78  'additionalFields' => [
79  'media',
80  'file_collections',
81  'filelink_sorting',
82  'target',
83  ],
84  ],
85  'shortcut' => [
86  'additionalFields' => [
87  'header',
88  'records'
89  ],
90  'disableHeaderFields' => true,
91  ],
92  'list' => [
93  'additionalFields' => [
94  'list_type',
95  'pages',
96  'recursive',
97  ],
98  ],
99  'div' => [
100  'additionalFields' => [
101  'header',
102  ],
103  'disableHeaderFields' => true,
104  ],
105  'html' => [
106  'additionalFields' => [
107  'bodytext',
108  ],
109  'disableHeaderFields' => true,
110  ],
111  ];
112 
117  {
118  $this->setUpBackendUserFromFixture(1);
119  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
120 
121  $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
122 
123  foreach (static::$contentFieldsByType as $contentType => $fieldConfig) {
124  $expectedFields = static::$commonContentFields;
125 
126  if (empty($fieldConfig['disableHeaderFields'])) {
127  $expectedFields = array_merge($expectedFields, static::$headerFields);
128  }
129 
130  if (!empty($fieldConfig['useImageFields'])) {
131  $expectedFields = array_merge($expectedFields, static::$imageFields);
132  }
133 
134  if (!empty($fieldConfig['additionalFields'])) {
135  $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
136  }
137 
138  $formResult = $formEngineTestService->createNewRecordForm('tt_content', ['CType' => $contentType]);
139  foreach ($expectedFields as $expectedField) {
140  self::assertNotFalse(
141  $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
142  'The field ' . $expectedField . ' is not in the form HTML'
143  );
144  }
145  }
146  }
147 }
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\$imageFields
‪static $imageFields
Definition: ContentVisibleFieldsTest.php:48
‪TYPO3\CMS\Frontend\Tests\Functional\Tca
Definition: BackendLayoutVisibleFieldsTest.php:16
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\$headerFields
‪static $headerFields
Definition: ContentVisibleFieldsTest.php:41
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\$commonContentFields
‪static $commonContentFields
Definition: ContentVisibleFieldsTest.php:25
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\$contentFieldsByType
‪static $contentFieldsByType
Definition: ContentVisibleFieldsTest.php:58
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService
Definition: FormTestService.php:27
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest
Definition: ContentVisibleFieldsTest.php:24
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\contentFormContainsExpectedFields
‪contentFormContainsExpectedFields()
Definition: ContentVisibleFieldsTest.php:116
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46