‪TYPO3CMS  11.5
BackendConfigurationManagerTest.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 
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
30 class ‪BackendConfigurationManagerTest extends FunctionalTestCase
31 {
38  {
39  $backendConfigurationManager = $this->getAccessibleMock(BackendConfigurationManager::class, ['getTypoScriptSetup'], [], '', false);
40  $mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock();
41  $backendConfigurationManager->_set('typoScriptService', $mockTypoScriptService);
42 
43  (new ‪ConnectionPool())->getConnectionForTable('sys_template')->insert(
44  'sys_template',
45  [
46  'pid' => 123,
47  'deleted' => 0,
48  'hidden' => 0,
49  'root' => 1,
50  ]
51  );
52 
53  $actualResult = $backendConfigurationManager->_call('getCurrentPageId');
54  self::assertEquals(123, $actualResult);
55  }
56 
63  {
64  $backendConfigurationManager = $this->getAccessibleMock(BackendConfigurationManager::class, ['getTypoScriptSetup'], [], '', false);
65  $mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock();
66  $backendConfigurationManager->_set('typoScriptService', $mockTypoScriptService);
67 
68  (new ‪ConnectionPool())->getConnectionForTable('pages')->insert(
69  'pages',
70  [
71  'deleted' => 0,
72  'hidden' => 0,
73  'is_siteroot' => 1,
74  ]
75  );
76 
77  $actualResult = $backendConfigurationManager->_call('getCurrentPageId');
78  self::assertEquals(1, $actualResult);
79  }
80 
87  {
88  $backendConfigurationManager = $this->getAccessibleMock(BackendConfigurationManager::class, ['getTypoScriptSetup'], [], '', false);
89  $mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock();
90  $backendConfigurationManager->_set('typoScriptService', $mockTypoScriptService);
91 
93  $actualResult = $backendConfigurationManager->_call('getCurrentPageId');
94  self::assertEquals($expectedResult, $actualResult);
95  }
96 
101  {
102  $this->importCSVDataSet(__DIR__ . '/Fixtures/BackendConfigurationManagerRecursivePids.csv');
103  ‪$GLOBALS['BE_USER'] = new ‪BackendUserAuthentication();
104  ‪$GLOBALS['BE_USER']->user = ['admin' => true];
105  $backendConfigurationManager = $this->getAccessibleMock(BackendConfigurationManager::class, null, [], '', false);
106  $expectedResult = [1, 2, 4, 5, 3, 6, 7];
107  $actualResult = $backendConfigurationManager->_call('getRecursiveStoragePids', [1, -6], 4);
108  self::assertEquals($expectedResult, $actualResult);
109  }
110 }
‪TYPO3\CMS\Extbase\Tests\Functional\Configuration\BackendConfigurationManagerTest
Definition: BackendConfigurationManagerTest.php:31
‪TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager
Definition: BackendConfigurationManager.php:37
‪TYPO3\CMS\Extbase\Tests\Functional\Configuration\BackendConfigurationManagerTest\getCurrentPageIdReturnsPidFromFirstRootTemplateIfIdIsNotSetAndNoRootPageWasFound
‪getCurrentPageIdReturnsPidFromFirstRootTemplateIfIdIsNotSetAndNoRootPageWasFound()
Definition: BackendConfigurationManagerTest.php:37
‪TYPO3\CMS\Extbase\Tests\Functional\Configuration\BackendConfigurationManagerTest\getRecursiveStoragePidsReturnsListOfPages
‪getRecursiveStoragePidsReturnsListOfPages()
Definition: BackendConfigurationManagerTest.php:100
‪TYPO3\CMS\Extbase\Tests\Functional\Configuration\BackendConfigurationManagerTest\getCurrentPageIdReturnsUidFromFirstRootPageIfIdIsNotSet
‪getCurrentPageIdReturnsUidFromFirstRootPageIfIdIsNotSet()
Definition: BackendConfigurationManagerTest.php:62
‪TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager
Definition: AbstractConfigurationManager.php:34
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Extbase\Tests\Functional\Configuration\BackendConfigurationManagerTest\getCurrentPageIdReturnsDefaultStoragePidIfIdIsNotSetNoRootTemplateAndRootPageWasFound
‪getCurrentPageIdReturnsDefaultStoragePidIfIdIsNotSetNoRootTemplateAndRootPageWasFound()
Definition: BackendConfigurationManagerTest.php:86
‪TYPO3\CMS\Core\TypoScript\TypoScriptService
Definition: TypoScriptService.php:25
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Extbase\Tests\Functional\Configuration
Definition: BackendConfigurationManagerTest.php:18
‪TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager\DEFAULT_BACKEND_STORAGE_PID
‪const DEFAULT_BACKEND_STORAGE_PID
Definition: AbstractConfigurationManager.php:38