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