‪TYPO3CMS  9.5
BackendModuleControllerTest.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 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
23 class ‪BackendModuleControllerTest extends FunctionalTestCase
24 {
31  public function ‪environmentContextIsRespectedTest(string $module): void
32  {
33  $subject = new ‪BackendModuleController();
34  $action = $module . 'Action';
35 
36  self::assertIsCallable([$subject, $action]);
37 
38  // Ensure we are not in development context
39  self::assertFalse(‪Environment::getContext()->isDevelopment());
40 
41  // Sudo mode is required
42  self::assertEquals(403, $subject->{$action}()->getStatusCode());
43 
44  // Initialize environment with development context
46  new ‪ApplicationContext('Development'),
53  ‪Environment::getBackendPath() . '/index.php',
54  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
55  );
56 
57  // Authorized redirect to the install tool is performed, sudo mode is not required
58  $response = $subject->{$action}();
59  self::assertEquals(303, $response->getStatusCode());
60  self::assertNotEmpty($response->getHeader('location'));
61  self::assertStringContainsString(
62  'install.php?install[controller]=' . $module . '&install[context]=backend',
63  $response->getHeaderLine('location')
64  );
65  }
66 
68  {
69  yield 'maintenance module' => ['maintenance'];
70  yield 'settings module' => ['settings'];
71  yield 'upgrade module' => ['upgrade'];
72  yield 'environment module' => ['environment'];
73  }
74 }
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Core\Core\ApplicationContext
Definition: ApplicationContext.php:36
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:266
‪TYPO3\CMS\Install\Tests\Functional\Controller\BackendModuleControllerTest\environmentContextIsRespectedTest
‪environmentContextIsRespectedTest(string $module)
Definition: BackendModuleControllerTest.php:31
‪TYPO3\CMS\Install\Tests\Functional\Controller\BackendModuleControllerTest\environmentContextIsRespectedTestDataProvider
‪environmentContextIsRespectedTestDataProvider()
Definition: BackendModuleControllerTest.php:67
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:106
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:142
‪TYPO3\CMS\Install\Tests\Functional\Controller
Definition: BackendModuleControllerTest.php:3
‪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:77
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static string getBackendPath()
Definition: Environment.php:223
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:117
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Install\Tests\Functional\Controller\BackendModuleControllerTest
Definition: BackendModuleControllerTest.php:24
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:183
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:165
‪TYPO3\CMS\Install\Controller\BackendModuleController
Definition: BackendModuleController.php:46