‪TYPO3CMS  ‪main
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 
20 use PHPUnit\Framework\Attributes\Test;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 final class ‪ContentVisibleFieldsTest extends FunctionalTestCase
27 {
28  protected static array ‪$commonContentFields = [
29  'CType',
30  'colPos',
31  'sys_language_uid',
32  'layout',
33  'hidden',
34  'sectionIndex',
35  'linkToTop',
36  'starttime',
37  'endtime',
38  'fe_group',
39  'editlock',
40  'rowDescription',
41  'categories',
42  ];
43 
44  protected static array ‪$headerFields = [
45  'header',
46  'header_layout',
47  'date',
48  'header_link',
49  ];
50 
51  protected static array ‪$imageFields = [
52  'image',
53  'image_zoom',
54  'imagewidth',
55  'imageheight',
56  'imageborder',
57  'imageorient',
58  'imagecols',
59  ];
60 
61  protected static array ‪$contentFieldsByType = [
62  'header' => [
63  'additionalFields' => ['subheader'],
64  ],
65  'bullets' => [
66  'additionalFields' => ['bodytext'],
67  ],
68  'table' => [
69  'additionalFields' => [
70  'bodytext',
71  'table_delimiter',
72  'table_enclosure',
73  'table_caption',
74  'table_caption',
75  'cols',
76  'table_header_position',
77  'table_tfoot',
78  ],
79  ],
80  'uploads' => [
81  'additionalFields' => [
82  'media',
83  'file_collections',
84  'filelink_sorting',
85  'target',
86  ],
87  ],
88  'shortcut' => [
89  'additionalFields' => [
90  'header',
91  'records',
92  ],
93  'disableHeaderFields' => true,
94  ],
95  'list' => [
96  'additionalFields' => [
97  'list_type',
98  'pages',
99  'recursive',
100  ],
101  ],
102  'div' => [
103  'additionalFields' => [
104  'header',
105  ],
106  'disableHeaderFields' => true,
107  ],
108  'html' => [
109  'additionalFields' => [
110  'bodytext',
111  ],
112  'disableHeaderFields' => true,
113  ],
114  ];
115 
116  #[Test]
117  public function ‪contentFormContainsExpectedFields(): void
118  {
119  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
120  $this->setUpBackendUser(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:51
‪TYPO3\CMS\Frontend\Tests\Functional\Tca
Definition: BackendLayoutVisibleFieldsTest.php:18
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\$headerFields
‪static array $headerFields
Definition: ContentVisibleFieldsTest.php:44
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService
Definition: FormTestService.php:32
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\$contentFieldsByType
‪static array $contentFieldsByType
Definition: ContentVisibleFieldsTest.php:61
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest
Definition: ContentVisibleFieldsTest.php:27
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\$commonContentFields
‪static array $commonContentFields
Definition: ContentVisibleFieldsTest.php:28
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\ContentVisibleFieldsTest\contentFormContainsExpectedFields
‪contentFormContainsExpectedFields()
Definition: ContentVisibleFieldsTest.php:117
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52