‪TYPO3CMS  9.5
PagesTsConfigGuardTest.php
Go to the documentation of this file.
1 <?php
2 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 
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
27 class ‪PagesTsConfigGuardTest extends FunctionalTestCase
28 {
32  private ‪$scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Regular/DataSet/';
33 
37  private ‪$assertionDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Regular/Hooks/DataSet/';
38 
44  protected ‪$backendUserFixture = 'typo3/sysext/core/Tests/Functional/Fixtures/be_users.xml';
45 
46  protected function ‪setUp(): void
47  {
48  parent::setUp();
50  $this->‪importScenarioDataSet('LiveDefaultPages');
51  $this->importDataSet(dirname($this->backendUserFixture) . '/be_groups.xml');
52  // define page create permissions for backend user group 9 on page 1
53  GeneralUtility::makeInstance(ConnectionPool::class)
54  ->getConnectionForTable('pages')
55  ->update(
56  'pages',
57  ['perms_groupid' => 9, 'perms_group' => ‪Permission::ALL],
58  ['uid' => 1]
59  );
60  }
61 
66  {
67  $backendUser = $this->setUpBackendUserFromFixture(1);
68  $identifier = ‪StringUtility::getUniqueId('NEW');
69 
70  $dataMap = [
71  'pages' => [
72  $identifier => [
73  'pid' => 1,
74  'title' => 'New page',
75  'TSconfig' => 'custom.setting = 1',
76  'tsconfig_includes' => 'EXT:package/file.tsconfig',
77  ],
78  ],
79  ];
80 
81  $this->‪assertProcessedDataMap($dataMap, $backendUser);
82  $this->‪assertAssertionDataSet('pagesTsConfigIsConsideredForAdminUser');
83  }
84 
89  {
90  $backendUser = $this->setUpBackendUserFromFixture(9);
91  $identifier = ‪StringUtility::getUniqueId('NEW');
92 
93  $dataMap = [
94  'pages' => [
95  $identifier => [
96  'pid' => 1,
97  'title' => 'New page',
98  'TSconfig' => 'custom.setting = 1',
99  'tsconfig_includes' => 'EXT:package/file.tsconfig',
100  ],
101  ],
102  ];
103 
104  $this->‪assertProcessedDataMap($dataMap, $backendUser);
105  $this->‪assertAssertionDataSet('pagesTsConfigIsIgnoredForNonAdminUser');
106  }
107 
111  private function ‪importScenarioDataSet($dataSetName): void
112  {
113  $fileName = rtrim($this->scenarioDataSetDirectory, '/') . '/' . $dataSetName . '.csv';
114  $fileName = GeneralUtility::getFileAbsFileName($fileName);
115  $this->importCSVDataSet($fileName);
116  }
117 
118  private function ‪assertAssertionDataSet($dataSetName): void
119  {
120  $fileName = rtrim($this->assertionDataSetDirectory, '/') . '/' . $dataSetName . '.csv';
121  $fileName = GeneralUtility::getFileAbsFileName($fileName);
122  $this->assertCSVDataSet($fileName);
123  }
124 
125  private function ‪assertProcessedDataMap(array $dataMap, ‪BackendUserAuthentication $backendUser)
126  {
127  $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
128  $dataHandler->start($dataMap, [], $backendUser);
129  $dataHandler->process_datamap();
130  static::assertEmpty($dataHandler->errorLog);
131  }
132 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:81
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\setUp
‪setUp()
Definition: PagesTsConfigGuardTest.php:43
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\$backendUserFixture
‪string $backendUserFixture
Definition: PagesTsConfigGuardTest.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\pagesTsConfigIsConsideredForAdminUser
‪pagesTsConfigIsConsideredForAdminUser()
Definition: PagesTsConfigGuardTest.php:62
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: PagesTsConfigGuardTest.php:108
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\assertProcessedDataMap
‪assertProcessedDataMap(array $dataMap, BackendUserAuthentication $backendUser)
Definition: PagesTsConfigGuardTest.php:122
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest
Definition: PagesTsConfigGuardTest.php:28
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:23
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\$assertionDataSetDirectory
‪string $assertionDataSetDirectory
Definition: PagesTsConfigGuardTest.php:35
‪TYPO3\CMS\Core\Type\Bitmask\Permission\ALL
‪const ALL
Definition: Permission.php:57
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: PagesTsConfigGuardTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks
Definition: PagesTsConfigGuardTest.php:3
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:91
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\pagesTsConfigIsIgnoredForNonAdminUser
‪pagesTsConfigIsIgnoredForNonAdminUser()
Definition: PagesTsConfigGuardTest.php:85
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:50
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Regular\Hooks\PagesTsConfigGuardTest\assertAssertionDataSet
‪assertAssertionDataSet($dataSetName)
Definition: PagesTsConfigGuardTest.php:115
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:21
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static Bootstrap null initializeLanguageObject()
Definition: Bootstrap.php:986