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