TYPO3 CMS  TYPO3_8-7
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 
21 class BackendUsersVisibleFieldsTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
22 {
23  protected static $backendUserFields = [
24  'disable',
25  'username',
26  'password',
27  'description',
28  'avatar',
29  'usergroup',
30  'admin',
31  'realName',
32  'email',
33  'lang',
34  'userMods',
35  'allowed_languages',
36  'workspace_perms',
37  'db_mountpoints',
38  'options',
39  'file_mountpoints',
40  'file_permissions',
41  'category_perms',
42  'lockToDomain',
43  'disableIPlock',
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  $this->assertNotFalse(
71  strpos($formResult['html'], '[' . $expectedField . ']'),
72  'The field ' . $expectedField . ' is not in the HTML'
73  );
74  }
75 
76  $this->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  $this->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  $this->assertFalse(
104  $formEngineTestService->formHtmlContainsField($hiddenField, $formResult['html']),
105  'The field ' . $hiddenField . ' is in the HTML'
106  );
107  }
108 
109  $this->assertNotFalse(
110  strpos($formResult['html'], 'Last login'),
111  'The field lastlogin is not in the HTML'
112  );
113  }
114 }
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']