Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Build/FunctionalTestsBootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

use TYPO3\TestingFramework\Core\Testbase;

/*
* This file is part of the TYPO3 CMS project.
*
Expand All @@ -11,7 +14,6 @@
*
* The TYPO3 project - inspiring people to share!
*/

/**
* Boilerplate for a functional test phpunit bootstrap file.
*
Expand All @@ -22,9 +24,11 @@
* This file is defined in FunctionalTests.xml and called by phpunit
* before instantiating the test suites.
*/
(static function () {
$testbase = new \TYPO3\TestingFramework\Core\Testbase();
(static function (): void {
$testbase = new Testbase();
$testbase->defineOriginalRootPath();
/** @phpstan-ignore constant.notFound */
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests');
/** @phpstan-ignore constant.notFound */
$testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient');
})();
63 changes: 34 additions & 29 deletions Build/UnitTestsBootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<?php

use TYPO3\TestingFramework\Core\Testbase;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Configuration\ConfigurationManager;
use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
use TYPO3\CMS\Core\Cache\Backend\NullBackend;
use TYPO3\CMS\Core\Package\UnitTestPackageManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Package\PackageManager;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

/*
* This file is part of the TYPO3 CMS project.
*
Expand All @@ -11,9 +24,8 @@
*
* The TYPO3 project - inspiring people to share!
*/

call_user_func(function () {
$testbase = new \TYPO3\TestingFramework\Core\Testbase();
call_user_func(function (): void {
$testbase = new Testbase();

// These if's are for core testing (package typo3/cms) only. cms-composer-installer does
// not create the autoload-include.php file that sets these env vars and sets composer
Expand All @@ -25,51 +37,44 @@
if (!getenv('TYPO3_PATH_ROOT')) {
putenv('TYPO3_PATH_ROOT=' . rtrim($testbase->getWebRoot(), '/'));
}

if (!getenv('TYPO3_PATH_WEB')) {
putenv('TYPO3_PATH_WEB=' . rtrim($testbase->getWebRoot(), '/'));
}

$testbase->defineSitePath();

$requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI;
\TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run(0, $requestType);
$requestType = SystemEnvironmentBuilder::REQUESTTYPE_BE | SystemEnvironmentBuilder::REQUESTTYPE_CLI;
SystemEnvironmentBuilder::run(0, $requestType);

$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3conf/ext');
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/assets');
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/tests');
$testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/transient');
$testbase->createDirectory(Environment::getPublicPath() . '/typo3conf/ext');
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/assets');
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/tests');
$testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/transient');

// Retrieve an instance of class loader and inject to core bootstrap
$classLoader = require $testbase->getPackagesPath() . '/autoload.php';
\TYPO3\CMS\Core\Core\Bootstrap::initializeClassLoader($classLoader);
Bootstrap::initializeClassLoader($classLoader);

// Initialize default TYPO3_CONF_VARS
$configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager();
$configurationManager = new ConfigurationManager();
$GLOBALS['TYPO3_CONF_VARS'] = $configurationManager->getDefaultConfiguration();

$cache = new \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend(
$cache = new PhpFrontend(
'core',
new \TYPO3\CMS\Core\Cache\Backend\NullBackend('production', [])
new NullBackend('production', [])
);

// Set all packages to active
if (interface_exists(\TYPO3\CMS\Core\Package\Cache\PackageCacheInterface::class)) {
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(
\TYPO3\CMS\Core\Package\UnitTestPackageManager::class,
\TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache)
);
} else {
// v10 compatibility layer
$packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(
\TYPO3\CMS\Core\Package\UnitTestPackageManager::class,
$cache
);
}
$packageManager = Bootstrap::createPackageManager(
UnitTestPackageManager::class,
Bootstrap::createPackageCache($cache)
);

\TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::setPackageManager($packageManager);
GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager);
ExtensionManagementUtility::setPackageManager($packageManager);

$testbase->dumpClassLoadingInformation();

\TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
});
GeneralUtility::purgeInstances();
});
Loading
Loading