‪TYPO3CMS  ‪main
UnitTestsBootstrap.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of the TYPO3 CMS project.
4  *
5  * It is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License, either version 2
7  * of the License, or any later version.
8  *
9  * For the full copyright and license information, please read the
10  * LICENSE.txt file that was distributed with this source code.
11  *
12  * The TYPO3 project - inspiring people to share!
13  */
14 
19 (static function () {
20  $testbase = new \TYPO3\TestingFramework\Core\Testbase();
21 
22  // These if's are for core testing (package typo3/cms) only. cms-composer-installer does
23  // not create the autoload-include.php file that sets these env vars and sets composer
24  // mode to true. testing-framework can not be used without composer anyway, so it is safe
25  // to do this here. This way it does not matter if 'bin/phpunit' or 'vendor/phpunit/phpunit/phpunit'
26  // is called to run the tests since the 'relative to entry script' path calculation within
27  // SystemEnvironmentBuilder is not used. However, the binary must be called from the document
28  // root since getWebRoot() uses 'getcwd()'.
29  if (!getenv('TYPO3_PATH_ROOT')) {
30  putenv('TYPO3_PATH_ROOT=' . rtrim($testbase->getWebRoot(), '/'));
31  }
32  if (!getenv('TYPO3_PATH_WEB')) {
33  putenv('TYPO3_PATH_WEB=' . rtrim($testbase->getWebRoot(), '/'));
34  }
35 
36  $testbase->defineSitePath();
37 
40 
41  $testbase->createDirectory(\‪TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3conf/ext');
42  $testbase->createDirectory(\‪TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/assets');
43  $testbase->createDirectory(\‪TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/tests');
44  $testbase->createDirectory(\‪TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/transient');
45 
46  // Retrieve an instance of class loader and inject to core bootstrap
47  $classLoader = require $testbase->getPackagesPath() . '/autoload.php';
49 
50  // Initialize default TYPO3_CONF_VARS
51  $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
52  ‪$GLOBALS['TYPO3_CONF_VARS'] = $configurationManager->getDefaultConfiguration();
53 
54  $cache = new \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend(
55  'core',
56  new \‪TYPO3\CMS\Core\Cache\Backend\NullBackend('production', [])
57  );
58  // Set all packages to active
59  $packageManager = ‪\TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(\‪TYPO3\CMS\Core\Package\UnitTestPackageManager::class, \‪TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache));
60 
61  \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\‪TYPO3\CMS\Core\Package\PackageManager::class, $packageManager);
63 
64  $testbase->dumpClassLoadingInformation();
65 
66  \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
67 })();
‪TYPO3
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_BE
‪const REQUESTTYPE_BE
Definition: SystemEnvironmentBuilder.php:45
‪TYPO3\CMS\Core\Core\Bootstrap\initializeClassLoader
‪static initializeClassLoader(ClassLoader $classLoader)
Definition: Bootstrap.php:193
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\setPackageManager
‪static setPackageManager(PackageManager $packageManager)
Definition: ExtensionManagementUtility.php:41
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\REQUESTTYPE_CLI
‪const REQUESTTYPE_CLI
Definition: SystemEnvironmentBuilder.php:47
‪TYPO3\CMS\Core\Core\Bootstrap\createPackageManager
‪static createPackageManager($packageManagerClassName, PackageCacheInterface $packageCache)
Definition: Bootstrap.php:276
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\SystemEnvironmentBuilder\run
‪static run(int $entryPointLevel=0, int $requestType=0)
Definition: SystemEnvironmentBuilder.php:60