‪TYPO3CMS  ‪main
SelectCheckBoxTest.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\Test;
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
24 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\ActionService;
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
27 final class ‪SelectCheckBoxTest extends FunctionalTestCase
28 {
29  protected const ‪PAGE_ID = 0;
31 
32  protected function ‪setUp(): void
33  {
34  parent::setUp();
35  $this->importCSVDataSet(__DIR__ . '/../../Fixtures/be_users_admin.csv');
36  $this->backendUserAuthentication = $this->setUpBackendUser(1);
37  ‪$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->createFromUserPreferences($this->backendUserAuthentication);
38  }
39 
40  #[Test]
41  public function ‪validMultipleChecked(): void
42  {
43  $newUserRecord = $this->‪createBackendUser([
44  'file_permissions' => 'readFolder,writeFolder,renameFolder,moveFolder,writeFile,addFile,moveFile,copyFile',
45  ]);
46  self::assertEquals(
47  'readFolder,writeFolder,renameFolder,moveFolder,writeFile,addFile,moveFile,copyFile',
48  $newUserRecord['file_permissions']
49  );
50  }
51 
52  #[Test]
53  public function ‪validNoneCheckedEmptyValuesAllowed(): void
54  {
55  $newUserRecord = $this->‪createBackendUser(['file_permissions' => '']);
56  self::assertEquals('', $newUserRecord['file_permissions']);
57  }
58 
59  protected function ‪createBackendUser(array $backendUser): array
60  {
61  $actionService = new ActionService();
62  $map = $actionService->createNewRecord('be_users', self::PAGE_ID, $backendUser);
63  $newUserId = reset($map['be_users']);
64  return BackendUtility::getRecord('be_users', $newUserId);
65  }
66 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SelectCheckBoxTest\setUp
‪setUp()
Definition: SelectCheckBoxTest.php:32
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SelectCheckBoxTest\PAGE_ID
‪const PAGE_ID
Definition: SelectCheckBoxTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler
Definition: CheckboxValidationTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SelectCheckBoxTest\createBackendUser
‪createBackendUser(array $backendUser)
Definition: SelectCheckBoxTest.php:59
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SelectCheckBoxTest\validNoneCheckedEmptyValuesAllowed
‪validNoneCheckedEmptyValuesAllowed()
Definition: SelectCheckBoxTest.php:53
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SelectCheckBoxTest\validMultipleChecked
‪validMultipleChecked()
Definition: SelectCheckBoxTest.php:41
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SelectCheckBoxTest
Definition: SelectCheckBoxTest.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SelectCheckBoxTest\$backendUserAuthentication
‪BackendUserAuthentication $backendUserAuthentication
Definition: SelectCheckBoxTest.php:30