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