‪TYPO3CMS  10.4
PagePermissionTest.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 
26 {
30  protected ‪$scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Regular/DataSet/';
31 
32  protected function ‪setUp(): void
33  {
34  parent::setUp();
35  $this->‪importScenarioDataSet('LiveDefaultPages');
36  }
37 
42  {
43  $this->backendUser->user['uid'] = 13;
44  $this->backendUser->firstMainGroup = 14;
45  ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPermissions'] = [
46  'user' => 'show,editcontent,edit,delete',
47  'group' => 'show,editcontent,new',
48  'everybody' => 'show'
49  ];
50  $record = $this->‪insertPage();
51  self::assertEquals(13, $record['perms_userid']);
52  self::assertEquals(14, $record['perms_groupid']);
54  self::assertEquals(‪Permission::PAGE_SHOW + ‪Permission::CONTENT_EDIT + ‪Permission::PAGE_NEW, $record['perms_group']);
55  self::assertEquals(‪Permission::PAGE_SHOW, $record['perms_everybody']);
56  }
57 
62  {
63  $this->backendUser->user['uid'] = 13;
64  $this->backendUser->firstMainGroup = 14;
65  ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPermissions'] = [
66  'user' => 'show,editcontent,edit,delete',
67  'group' => 'show,editcontent,new',
68  'everybody' => 'show'
69  ];
70  ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] = '
71 TCEMAIN.permissions.userid = 12
72 TCEMAIN.permissions.groupid = 42
73 TCEMAIN.permissions.user = show,edit
74 TCEMAIN.permissions.group = show,delete
75 TCEMAIN.permissions.everybody = show,delete
76 ';
77  $record = $this->‪insertPage();
78  self::assertEquals(12, $record['perms_userid']);
79  self::assertEquals(42, $record['perms_groupid']);
80  self::assertEquals(‪Permission::PAGE_SHOW + ‪Permission::PAGE_EDIT, $record['perms_user']);
81  self::assertEquals(‪Permission::PAGE_SHOW + ‪Permission::PAGE_DELETE, $record['perms_group']);
82  self::assertEquals(‪Permission::PAGE_SHOW + ‪Permission::PAGE_DELETE, $record['perms_everybody']);
83  }
84 
88  protected function ‪insertPage()
89  {
90  // pid 88 comes from LiveDefaultPages
91  $result = $this->actionService->createNewRecord('pages', 88, [
92  'title' => 'Test page'
93  ]);
94  $recordUid = $result['pages'][0];
95  return ‪BackendUtility::getRecord('pages', $recordUid);
96  }
97 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\PagePermissionTest\setUp
‪setUp()
Definition: PagePermissionTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\PagePermissionTest\insertPage
‪array insertPage()
Definition: PagePermissionTest.php:87
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_NEW
‪const PAGE_NEW
Definition: Permission.php:48
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\PagePermissionTest\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: PagePermissionTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\PagePermissionTest
Definition: PagePermissionTest.php:26
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:33
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular
Definition: AbstractActionTestCase.php:16
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:95
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\PagePermissionTest\newPageReceivesOverriddenPageTsPermissionSet
‪newPageReceivesOverriddenPageTsPermissionSet()
Definition: PagePermissionTest.php:60
‪TYPO3\CMS\Core\Type\Bitmask\Permission\CONTENT_EDIT
‪const CONTENT_EDIT
Definition: Permission.php:53
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_EDIT
‪const PAGE_EDIT
Definition: Permission.php:38
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_DELETE
‪const PAGE_DELETE
Definition: Permission.php:43
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:201
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\PagePermissionTest\newPageReceivesDefaultPermissionSet
‪newPageReceivesDefaultPermissionSet()
Definition: PagePermissionTest.php:40