‪TYPO3CMS  9.5
PagesLanguageOverlayVisibleFieldsTest.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 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
23 class ‪PagesLanguageOverlayVisibleFieldsTest extends FunctionalTestCase
24 {
30  protected static ‪$defaultPagesLanguageOverlayFields = [
31  'title',
32  'nav_title',
33  'subtitle',
34  'hidden',
35  'starttime',
36  'endtime',
37  'abstract',
38  'keywords',
39  'description',
40  'author',
41  'author_email',
42  'media',
43  ];
44 
50  protected static ‪$pageFormFields = [
54  'additionalFields' => [
55  'shortcut_mode',
56  'shortcut',
57  ],
58  'hiddenFields' => [
59  'keywords',
60  'description',
61  'content_from_pid',
62  'cache_timeout',
63  'cache_tags',
64  'module',
65  ],
66  ],
68  'hiddenFields' => [
69  'keywords',
70  'description',
71  'content_from_pid',
72  'cache_timeout',
73  'cache_tags',
74  'module',
75  ],
76  ],
78  'additionalFields' => [
79  'url',
80  ],
81  'hiddenFields' => [
82  'keywords',
83  'description',
84  'content_from_pid',
85  'cache_timeout',
86  'cache_tags',
87  'module',
88  ],
89  ],
91  'hiddenFields' => [
92  'nav_title',
93  'subtitle',
94  'starttime',
95  'endtime',
96  'abstract',
97  'keywords',
98  'description',
99  'author',
100  'author_email',
101  ],
102  ],
104  'hiddenFields' => [
105  'nav_title',
106  'subtitle',
107  'starttime',
108  'endtime',
109  'abstract',
110  'keywords',
111  'description',
112  'author',
113  'author_email',
114  'media',
115  ],
116  ],
118  'hiddenFields' => [
119  'nav_title',
120  'subtitle',
121  'abstract',
122  'keywords',
123  'description',
124  'author',
125  'author_email',
126  'media',
127  ],
128  ],
129  ];
130 
135  {
136  $pageTypes = [];
137 
138  foreach (static::$pageFormFields as $doktype => $fieldConfig) {
139  $expectedFields = static::$defaultPagesLanguageOverlayFields;
140  $hiddenFields = [];
141  if (array_key_exists('additionalFields', $fieldConfig)) {
142  $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
143  }
144  if (array_key_exists('hiddenFields', $fieldConfig)) {
145  $hiddenFields = $fieldConfig['hiddenFields'];
146  $expectedFields = array_diff($expectedFields, $hiddenFields);
147  }
148  $pageTypes['page doktype ' . $doktype] = [$doktype, $expectedFields, $hiddenFields];
149  }
150 
151  return $pageTypes;
152  }
153 
162  int $doktype,
163  array $expectedFields,
164  array $hiddenFields
165  ) {
166  $this->setUpBackendUserFromFixture(1);
167  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
168 
169  $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
170  $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]);
171 
172  foreach ($expectedFields as $expectedField) {
173  $this->assertNotFalse(
174  $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
175  'The field ' . $expectedField . ' is not in the form HTML'
176  );
177  }
178 
179  foreach ($hiddenFields as $hiddenField) {
180  $this->assertFalse(
181  $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
182  'The field ' . $hiddenField . ' is in the form HTML'
183  );
184  }
185  }
186 }
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_MOUNTPOINT
‪const DOKTYPE_MOUNTPOINT
Definition: PageRepository.php:172
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest\$pageFormFields
‪static array $pageFormFields
Definition: PagesLanguageOverlayVisibleFieldsTest.php:48
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest\pagesLanguageOverlayFormContainsExpectedFieldsDataProvider
‪array pagesLanguageOverlayFormContainsExpectedFieldsDataProvider()
Definition: PagesLanguageOverlayVisibleFieldsTest.php:132
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_SHORTCUT
‪const DOKTYPE_SHORTCUT
Definition: PageRepository.php:170
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_SPACER
‪const DOKTYPE_SPACER
Definition: PageRepository.php:173
‪TYPO3\CMS\Frontend\Tests\Functional\Tca
Definition: BackendLayoutVisibleFieldsTest.php:2
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest\$defaultPagesLanguageOverlayFields
‪static array $defaultPagesLanguageOverlayFields
Definition: PagesLanguageOverlayVisibleFieldsTest.php:29
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_LINK
‪const DOKTYPE_LINK
Definition: PageRepository.php:169
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_SYSFOLDER
‪const DOKTYPE_SYSFOLDER
Definition: PageRepository.php:174
‪TYPO3\CMS\Frontend\Page\PageRepository
Definition: PageRepository.php:53
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_DEFAULT
‪const DOKTYPE_DEFAULT
Definition: PageRepository.php:168
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest
Definition: PagesLanguageOverlayVisibleFieldsTest.php:24
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService
Definition: FormTestService.php:26
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_RECYCLER
‪const DOKTYPE_RECYCLER
Definition: PageRepository.php:175
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest\pagesLanguageOverlayFormContainsExpectedFields
‪pagesLanguageOverlayFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
Definition: PagesLanguageOverlayVisibleFieldsTest.php:159
‪TYPO3\CMS\Frontend\Page\PageRepository\DOKTYPE_BE_USER_SECTION
‪const DOKTYPE_BE_USER_SECTION
Definition: PageRepository.php:171