‪TYPO3CMS  10.4
BackendModuleControllerTest.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 
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 class ‪BackendModuleControllerTest extends FunctionalTestCase
27 {
34  public function ‪environmentContextIsRespectedTest(string $module): void
35  {
36  $subject = new ‪BackendModuleController();
37  $action = $module . 'Action';
38 
39  self::assertIsCallable([$subject, $action]);
40 
41  // Ensure we are not in development context
42  self::assertFalse(‪Environment::getContext()->isDevelopment());
43 
44  // Sudo mode is required
45  self::assertEquals(403, $subject->{$action}()->getStatusCode());
46 
47  // Initialize environment with development context
49  new ‪ApplicationContext('Development'),
56  ‪Environment::getBackendPath() . '/index.php',
57  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
58  );
59 
60  // Authorized redirect to the admin tool is performed
61  // sudo mode is not required (due to development context)
62  ‪$GLOBALS['BE_USER'] = new ‪BackendUserAuthentication();
63  // using anonymous user session, which is fine for this test case
64  ‪$GLOBALS['BE_USER']->id = ‪$GLOBALS['BE_USER']->createSessionId();
65  ‪$GLOBALS['BE_USER']->user = ['uid' => 1];
66 
67  $response = $subject->{$action}();
68  self::assertEquals(303, $response->getStatusCode());
69  self::assertNotEmpty($response->getHeader('location'));
70  self::assertStringContainsString(
71  'install.php?install[controller]=' . $module . '&install[context]=backend',
72  $response->getHeaderLine('location')
73  );
74  }
75 
77  {
78  yield 'maintenance module' => ['maintenance'];
79  yield 'settings module' => ['settings'];
80  yield 'upgrade module' => ['upgrade'];
81  yield 'environment module' => ['environment'];
82  }
83 }
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:180
‪TYPO3\CMS\Core\Core\ApplicationContext
Definition: ApplicationContext.php:37
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:292
‪TYPO3\CMS\Install\Tests\Functional\Controller\BackendModuleControllerTest\environmentContextIsRespectedTest
‪environmentContextIsRespectedTest(string $module)
Definition: BackendModuleControllerTest.php:34
‪TYPO3\CMS\Install\Tests\Functional\Controller\BackendModuleControllerTest\environmentContextIsRespectedTestDataProvider
‪environmentContextIsRespectedTestDataProvider()
Definition: BackendModuleControllerTest.php:76
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:133
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:169
‪TYPO3\CMS\Install\Tests\Functional\Controller
Definition: BackendModuleControllerTest.php:18
‪TYPO3\CMS\Core\Core\Environment\initialize
‪static initialize(ApplicationContext $context, bool $cli, bool $composerMode, string $projectPath, string $publicPath, string $varPath, string $configPath, string $currentScript, string $os)
Definition: Environment.php:104
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static string getBackendPath()
Definition: Environment.php:250
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:144
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Install\Tests\Functional\Controller\BackendModuleControllerTest
Definition: BackendModuleControllerTest.php:27
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:210
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:192
‪TYPO3\CMS\Install\Controller\BackendModuleController
Definition: BackendModuleController.php:47