3 * This file is part of the TYPO3 CMS project.
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.
9 * For the full copyright and license information, please read the
10 * LICENSE.txt file that was distributed with this source code.
12 * The TYPO3 project - inspiring people to share!
16 * This file is defined in UnitTests.xml and called by phpunit
17 * before instantiating the test suites, it must also be included
18 * with phpunit parameter --bootstrap if executing single test case classes.
20 * Run whole core unit test suite, example:
21 * - cd /var/www/t3master/foo # Document root of TYPO3 CMS instance (location of index.php)
22 * - typo3/../bin/phpunit -c typo3/sysext/core/Build/UnitTests.xml
24 * Run single test case, example:
25 * - cd /var/www/t3master/foo # Document root of TYPO3 CMS instance (location of index.php)
26 * - typo3/../bin/phpunit -c typo3/sysext/core/Build/UnitTests.xml
27 * typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php
30 call_user_func(function () {
31 // Ensure cli only as security measure
32 if (PHP_SAPI
!== 'cli') {
33 die('This script supports command line usage only. Please check your command.');
36 $testbase = new \TYPO3\CMS\Core\Tests\
Testbase();
37 $testbase->enableDisplayErrors();
38 $testbase->defineBaseConstants();
39 $testbase->defineSitePath();
40 $testbase->defineTypo3ModeBe();
41 $testbase->setTypo3TestingContext();
42 $testbase->createDirectory(PATH_site
. 'uploads');
43 $testbase->createDirectory(PATH_site
. 'typo3temp/var/tests');
44 $testbase->createDirectory(PATH_site
. 'typo3temp/var/transient');
45 $testbase->createDirectory(PATH_site
. 'typo3conf/ext');
47 // Retrieve an instance of class loader and inject to core bootstrap
48 $classLoaderFilepath = __DIR__
. '/../../../../vendor/autoload.php';
49 if (!file_exists($classLoaderFilepath)) {
50 die('ClassLoader can\'t be loaded. Please check your path or set an environment variable \'TYPO3_PATH_WEB\' to your root path.');
52 $classLoader = require $classLoaderFilepath;
53 \TYPO3\CMS\Core\Core\Bootstrap
::getInstance()
54 ->initializeClassLoader($classLoader)
55 ->setRequestType(TYPO3_REQUESTTYPE_BE | TYPO3_REQUESTTYPE_CLI
)
58 // Initialize default TYPO3_CONF_VARS
59 $configurationManager = new \TYPO3\CMS\Core\Configuration\
ConfigurationManager();
60 $GLOBALS['TYPO3_CONF_VARS'] = $configurationManager->getDefaultConfiguration();
61 // Avoid failing tests that rely on HTTP_HOST retrieval
62 $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = '.*';
64 \TYPO3\CMS\Core\Core\Bootstrap
::getInstance()
66 ->initializeCachingFramework()
67 // Set all packages to active
68 ->initializePackageManagement(\TYPO3\CMS\Core\Package\UnitTestPackageManager
::class)
69 // Find all class names
70 ->ensureClassLoadingInformationExists();