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