diff --git a/typo3/sysext/core/Build/FunctionalTestsBootstrap.php b/typo3/sysext/core/Build/FunctionalTestsBootstrap.php index c496e3038f054d9ab5fc94aa3420f2f1ad558a10..b5d9e11119d4e4d7b4a8761cf3f2566048fb1ccc 100644 --- a/typo3/sysext/core/Build/FunctionalTestsBootstrap.php +++ b/typo3/sysext/core/Build/FunctionalTestsBootstrap.php @@ -43,8 +43,26 @@ require_once(__DIR__ . '/../Tests/Exception.php'); * be way more complicated if done within the test class. * * It is required that phpunit binary is called from the document root of the instance, - * otherwise path calculation of the created TYPO3 CMS instance will fail. + * or TYPO3_PATH_WEB environement variable needs to be set, + * otherwise path calculation, of the created TYPO3 CMS instance will fail. */ +if (getenv('TYPO3_PATH_WEB')) { + $webRoot = getenv('TYPO3_PATH_WEB') . '/'; +} elseif (isset($_SERVER['PWD'])) { + $webRoot = $_SERVER['PWD'] . '/'; +} else { + $webRoot = getcwd() . '/'; +} + +/** + * Fail if configuration is not found + */ +if (!file_exists($webRoot . 'typo3conf/LocalConfiguration.php')) { + throw new \Exception('TYPO3 web root not found. Call PHPUnit from that directory or set TYPO3_PATH_WEB to it.'); +} + if (!defined('ORIGINAL_ROOT')) { - define('ORIGINAL_ROOT', $_SERVER['PWD'] . '/'); + define('ORIGINAL_ROOT', $webRoot); } + +unset($webRoot); \ No newline at end of file diff --git a/typo3/sysext/core/Build/UnitTestsBootstrap.php b/typo3/sysext/core/Build/UnitTestsBootstrap.php index 6d1d5746ff292d3753106906731fe8852fc33dae..9ffd6fbf38628611b26d9ccc1cd6797076c2da98 100644 --- a/typo3/sysext/core/Build/UnitTestsBootstrap.php +++ b/typo3/sysext/core/Build/UnitTestsBootstrap.php @@ -82,6 +82,8 @@ define('PATH_site', $webRoot); define('TYPO3_MODE', 'BE'); define('TYPO3_cliMode', TRUE); +unset($webRoot); + /** * We need to fake the current script to be the cli dispatcher to satisfy some GeneralUtility::getIndpEnv tests * TODO: properly mock these tests