‪TYPO3CMS  ‪main
PagesLanguageOverlayVisibleFieldsTest.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\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
26 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
27 
28 final class ‪PagesLanguageOverlayVisibleFieldsTest extends FunctionalTestCase
29 {
33  protected static array ‪$defaultPagesLanguageOverlayFields = [
34  'title',
35  'nav_title',
36  'subtitle',
37  'hidden',
38  'starttime',
39  'endtime',
40  'abstract',
41  'keywords',
42  'description',
43  'author',
44  'author_email',
45  'media',
46  ];
47 
51  protected static array ‪$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  'abstract',
109  'keywords',
110  'description',
111  'author',
112  'author_email',
113  'media',
114  ],
115  ],
116  ];
117 
119  {
120  $pageTypes = [];
121 
122  foreach (static::$pageFormFields as $doktype => $fieldConfig) {
123  $expectedFields = static::$defaultPagesLanguageOverlayFields;
124  $hiddenFields = [];
125  if (array_key_exists('additionalFields', $fieldConfig)) {
126  $expectedFields = array_merge($expectedFields, $fieldConfig['additionalFields']);
127  }
128  if (array_key_exists('hiddenFields', $fieldConfig)) {
129  $hiddenFields = $fieldConfig['hiddenFields'];
130  $expectedFields = array_diff($expectedFields, $hiddenFields);
131  }
132  $pageTypes['page doktype ' . $doktype] = [$doktype, $expectedFields, $hiddenFields];
133  }
134 
135  return $pageTypes;
136  }
137 
138  #[DataProvider('pagesLanguageOverlayFormContainsExpectedFieldsDataProvider')]
139  #[Test]
140  public function ‪pagesLanguageOverlayFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields): void
141  {
142  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
143  $this->setUpBackendUser(1);
144  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
145 
146  $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
147  $formResult = $formEngineTestService->createNewRecordForm('pages', ['doktype' => $doktype]);
148 
149  foreach ($expectedFields as $expectedField) {
150  self::assertNotFalse(
151  $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
152  'The field ' . $expectedField . ' is not in the form HTML'
153  );
154  }
155 
156  foreach ($hiddenFields as $hiddenField) {
157  self::assertFalse(
158  $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
159  'The field ' . $hiddenField . ' is in the form HTML'
160  );
161  }
162  }
163 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest\$pageFormFields
‪static array $pageFormFields
Definition: PagesLanguageOverlayVisibleFieldsTest.php:51
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_DEFAULT
‪const DOKTYPE_DEFAULT
Definition: PageRepository.php:98
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_SHORTCUT
‪const DOKTYPE_SHORTCUT
Definition: PageRepository.php:100
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_LINK
‪const DOKTYPE_LINK
Definition: PageRepository.php:99
‪TYPO3\CMS\Frontend\Tests\Functional\Tca
Definition: BackendLayoutVisibleFieldsTest.php:18
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest\$defaultPagesLanguageOverlayFields
‪static array $defaultPagesLanguageOverlayFields
Definition: PagesLanguageOverlayVisibleFieldsTest.php:33
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_MOUNTPOINT
‪const DOKTYPE_MOUNTPOINT
Definition: PageRepository.php:102
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_SPACER
‪const DOKTYPE_SPACER
Definition: PageRepository.php:103
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_BE_USER_SECTION
‪const DOKTYPE_BE_USER_SECTION
Definition: PageRepository.php:101
‪TYPO3\CMS\Core\Domain\Repository\PageRepository\DOKTYPE_SYSFOLDER
‪const DOKTYPE_SYSFOLDER
Definition: PageRepository.php:104
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest
Definition: PagesLanguageOverlayVisibleFieldsTest.php:29
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest\pagesLanguageOverlayFormContainsExpectedFieldsDataProvider
‪static pagesLanguageOverlayFormContainsExpectedFieldsDataProvider()
Definition: PagesLanguageOverlayVisibleFieldsTest.php:118
‪TYPO3\CMS\Backend\Tests\Functional\Form\FormTestService
Definition: FormTestService.php:32
‪TYPO3\CMS\Core\Domain\Repository\PageRepository
Definition: PageRepository.php:69
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Frontend\Tests\Functional\Tca\PagesLanguageOverlayVisibleFieldsTest\pagesLanguageOverlayFormContainsExpectedFields
‪pagesLanguageOverlayFormContainsExpectedFields(int $doktype, array $expectedFields, array $hiddenFields)
Definition: PagesLanguageOverlayVisibleFieldsTest.php:140