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