‪TYPO3CMS  11.5
BackendUsersVisibleFieldsTest.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 ‪BackendUsersVisibleFieldsTest extends FunctionalTestCase
26 {
27  protected static ‪$backendUserFields = [
28  'disable',
29  'username',
30  'password',
31  'description',
32  'avatar',
33  'usergroup',
34  'admin',
35  'realName',
36  'email',
37  'lang',
38  'userMods',
39  'allowed_languages',
40  'db_mountpoints',
41  'options',
42  'file_mountpoints',
43  'file_permissions',
44  'category_perms',
45  'TSconfig',
46  'starttime',
47  'endtime',
48  ];
49 
50  protected static ‪$adminHiddenFields = [
51  'userMods',
52  'allowed_languages',
53  'workspace_perms',
54  'file_permissions',
55  'category_perms',
56  ];
57 
58  protected static ‪$specialFields = [
59  'mfa' => 'Multi-factor authentication',
60  'lastlogin' => 'Last login',
61  ];
62 
67  {
68  $this->setUpBackendUserFromFixture(1);
69  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
70 
71  $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
72  $formResult = $formEngineTestService->createNewRecordForm('be_users');
73 
74  foreach (static::$backendUserFields as $expectedField) {
75  self::assertNotFalse(
76  $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
77  'The field ' . $expectedField . ' is not in the HTML'
78  );
79  }
80 
81  foreach (static::$specialFields as $fieldName => $searchString) {
82  self::assertNotFalse(
83  strpos($formResult['html'], $searchString),
84  'The field ' . $fieldName . ' is not in the HTML'
85  );
86  }
87  }
88 
93  {
94  $this->setUpBackendUserFromFixture(1);
95  ‪$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
96 
97  $formEngineTestService = GeneralUtility::makeInstance(FormTestService::class);
98  $formResult = $formEngineTestService->createNewRecordForm('be_users', ['admin' => true]);
99 
100  $expectedFields = array_diff(static::$backendUserFields, static::$adminHiddenFields);
101 
102  foreach ($expectedFields as $expectedField) {
103  self::assertNotFalse(
104  $formEngineTestService->formHtmlContainsField($expectedField, $formResult['html']),
105  'The field ' . $expectedField . ' is not in the HTML'
106  );
107  }
108 
109  foreach (static::$adminHiddenFields as $hiddenField) {
110  self::assertFalse(
111  $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
112  'The field ' . $hiddenField . ' is in the HTML'
113  );
114  }
115 
116  foreach (static::$specialFields as $fieldName => $searchString) {
117  self::assertNotFalse(
118  strpos($formResult['html'], $searchString),
119  'The field ' . $fieldName . ' is not in the HTML'
120  );
121  }
122  }
123 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Core\Tests\Functional\Tca\BackendUsersVisibleFieldsTest
Definition: BackendUsersVisibleFieldsTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\Tca\BackendUsersVisibleFieldsTest\$backendUserFields
‪static $backendUserFields
Definition: BackendUsersVisibleFieldsTest.php:27
‪TYPO3\CMS\Core\Tests\Functional\Tca
Definition: BackendGroupsVisibleFieldsTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\Tca\BackendUsersVisibleFieldsTest\backendUsersFormContainsExpectedFields
‪backendUsersFormContainsExpectedFields()
Definition: BackendUsersVisibleFieldsTest.php:66
‪$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\Core\Tests\Functional\Tca\BackendUsersVisibleFieldsTest\$specialFields
‪static $specialFields
Definition: BackendUsersVisibleFieldsTest.php:58
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Tests\Functional\Tca\BackendUsersVisibleFieldsTest\$adminHiddenFields
‪static $adminHiddenFields
Definition: BackendUsersVisibleFieldsTest.php:50
‪TYPO3\CMS\Core\Tests\Functional\Tca\BackendUsersVisibleFieldsTest\backendUsersFormContainsExpectedFieldsForAdmins
‪backendUsersFormContainsExpectedFieldsForAdmins()
Definition: BackendUsersVisibleFieldsTest.php:92