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