From 311cfe21a77ba152e3ed5074966bf03ee340e9e0 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Fri, 15 Jun 2018 18:45:41 +0200
Subject: [PATCH] [TASK] Use Environment API instead of PATH_site in core

First batch taking care of "easy" places.

Resolves: #85283
Releases: master
Change-Id: I68fa5a0559aae6191858aba7690ba72918bdf507
Reviewed-on: https://review.typo3.org/57240
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
---
 .../Configuration/Loader/YamlFileLoader.php   |   4 +-
 typo3/sysext/core/Classes/Core/Bootstrap.php  |   2 +-
 .../Core/ClassLoadingInformationGenerator.php |   2 +-
 .../core/Classes/Http/NormalizedParams.php    |   4 +-
 .../Classes/Imaging/GraphicalFunctions.php    |  32 +--
 .../Localization/Parser/AbstractXmlParser.php |  23 ++-
 .../core/Classes/Log/Writer/FileWriter.php    |   6 +-
 .../Middleware/NormalizedParamsAttribute.php  |  10 +-
 .../core/Classes/Package/PackageManager.php   |  18 +-
 .../Resource/Driver/DriverInterface.php       |   4 +-
 .../Classes/Resource/Driver/LocalDriver.php   |  11 +-
 .../Processing/LocalCropScaleMaskHelper.php   |   3 +-
 .../Classes/Resource/ResourceCompressor.php   |  48 ++---
 .../core/Classes/Resource/ResourceFactory.php |  15 +-
 .../core/Classes/Resource/ResourceStorage.php |   9 +-
 .../Classes/Resource/StorageRepository.php    |   3 +-
 .../TypoScript/Parser/TypoScriptParser.php    |   3 +-
 .../Classes/TypoScript/TemplateService.php    |   3 +-
 .../core/Classes/Utility/CommandUtility.php   |   6 +-
 .../Utility/ExtensionManagementUtility.php    |   8 +-
 .../core/Classes/Utility/GeneralUtility.php   |   2 +-
 .../core/Classes/Utility/PathUtility.php      |   6 +-
 .../DefaultConfigurationDescription.yaml      |   4 +-
 .../Resource/ResourceStorageTest.php          |  44 ++--
 .../ConfigurationManagerTest.php              |  21 +-
 .../Tests/Unit/Http/NormalizedParamsTest.php  |  10 +-
 .../core/Tests/Unit/Http/StreamTest.php       |  62 +++---
 .../Localization/LocalizationFactoryTest.php  |   3 +-
 .../Parser/LocallangXmlParserTest.php         |   3 +-
 .../Localization/Parser/XliffParserTest.php   |   3 +-
 .../Locking/SemaphoreLockStrategyTest.php     |   5 +-
 .../Unit/Locking/SimpleLockStrategyTest.php   |   2 +-
 .../Unit/Resource/Driver/LocalDriverTest.php  |  16 +-
 .../ResourceCompressorIntegrationTest.php     |  17 +-
 .../Unit/Resource/ResourceCompressorTest.php  |   3 +-
 .../Unit/Resource/ResourceFactoryTest.php     |   7 +-
 .../ExtensionManagementUtilityTest.php        |   9 +-
 .../GeneralUtilityFilesystemFixture.php       |   2 +-
 .../Tests/Unit/Utility/GeneralUtilityTest.php | 193 ++++++++++--------
 .../Tests/Unit/Utility/PathUtilityTest.php    |  24 +--
 .../ExtensionManagementUtilityTest.php        |   7 +-
 41 files changed, 361 insertions(+), 296 deletions(-)

diff --git a/typo3/sysext/core/Classes/Configuration/Loader/YamlFileLoader.php b/typo3/sysext/core/Classes/Configuration/Loader/YamlFileLoader.php
index eb05f5fa13d9..aebe6664e257 100644
--- a/typo3/sysext/core/Classes/Configuration/Loader/YamlFileLoader.php
+++ b/typo3/sysext/core/Classes/Configuration/Loader/YamlFileLoader.php
@@ -37,7 +37,7 @@ class YamlFileLoader
     /**
      * Loads and parses a YAML file, and returns an array with the found data
      *
-     * @param string $fileName either relative to PATH_site or prefixed with EXT:...
+     * @param string $fileName either relative to TYPO3's base project folder or prefixed with EXT:...
      * @return array the configuration as array
      * @throws \RuntimeException when the file is empty or is of invalid format
      */
@@ -61,7 +61,7 @@ class YamlFileLoader
     /**
      * Put into a separate method to ease the pains with unit tests
      *
-     * @param string $fileName either relative to PATH_site or prefixed with EXT:...
+     * @param string $fileName either relative to TYPO3's base project folder or prefixed with EXT:...
      *
      * @return string the contents of the file
      * @throws \RuntimeException when the file was not accessible
diff --git a/typo3/sysext/core/Classes/Core/Bootstrap.php b/typo3/sysext/core/Classes/Core/Bootstrap.php
index b09cd7f9d2ac..4fdc6560b7e0 100644
--- a/typo3/sysext/core/Classes/Core/Bootstrap.php
+++ b/typo3/sysext/core/Classes/Core/Bootstrap.php
@@ -840,7 +840,7 @@ class Bootstrap
     public static function initializeBackendRouter()
     {
         // See if the Routes.php from all active packages have been built together already
-        $cacheIdentifier = 'BackendRoutesFromPackages_' . sha1(TYPO3_version . PATH_site . 'BackendRoutesFromPackages');
+        $cacheIdentifier = 'BackendRoutesFromPackages_' . sha1(TYPO3_version . Environment::getProjectPath() . 'BackendRoutesFromPackages');
 
         /** @var $codeCache \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface */
         $codeCache = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('cache_core');
diff --git a/typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php b/typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php
index 40aef39b1b49..33fc9d321424 100644
--- a/typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php
+++ b/typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php
@@ -64,7 +64,7 @@ class ClassLoadingInformationGenerator
      * Returns class loading information for a single package
      *
      * @param PackageInterface $package The package to generate the class loading info for
-     * @param bool $useRelativePaths If set to TRUE, make the path relative to the current TYPO3 instance (PATH_site)
+     * @param bool $useRelativePaths If set to TRUE, make the path relative to the current TYPO3 public web path
      * @return array
      */
     public function buildClassLoadingInformationForPackage(PackageInterface $package, $useRelativePaths = false)
diff --git a/typo3/sysext/core/Classes/Http/NormalizedParams.php b/typo3/sysext/core/Classes/Http/NormalizedParams.php
index b68bf1b6c179..7ad592237f92 100644
--- a/typo3/sysext/core/Classes/Http/NormalizedParams.php
+++ b/typo3/sysext/core/Classes/Http/NormalizedParams.php
@@ -288,7 +288,7 @@ class NormalizedParams
      * @param ServerRequestInterface $serverRequest Used to access $_SERVER
      * @param array $typo3ConfVars $GLOBALS['TYPO3_CONF_VARS']
      * @param string $pathThisScript Absolute server entry script path, usually found within Environment::getCurrentScript()
-     * @param string $pathSite Absolute server path to document root, constant PATH_site
+     * @param string $pathSite Absolute server path to document root, Environment::getPublicPath()
      */
     public function __construct(ServerRequestInterface $serverRequest, array $typo3ConfVars, string $pathThisScript, string $pathSite)
     {
@@ -307,7 +307,7 @@ class NormalizedParams
         $this->remoteAddress = self::determineRemoteAddress($serverParams, $typo3ConfVars, $isBehindReverseProxy);
         $scriptFilename = $this->scriptFilename = $pathThisScript;
         $this->documentRoot = self::determineDocumentRoot($scriptName, $scriptFilename);
-        $siteUrl = $this->siteUrl = self::determineSiteUrl($requestDir, $pathThisScript, $pathSite);
+        $siteUrl = $this->siteUrl = self::determineSiteUrl($requestDir, $pathThisScript, $pathSite . '/');
         $this->sitePath = self::determineSitePath($requestHost, $siteUrl);
         $this->siteScript = self::determineSiteScript($requestUrl, $siteUrl);
 
diff --git a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
index 60e8e1edeb3e..202dcf62f212 100644
--- a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
+++ b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
@@ -2131,9 +2131,9 @@ class GraphicalFunctions
             $theOutputName = $this->imageMagickConvert_forceFileNameBody;
             $this->imageMagickConvert_forceFileNameBody = '';
         }
-        // Making the temporary filename:
-        GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/assets/images/');
-        $output = PATH_site . 'typo3temp/assets/images/' . $this->filenamePrefix . $theOutputName . '.' . $newExt;
+        // Making the temporary filename
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/typo3temp/assets/images/');
+        $output = Environment::getPublicPath() . '/typo3temp/assets/images/' . $this->filenamePrefix . $theOutputName . '.' . $newExt;
         if ($this->dontCheckForExistingTempFile || !file_exists($output)) {
             $this->imageMagickExec($imagefile, $output, $command, $frame);
         }
@@ -2210,7 +2210,7 @@ class GraphicalFunctions
     /**
      * Fetches the cached image dimensions from the cache. Does not check if the image file exists.
      *
-     * @param string $filePath Image file path, relative to PATH_site
+     * @param string $filePath Image file path, relative to public web path
      *
      * @return array|bool an array where [0]/[1] is w/h, [2] is extension and [3] is the file name,
      *                    or FALSE for a cache miss
@@ -2248,7 +2248,7 @@ class GraphicalFunctions
      *
      * This method does not check if the image file actually exists.
      *
-     * @param string $filePath Image file path, relative to PATH_site
+     * @param string $filePath Image file path, relative to public web path
      *
      * @return string the hash key (an SHA1 hash), will not be empty
      */
@@ -2260,7 +2260,7 @@ class GraphicalFunctions
     /**
      * Creates the status hash to check whether a file has been changed.
      *
-     * @param string $filePath Image file path, relative to PATH_site
+     * @param string $filePath Image file path, relative to public web path
      *
      * @return string the status hash (an SHA1 hash)
      */
@@ -2401,7 +2401,7 @@ class GraphicalFunctions
     /**
      * Call the identify command
      *
-     * @param string $imagefile The relative (to PATH_site) image filepath
+     * @param string $imagefile The relative to public web path image filepath
      * @return array|null Returns an array where [0]/[1] is w/h, [2] is extension and [3] is the filename.
      */
     public function imageMagickIdentify($imagefile)
@@ -2441,8 +2441,8 @@ class GraphicalFunctions
      * Executes an ImageMagick "convert" on two filenames, $input and $output using $params before them.
      * Can be used for many things, mostly scaling and effects.
      *
-     * @param string $input The relative (to PATH_site) image filepath, input file (read from)
-     * @param string $output The relative (to PATH_site) image filepath, output filename (written to)
+     * @param string $input The relative to public web path image filepath, input file (read from)
+     * @param string $output The relative to public web path image filepath, output filename (written to)
      * @param string $params ImageMagick parameters
      * @param int $frame Optional, refers to which frame-number to select in the image. '' or 0
      * @return string The result of a call to PHP function "exec()
@@ -2467,10 +2467,10 @@ class GraphicalFunctions
      * Executes an ImageMagick "combine" (or composite in newer times) on four filenames - $input, $overlay and $mask as input files and $output as the output filename (written to)
      * Can be used for many things, mostly scaling and effects.
      *
-     * @param string $input The relative (to PATH_site) image filepath, bottom file
-     * @param string $overlay The relative (to PATH_site) image filepath, overlay file (top)
-     * @param string $mask The relative (to PATH_site) image filepath, the mask file (grayscale)
-     * @param string $output The relative (to PATH_site) image filepath, output filename (written to)
+     * @param string $input The relative to public web path image filepath, bottom file
+     * @param string $overlay The relative to public web path image filepath, overlay file (top)
+     * @param string $mask The relative to public web path image filepath, the mask file (grayscale)
+     * @param string $output The relative to public web path image filepath, output filename (written to)
      * @return string
      */
     public function combineExec($input, $overlay, $mask, $output)
@@ -2570,10 +2570,10 @@ class GraphicalFunctions
             return $theFile;
         }
 
-        if (!@is_dir(PATH_site . 'typo3temp/assets/images/')) {
-            GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/assets/images/');
+        if (!@is_dir(Environment::getPublicPath() . '/typo3temp/assets/images/')) {
+            GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/typo3temp/assets/images/');
         }
-        $newFile = PATH_site . 'typo3temp/assets/images/' . md5($theFile . '|' . filemtime($theFile)) . ($output_png ? '.png' : '.gif');
+        $newFile = Environment::getPublicPath() . '/typo3temp/assets/images/' . md5($theFile . '|' . filemtime($theFile)) . ($output_png ? '.png' : '.gif');
         $cmd = CommandUtility::imageMagickCommand(
             'convert',
             '"' . $theFile . '" "' . $newFile . '"',
diff --git a/typo3/sysext/core/Classes/Localization/Parser/AbstractXmlParser.php b/typo3/sysext/core/Classes/Localization/Parser/AbstractXmlParser.php
index ab4c489a8ab7..b1ccea6256fb 100644
--- a/typo3/sysext/core/Classes/Localization/Parser/AbstractXmlParser.php
+++ b/typo3/sysext/core/Classes/Localization/Parser/AbstractXmlParser.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Localization\Parser;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Localization\Exception\FileNotFoundException;
 use TYPO3\CMS\Core\Localization\Exception\InvalidXmlFileException;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -105,16 +106,16 @@ abstract class AbstractXmlParser implements LocalizationParserInterface
             return GeneralUtility::getFileAbsFileName(str_replace($fileName, $language . '.' . $fileName, $fileRef));
         }
 
-        // Analyse file reference:
-        // Is system:
-        if (GeneralUtility::isFirstPartOfStr($fileRef, PATH_typo3 . 'sysext/')) {
-            $validatedPrefix = PATH_typo3 . 'sysext/';
-        } elseif (GeneralUtility::isFirstPartOfStr($fileRef, PATH_typo3 . 'ext/')) {
-            // Is global:
-            $validatedPrefix = PATH_typo3 . 'ext/';
-        } elseif (GeneralUtility::isFirstPartOfStr($fileRef, PATH_typo3conf . 'ext/')) {
-            // Is local:
-            $validatedPrefix = PATH_typo3conf . 'ext/';
+        // Analyse file reference
+        if (GeneralUtility::isFirstPartOfStr($fileRef, Environment::getPublicPath() . '/typo3/sysext/')) {
+            // Is system
+            $validatedPrefix = Environment::getPublicPath() . '/typo3/sysext/';
+        } elseif (GeneralUtility::isFirstPartOfStr($fileRef, Environment::getPublicPath() . '/typo3/ext/')) {
+            // Is global
+            $validatedPrefix = Environment::getPublicPath() . '/typo3/ext/';
+        } elseif (GeneralUtility::isFirstPartOfStr($fileRef, Environment::getPublicPath() . '/typo3conf/ext/')) {
+            // Is local
+            $validatedPrefix = Environment::getPublicPath() . '/typo3conf/ext/';
         } else {
             $validatedPrefix = '';
         }
@@ -128,7 +129,7 @@ abstract class AbstractXmlParser implements LocalizationParserInterface
             // Add empty first-entry if not there.
             list($file_extPath, $file_fileName) = $temp;
             // The filename is prefixed with "[language key]." because it prevents the llxmltranslate tool from detecting it.
-            return PATH_site . 'typo3conf/l10n/' . $language . '/' . $extensionKey . '/' . ($file_extPath ? $file_extPath . '/' : '') . $language . '.' . $file_fileName;
+            return Environment::getPublicPath() . '/typo3conf/l10n/' . $language . '/' . $extensionKey . '/' . ($file_extPath ? $file_extPath . '/' : '') . $language . '.' . $file_fileName;
         }
         return null;
     }
diff --git a/typo3/sysext/core/Classes/Log/Writer/FileWriter.php b/typo3/sysext/core/Classes/Log/Writer/FileWriter.php
index 47174876d72d..2a70835c1c6a 100644
--- a/typo3/sysext/core/Classes/Log/Writer/FileWriter.php
+++ b/typo3/sysext/core/Classes/Log/Writer/FileWriter.php
@@ -28,7 +28,7 @@ use TYPO3\CMS\Core\Utility\PathUtility;
 class FileWriter extends AbstractWriter
 {
     /**
-     * Log file path, relative to PATH_site
+     * Log file path, relative to TYPO3's base project folder
      *
      * @var string
      */
@@ -93,7 +93,7 @@ class FileWriter extends AbstractWriter
     /**
      * Sets the path to the log file.
      *
-     * @param string $relativeLogFile path to the log file, relative to PATH_site
+     * @param string $relativeLogFile path to the log file, relative to public web dir
      * @return WriterInterface
      * @throws InvalidLogWriterConfigurationException
      */
@@ -212,7 +212,7 @@ class FileWriter extends AbstractWriter
         if (!@is_dir($logFileDirectory)) {
             GeneralUtility::mkdir_deep($logFileDirectory);
             // create .htaccess file if log file is within the site path
-            if (PathUtility::getCommonPrefix([PATH_site, $logFileDirectory]) === PATH_site) {
+            if (PathUtility::getCommonPrefix([Environment::getPublicPath() . '/', $logFileDirectory]) === (Environment::getPublicPath() . '/')) {
                 // only create .htaccess, if we created the directory on our own
                 $this->createHtaccessFile($logFileDirectory . '/.htaccess');
             }
diff --git a/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php b/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php
index bdc95b17687a..be09055b3835 100644
--- a/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php
+++ b/typo3/sysext/core/Classes/Middleware/NormalizedParamsAttribute.php
@@ -40,7 +40,15 @@ class NormalizedParamsAttribute implements MiddlewareInterface
      */
     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
     {
-        $request = $request->withAttribute('normalizedParams', new NormalizedParams($request, $GLOBALS['TYPO3_CONF_VARS'], Environment::getCurrentScript(), PATH_site));
+        $request = $request->withAttribute(
+            'normalizedParams',
+            new NormalizedParams(
+                $request,
+                $GLOBALS['TYPO3_CONF_VARS'],
+                Environment::getCurrentScript(),
+                Environment::getPublicPath()
+            )
+        );
 
         // Set $request as global variable. This is needed in a transition phase until core code has been
         // refactored to have ServerRequest object available where it is needed. This global will be
diff --git a/typo3/sysext/core/Classes/Package/PackageManager.php b/typo3/sysext/core/Classes/Package/PackageManager.php
index ff735454ec29..c632c63b8506 100644
--- a/typo3/sysext/core/Classes/Package/PackageManager.php
+++ b/typo3/sysext/core/Classes/Package/PackageManager.php
@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Core\ClassLoadingInformation;
 use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
+use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
@@ -30,7 +31,7 @@ use TYPO3\CMS\Core\Utility\StringUtility;
 /**
  * The default TYPO3 Package Manager
  */
-class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
+class PackageManager implements SingletonInterface
 {
     /**
      * @var DependencyOrderingService
@@ -66,7 +67,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
      * Absolute path leading to the various package directories
      * @var string
      */
-    protected $packagesBasePath = PATH_site;
+    protected $packagesBasePath;
 
     /**
      * Array of available packages, indexed by package key
@@ -107,7 +108,8 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function __construct(DependencyOrderingService $dependencyOrderingService = null)
     {
-        $this->packageStatesPathAndFilename = PATH_typo3conf . 'PackageStates.php';
+        $this->packagesBasePath = Environment::getPublicPath() . '/';
+        $this->packageStatesPathAndFilename = Environment::getPublicPath() . '/typo3conf/PackageStates.php';
         if ($dependencyOrderingService === null) {
             trigger_error(self::class . ' without constructor based dependency injection has been deprecated in v9.2 and will not work in TYPO3 v10.', E_USER_DEPRECATED);
             $dependencyOrderingService = GeneralUtility::makeInstance(DependencyOrderingService::class);
@@ -1058,13 +1060,13 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
     {
         if (count($this->packagesBasePaths) < 3) {
             // Check if the directory even exists and if it is not empty
-            if (is_dir(PATH_typo3conf . 'ext') && $this->hasSubDirectories(PATH_typo3conf . 'ext')) {
-                $this->packagesBasePaths['local'] = PATH_typo3conf . 'ext/*/';
+            if (is_dir(Environment::getPublicPath() . '/typo3conf/ext') && $this->hasSubDirectories(Environment::getPublicPath() . '/typo3conf/ext')) {
+                $this->packagesBasePaths['local'] = Environment::getPublicPath() . '/typo3conf/ext/*/';
             }
-            if (is_dir(PATH_typo3 . 'ext') && $this->hasSubDirectories(PATH_typo3 . 'ext')) {
-                $this->packagesBasePaths['global'] = PATH_typo3 . 'ext/*/';
+            if (is_dir(Environment::getPublicPath() . '/typo3/ext') && $this->hasSubDirectories(Environment::getPublicPath() . '/typo3/ext')) {
+                $this->packagesBasePaths['global'] = Environment::getPublicPath() . '/typo3/ext/*/';
             }
-            $this->packagesBasePaths['system'] = PATH_typo3 . 'sysext/*/';
+            $this->packagesBasePaths['system'] = Environment::getPublicPath() . '/typo3/sysext/*/';
         }
         return $this->packagesBasePaths;
     }
diff --git a/typo3/sysext/core/Classes/Resource/Driver/DriverInterface.php b/typo3/sysext/core/Classes/Resource/Driver/DriverInterface.php
index 5822f7336f44..29831a5c9843 100644
--- a/typo3/sysext/core/Classes/Resource/Driver/DriverInterface.php
+++ b/typo3/sysext/core/Classes/Resource/Driver/DriverInterface.php
@@ -119,7 +119,7 @@ interface DriverInterface
 
     /**
      * Returns the public URL to a file.
-     * Either fully qualified URL or relative to PATH_site (rawurlencoded).
+     * Either fully qualified URL or relative to public web path (rawurlencoded).
      *
      * @param string $identifier
      * @return string|null NULL if file is missing or deleted, the generated url otherwise
@@ -185,7 +185,7 @@ interface DriverInterface
      * further check is done here! After a successful the original file must
      * not exist anymore.
      *
-     * @param string $localFilePath (within PATH_site)
+     * @param string $localFilePath within public web path
      * @param string $targetFolderIdentifier
      * @param string $newFileName optional, if not given original name is used
      * @param bool $removeOriginal if set the original file will be removed
diff --git a/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php b/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
index f60f3a21cfa9..c476fc22c2c3 100644
--- a/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
+++ b/typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Resource\Driver;
  */
 
 use TYPO3\CMS\Core\Charset\CharsetConverter;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Resource\Exception;
 use TYPO3\CMS\Core\Resource\FolderInterface;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
@@ -117,7 +118,7 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
     {
         // only calculate baseURI if the storage does not enforce jumpUrl Script
         if ($this->hasCapability(ResourceStorage::CAPABILITY_PUBLIC)) {
-            if (GeneralUtility::isFirstPartOfStr($this->absoluteBasePath, PATH_site)) {
+            if (GeneralUtility::isFirstPartOfStr($this->absoluteBasePath, Environment::getPublicPath())) {
                 // use site-relative URLs
                 $temporaryBaseUri = rtrim(PathUtility::stripPathSitePrefix($this->absoluteBasePath), '/');
                 if ($temporaryBaseUri !== '') {
@@ -150,7 +151,7 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
 
         if (!empty($configuration['pathType']) && $configuration['pathType'] === 'relative') {
             $relativeBasePath = $configuration['basePath'];
-            $absoluteBasePath = PATH_site . $relativeBasePath;
+            $absoluteBasePath = Environment::getPublicPath() . '/' . $relativeBasePath;
         } else {
             $absoluteBasePath = $configuration['basePath'];
         }
@@ -167,7 +168,7 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
 
     /**
      * Returns the public URL to a file.
-     * For the local driver, this will always return a path relative to PATH_site.
+     * For the local driver, this will always return a path relative to public web path.
      *
      * @param string $identifier
      * @return string|null NULL if file is missing or deleted, the generated url otherwise
@@ -750,7 +751,7 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
      * This assumes that the local file exists, so no further check is done here!
      * After a successful the original file must not exist anymore.
      *
-     * @param string $localFilePath (within PATH_site)
+     * @param string $localFilePath within public web path
      * @param string $targetFolderIdentifier
      * @param string $newFileName optional, if not given original name is used
      * @param bool $removeOriginal if set the original file will be removed after successful operation
@@ -761,7 +762,7 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
     public function addFile($localFilePath, $targetFolderIdentifier, $newFileName = '', $removeOriginal = true)
     {
         $localFilePath = $this->canonicalizeAndCheckFilePath($localFilePath);
-        // as for the "virtual storage" for backwards-compatibility, this check always fails, as the file probably lies under PATH_site
+        // as for the "virtual storage" for backwards-compatibility, this check always fails, as the file probably lies under public web path
         // thus, it is not checked here
         // @todo is check in storage
         if (GeneralUtility::isFirstPartOfStr($localFilePath, $this->absoluteBasePath) && $this->storageUid > 0) {
diff --git a/typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php b/typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php
index f3ec48478505..af335aa2bc0f 100644
--- a/typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php
+++ b/typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Resource\Processing;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Resource;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -138,7 +139,7 @@ class LocalCropScaleMaskHelper
             }
         } else {
             $targetFileName = $this->getFilenameForImageCropScaleMask($task);
-            $temporaryFileName = PATH_site . 'typo3temp/' . $targetFileName;
+            $temporaryFileName = Environment::getPublicPath() . '/typo3temp/' . $targetFileName;
             $maskImage = $configuration['maskImages']['maskImage'];
             $maskBackgroundImage = $configuration['maskImages']['backgroundImage'];
             if ($maskImage instanceof Resource\FileInterface && $maskBackgroundImage instanceof Resource\FileInterface) {
diff --git a/typo3/sysext/core/Classes/Resource/ResourceCompressor.php b/typo3/sysext/core/Classes/Resource/ResourceCompressor.php
index c24d4f5f9a3e..bfd84089f63d 100644
--- a/typo3/sysext/core/Classes/Resource/ResourceCompressor.php
+++ b/typo3/sysext/core/Classes/Resource/ResourceCompressor.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Resource;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
@@ -63,13 +64,13 @@ class ResourceCompressor
     public function __construct()
     {
         // we check for existence of our targetDirectory
-        if (!is_dir(PATH_site . $this->targetDirectory)) {
-            GeneralUtility::mkdir_deep(PATH_site . $this->targetDirectory);
+        if (!is_dir(Environment::getPublicPath() . '/' . $this->targetDirectory)) {
+            GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/' . $this->targetDirectory);
         }
         // if enabled, we check whether we should auto-create the .htaccess file
         if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['generateApacheHtaccess']) {
             // check whether .htaccess exists
-            $htaccessPath = PATH_site . $this->targetDirectory . '.htaccess';
+            $htaccessPath = Environment::getPublicPath() . '/' . $this->targetDirectory . '.htaccess';
             if (!file_exists($htaccessPath)) {
                 GeneralUtility::writeFile($htaccessPath, $this->htaccessTemplate);
             }
@@ -84,7 +85,7 @@ class ResourceCompressor
                 $this->gzipCompressionLevel = (int)$compressionLevel;
             }
         }
-        $this->setRootPath(TYPO3_MODE === 'BE' ? PATH_typo3 : PATH_site);
+        $this->setRootPath(TYPO3_MODE === 'BE' ? Environment::getPublicPath() . '/typo3/' : Environment::getPublicPath() . '/');
     }
 
     /**
@@ -286,7 +287,7 @@ class ResourceCompressor
         }
         $targetFile = $this->targetDirectory . 'merged-' . md5($unique) . '.' . $type;
         // if the file doesn't already exist, we create it
-        if (!file_exists(PATH_site . $targetFile)) {
+        if (!file_exists(Environment::getPublicPath() . '/' . $targetFile)) {
             $concatenated = '';
             // concatenate all the files together
             foreach ($filesToInclude as $filename) {
@@ -307,7 +308,7 @@ class ResourceCompressor
             if ($type === 'css') {
                 $concatenated = $this->cssFixStatements($concatenated);
             }
-            GeneralUtility::writeFile(PATH_site . $targetFile, $concatenated);
+            GeneralUtility::writeFile(Environment::getPublicPath() . '/' . $targetFile, $concatenated);
         }
         return $targetFile;
     }
@@ -363,7 +364,7 @@ class ResourceCompressor
         $pathinfo = PathUtility::pathinfo($filenameAbsolute);
         $targetFile = $this->targetDirectory . $pathinfo['filename'] . '-' . md5($unique) . '.css';
         // only create it, if it doesn't exist, yet
-        if (!file_exists(PATH_site . $targetFile) || $this->createGzipped && !file_exists(PATH_site . $targetFile . '.gzip')) {
+        if (!file_exists(Environment::getPublicPath() . '/' . $targetFile) || $this->createGzipped && !file_exists(Environment::getPublicPath() . '/' . $targetFile . '.gzip')) {
             $contents = $this->compressCssString(file_get_contents($filenameAbsolute));
             if (strpos($filename, $this->targetDirectory) === false) {
                 $contents = $this->cssFixRelativeUrlPaths($contents, PathUtility::dirname($filename) . '/');
@@ -415,7 +416,7 @@ class ResourceCompressor
         $pathinfo = PathUtility::pathinfo($filename);
         $targetFile = $this->targetDirectory . $pathinfo['filename'] . '-' . md5($unique) . '.js';
         // only create it, if it doesn't exist, yet
-        if (!file_exists(PATH_site . $targetFile) || $this->createGzipped && !file_exists(PATH_site . $targetFile . '.gzip')) {
+        if (!file_exists(Environment::getPublicPath() . '/' . $targetFile) || $this->createGzipped && !file_exists(Environment::getPublicPath() . '/' . $targetFile . '.gzip')) {
             $contents = file_get_contents($filenameAbsolute);
             $this->writeFileAndCompressed($targetFile, $contents);
         }
@@ -433,12 +434,12 @@ class ResourceCompressor
         /*
          * The various paths may have those values (e.g. if TYPO3 is installed in a subdir)
          * - docRoot = /var/www/html/
-         * - PATH_site = /var/www/html/sites/site1/
+         * - Environment::getPublicPath() = /var/www/html/sites/site1/
          * - $this->rootPath = /var/www/html/sites/site1/typo3
          *
          * The file names passed into this function may be either:
          * - relative to $this->rootPath
-         * - relative to PATH_site
+         * - relative to Environment::getPublicPath()
          * - relative to docRoot
          */
         $docRoot = GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT');
@@ -454,29 +455,28 @@ class ResourceCompressor
             }
             // the path is not within the root path, strip off the site path, the remaining logic below
             // takes care about adjusting the path correctly.
-            $filename = substr($absolutePath, strlen(PATH_site));
+            $filename = substr($absolutePath, strlen(Environment::getPublicPath() . '/'));
         }
         // if the file exists in the root path, just return the $filename
         if (is_file($this->rootPath . $fileNameWithoutSlash)) {
             return $fileNameWithoutSlash;
         }
         // if the file is from a special TYPO3 internal directory, add the missing typo3/ prefix
-        if (is_file(realpath(PATH_site . TYPO3_mainDir . $filename))) {
-            $filename = TYPO3_mainDir . $filename;
+        if (is_file(realpath(Environment::getPublicPath() . '/typo3/' . $filename))) {
+            $filename = 'typo3/' . $filename;
         }
-        // build the file path relatively to the PATH_site
+        // build the file path relative to the public web path
         if (strpos($filename, 'EXT:') === 0) {
             $file = GeneralUtility::getFileAbsFileName($filename);
         } elseif (strpos($filename, '../') === 0) {
-            $file = GeneralUtility::resolveBackPath(PATH_typo3 . $filename);
+            $file = GeneralUtility::resolveBackPath(Environment::getPublicPath() . '/typo3/' . $filename);
         } else {
-            $file = PATH_site . $filename;
+            $file = Environment::getPublicPath() . '/' . $filename;
         }
 
         // check if the file exists, and if so, return the path relative to TYPO3_mainDir
         if (is_file($file)) {
-            $mainDirDepth = substr_count(TYPO3_mainDir, '/');
-            return str_repeat('../', $mainDirDepth) . str_replace(PATH_site, '', $file);
+            return '../' . str_replace(Environment::getPublicPath() . '/', '', $file);
         }
         // none of above conditions were met, fallback to default behaviour
         return $filename;
@@ -616,10 +616,10 @@ class ResourceCompressor
     protected function writeFileAndCompressed($filename, $contents)
     {
         // write uncompressed file
-        GeneralUtility::writeFile(PATH_site . $filename, $contents);
+        GeneralUtility::writeFile(Environment::getPublicPath() . '/' . $filename, $contents);
         if ($this->createGzipped) {
             // create compressed version
-            GeneralUtility::writeFile(PATH_site . $filename . '.gzip', gzencode($contents, $this->gzipCompressionLevel));
+            GeneralUtility::writeFile(Environment::getPublicPath() . '/' . $filename . '.gzip', gzencode($contents, $this->gzipCompressionLevel));
         }
     }
 
@@ -636,7 +636,7 @@ class ResourceCompressor
         if ($this->createGzipped && strpos(GeneralUtility::getIndpEnv('HTTP_ACCEPT_ENCODING'), 'gzip') !== false) {
             $filename .= '.gzip';
         }
-        return PathUtility::getRelativePath($this->rootPath, PATH_site) . $filename;
+        return PathUtility::getRelativePath($this->rootPath, Environment::getPublicPath() . '/') . $filename;
     }
 
     /**
@@ -650,10 +650,10 @@ class ResourceCompressor
         $externalContent = GeneralUtility::getUrl($url);
         $filename = $this->targetDirectory . 'external-' . md5($url);
         // Write only if file does not exist OR md5 of the content is not the same as fetched one
-        if (!file_exists(PATH_site . $filename)
-            || (md5($externalContent) !== md5(file_get_contents(PATH_site . $filename)))
+        if (!file_exists(Environment::getPublicPath() . '/' . $filename)
+            || (md5($externalContent) !== md5(file_get_contents(Environment::getPublicPath() . '/' . $filename)))
         ) {
-            GeneralUtility::writeFile(PATH_site . $filename, $externalContent);
+            GeneralUtility::writeFile(Environment::getPublicPath() . '/' . $filename, $externalContent);
         }
         return $filename;
     }
diff --git a/typo3/sysext/core/Classes/Resource/ResourceFactory.php b/typo3/sysext/core/Classes/Resource/ResourceFactory.php
index d1fd31b721bd..146b3c0a4778 100644
--- a/typo3/sysext/core/Classes/Resource/ResourceFactory.php
+++ b/typo3/sysext/core/Classes/Resource/ResourceFactory.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Resource;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Resource\Index\FileIndexRepository;
@@ -207,7 +208,7 @@ class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\Singl
 
     /**
      * Checks whether a file resides within a real storage in local file system.
-     * If no match is found, uid 0 is returned which is a fallback storage pointing to PATH_site.
+     * If no match is found, uid 0 is returned which is a fallback storage pointing to fileadmin in public web path.
      *
      * The file identifier is adapted accordingly to match the new storage's base path.
      *
@@ -463,9 +464,9 @@ class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\Singl
      */
     public function retrieveFileOrFolderObject($input)
     {
-        // Remove PATH_site because absolute paths under Windows systems contain ':'
+        // Remove Environment::getPublicPath() because absolute paths under Windows systems contain ':'
         // This is done in all considered sub functions anyway
-        $input = str_replace(PATH_site, '', $input);
+        $input = str_replace(Environment::getPublicPath() . '/', '', $input);
 
         if (GeneralUtility::isFirstPartOfStr($input, 'file:')) {
             $input = substr($input, 5);
@@ -486,7 +487,7 @@ class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\Singl
                     return null;
                 }
 
-                $input = PathUtility::getRelativePath(PATH_site, PathUtility::dirname($input)) . PathUtility::basename($input);
+                $input = PathUtility::getRelativePath(Environment::getPublicPath() . '/', PathUtility::dirname($input)) . PathUtility::basename($input);
                 return $this->getFileObjectFromCombinedIdentifier($input);
             }
             return null;
@@ -494,7 +495,7 @@ class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\Singl
         // this is a backwards-compatible way to access "0-storage" files or folders
         // eliminate double slashes, /./ and /../
         $input = PathUtility::getCanonicalPath(ltrim($input, '/'));
-        if (@is_file(PATH_site . $input)) {
+        if (@is_file(Environment::getPublicPath() . '/' . $input)) {
             // only the local file
             return $this->getFileObjectFromCombinedIdentifier($input);
         }
@@ -523,8 +524,8 @@ class ResourceFactory implements ResourceFactoryInterface, \TYPO3\CMS\Core\Singl
             // please note that getStorageObject() might modify $folderIdentifier when
             // auto-detecting the best-matching storage to use
             $folderIdentifier = $parts[0];
-            // make sure to not use an absolute path, and remove PATH_site if it is prepended
-            if (GeneralUtility::isFirstPartOfStr($folderIdentifier, PATH_site)) {
+            // make sure to not use an absolute path, and remove Environment::getPublicPath if it is prepended
+            if (GeneralUtility::isFirstPartOfStr($folderIdentifier, Environment::getPublicPath() . '/')) {
                 $folderIdentifier = PathUtility::stripPathSitePrefix($parts[0]);
             }
         }
diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorage.php b/typo3/sysext/core/Classes/Resource/ResourceStorage.php
index b2f3d0f05ecc..83ae106639e7 100644
--- a/typo3/sysext/core/Classes/Resource/ResourceStorage.php
+++ b/typo3/sysext/core/Classes/Resource/ResourceStorage.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Resource;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Registry;
@@ -1300,16 +1301,16 @@ class ResourceStorage implements ResourceStorageInterface
                     }
 
                     $queryParameterArray['token'] = GeneralUtility::hmac(implode('|', $queryParameterArray), 'resourceStorageDumpFile');
-                    $publicUrl = GeneralUtility::locationHeaderUrl(PathUtility::getAbsoluteWebPath(PATH_site . 'index.php'));
+                    $publicUrl = GeneralUtility::locationHeaderUrl(PathUtility::getAbsoluteWebPath(Environment::getPublicPath() . '/index.php'));
                     $publicUrl .= '?' . http_build_query($queryParameterArray, '', '&', PHP_QUERY_RFC3986);
                 }
 
                 // If requested, make the path relative to the current script in order to make it possible
                 // to use the relative file
                 if ($publicUrl !== null && $relativeToCurrentScript && !GeneralUtility::isValidUrl($publicUrl)) {
-                    $absolutePathToContainingFolder = PathUtility::dirname(PATH_site . $publicUrl);
+                    $absolutePathToContainingFolder = PathUtility::dirname(Environment::getPublicPath() . '/' . $publicUrl);
                     $pathPart = PathUtility::getRelativePathTo($absolutePathToContainingFolder);
-                    $filePart = substr(PATH_site . $publicUrl, strlen($absolutePathToContainingFolder) + 1);
+                    $filePart = substr(Environment::getPublicPath() . '/' . $publicUrl, strlen($absolutePathToContainingFolder) + 1);
                     $publicUrl = $pathPart . $filePart;
                 }
             }
@@ -1902,7 +1903,7 @@ class ResourceStorage implements ResourceStorageInterface
             } elseif ($conflictMode->equals(DuplicationBehavior::REPLACE)) {
                 $sourceFileIdentifier = substr($file->getCombinedIdentifier(), 0, strrpos($file->getCombinedIdentifier(), '/') + 1) . $targetFileName;
                 $sourceFile = $this->getResourceFactoryInstance()->getFileObjectFromCombinedIdentifier($sourceFileIdentifier);
-                $file = $this->replaceFile($sourceFile, PATH_site . $file->getPublicUrl());
+                $file = $this->replaceFile($sourceFile, Environment::getPublicPath() . '/' . $file->getPublicUrl());
             }
         } catch (\RuntimeException $e) {
         }
diff --git a/typo3/sysext/core/Classes/Resource/StorageRepository.php b/typo3/sysext/core/Classes/Resource/StorageRepository.php
index f86c553c932f..eb9ed0fc79e6 100644
--- a/typo3/sysext/core/Classes/Resource/StorageRepository.php
+++ b/typo3/sysext/core/Classes/Resource/StorageRepository.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Resource;
  */
 
 use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Core\Log\LogManager;
@@ -202,7 +203,7 @@ class StorageRepository extends AbstractRepository
      */
     public function createLocalStorage($name, $basePath, $pathType, $description = '', $default = false)
     {
-        $caseSensitive = $this->testCaseSensitivity($pathType === 'relative' ? PATH_site . $basePath : $basePath);
+        $caseSensitive = $this->testCaseSensitivity($pathType === 'relative' ? Environment::getPublicPath() . '/' . $basePath : $basePath);
         // create the FlexForm for the driver configuration
         $flexFormData = [
             'data' => [
diff --git a/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php b/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
index e276d3fc675f..84a9f7091119 100644
--- a/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
+++ b/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
@@ -18,6 +18,7 @@ use Psr\Log\LoggerInterface;
 use Symfony\Component\Finder\Finder;
 use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher as BackendConditionMatcher;
 use TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
@@ -1152,7 +1153,7 @@ class TypoScriptParser
             // Get alphabetically sorted file index in array
             $fileIndex = GeneralUtility::getAllFilesAndFoldersInPath([], $absDirPath, $includedFileExtensions);
             // Prepend file contents to $newString
-            $prefixLength = strlen(PATH_site);
+            $prefixLength = strlen(Environment::getPublicPath() . '/');
             foreach ($fileIndex as $absFileRef) {
                 $relFileRef = substr($absFileRef, $prefixLength);
                 self::includeFile($relFileRef, $cycle_counter, $returnFiles, $newString, $includedFiles, '', $absDirPath);
diff --git a/typo3/sysext/core/Classes/TypoScript/TemplateService.php b/typo3/sysext/core/Classes/TypoScript/TemplateService.php
index f6cf18b46153..b4ecf8445f24 100644
--- a/typo3/sysext/core/Classes/TypoScript/TemplateService.php
+++ b/typo3/sysext/core/Classes/TypoScript/TemplateService.php
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\TypoScript;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\AbstractRestrictionContainer;
@@ -1373,7 +1374,7 @@ class TemplateService
 
         // if this is an URL, it can be returned directly
         $urlScheme = parse_url($file, PHP_URL_SCHEME);
-        if ($urlScheme === 'https' || $urlScheme === 'http' || is_file(PATH_site . $file)) {
+        if ($urlScheme === 'https' || $urlScheme === 'http' || is_file(Environment::getPublicPath() . '/' . $file)) {
             return $file;
         }
 
diff --git a/typo3/sysext/core/Classes/Utility/CommandUtility.php b/typo3/sysext/core/Classes/Utility/CommandUtility.php
index 1f7f8a40e67a..614cc8502b9e 100644
--- a/typo3/sysext/core/Classes/Utility/CommandUtility.php
+++ b/typo3/sysext/core/Classes/Utility/CommandUtility.php
@@ -255,7 +255,7 @@ class CommandUtility
     /**
      * Extend the preset paths. This way an extension can install an executable and provide the path to \TYPO3\CMS\Core\Utility\CommandUtility
      *
-     * @param string $paths Comma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with site root path (PATH_site).
+     * @param string $paths Comma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with public web path
      */
     public static function addPaths($paths)
     {
@@ -307,7 +307,7 @@ class CommandUtility
     /**
      * Initializes and extends the preset paths with own
      *
-     * @param string $paths Comma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with site root path (PATH_site).
+     * @param string $paths Comma separated list of extra paths where a command should be searched. Relative paths (without leading "/") are prepend with public web path
      */
     protected static function initPaths($paths = '')
     {
@@ -325,7 +325,7 @@ class CommandUtility
                 foreach ($paths as $path) {
                     // Make absolute path of relative
                     if (!preg_match('#^/#', $path)) {
-                        $path = PATH_site . $path;
+                        $path = Environment::getPublicPath() . '/' . $path;
                     }
                     if (!isset(self::$paths[$path])) {
                         if (@is_dir($path)) {
diff --git a/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php b/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
index 014b6f2ff119..c088c75571e7 100644
--- a/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
+++ b/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
@@ -150,7 +150,7 @@ class ExtensionManagementUtility
     }
 
     /**
-     * Returns the relative path to the extension as measured from the PATH_site (frontend)
+     * Returns the relative path to the extension as measured from the public web path
      * If the extension is not loaded the function will die with an error message
      * Useful for images and links from the frontend
      *
@@ -1609,7 +1609,7 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function getExtLocalconfCacheIdentifier()
     {
-        return 'ext_localconf_' . sha1(TYPO3_version . PATH_site . 'extLocalconf' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
+        return 'ext_localconf_' . sha1(TYPO3_version . Environment::getProjectPath() . 'extLocalconf' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
     }
 
     /**
@@ -1755,7 +1755,7 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function getBaseTcaCacheIdentifier()
     {
-        return 'tca_base_' . sha1(TYPO3_version . PATH_site . 'tca_code' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
+        return 'tca_base_' . sha1(TYPO3_version . Environment::getProjectPath() . 'tca_code' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
     }
 
     /**
@@ -1857,7 +1857,7 @@ tt_content.' . $key . $suffix . ' {
      */
     protected static function getExtTablesCacheIdentifier()
     {
-        return 'ext_tables_' . sha1(TYPO3_version . PATH_site . 'extTables' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
+        return 'ext_tables_' . sha1(TYPO3_version . Environment::getProjectPath() . 'extTables' . serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['runtimeActivatedPackages']));
     }
 
     /**
diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
index 44ea05289394..d953a01271ec 100644
--- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php
+++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
@@ -2019,7 +2019,7 @@ class GeneralUtility
 
         // Setting main temporary directory name (standard)
         $allowedPathPrefixes = [
-            PATH_site . 'typo3temp' => 'PATH_site + "typo3temp/"'
+            Environment::getPublicPath() . '/typo3temp' => 'Environment::getPublicPath() + "/typo3temp/"'
         ];
         // Also allow project-path + /var/
         if (Environment::getVarPath() !== PATH_site . 'typo3temp/var') {
diff --git a/typo3/sysext/core/Classes/Utility/PathUtility.php b/typo3/sysext/core/Classes/Utility/PathUtility.php
index 075bb37effea..7b0f7b161641 100644
--- a/typo3/sysext/core/Classes/Utility/PathUtility.php
+++ b/typo3/sysext/core/Classes/Utility/PathUtility.php
@@ -42,7 +42,7 @@ class PathUtility
     public static function getAbsoluteWebPath($targetPath)
     {
         if (self::isAbsolutePath($targetPath)) {
-            if (strpos($targetPath, PATH_site) === 0) {
+            if (strpos($targetPath, Environment::getPublicPath()) === 0) {
                 $targetPath = self::stripPathSitePrefix($targetPath);
                 if (!Environment::isCli()) {
                     $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
@@ -362,7 +362,7 @@ class PathUtility
     }
 
     /**
-     * Strip first part of a path, equal to the length of PATH_site
+     * Strip first part of a path, equal to the length of public web path including trailing slash
      *
      * @param string $path
      * @return string
@@ -370,6 +370,6 @@ class PathUtility
      */
     public static function stripPathSitePrefix($path)
     {
-        return substr($path, strlen(PATH_site));
+        return substr($path, strlen(Environment::getPublicPath() . '/'));
     }
 }
diff --git a/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml b/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml
index 0511cea9c830..479bad216a90 100644
--- a/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml
+++ b/typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml
@@ -240,13 +240,13 @@ BE:
             description: 'If enabled, language labels will be shown with additional debug information.'
         fileadminDir:
             type: text
-            description: 'Path to the primary directory of files for editors. This is relative to PATH_site, DefaultStorage will be created with that configuration, do not access manually but via <code>\TYPO3\CMS\Core\Resource\ResourceFactory::getDefaultStorage().</code>'
+            description: 'Path to the primary directory of files for editors. This is relative to the public web dir, DefaultStorage will be created with that configuration, do not access manually but via <code>\TYPO3\CMS\Core\Resource\ResourceFactory::getDefaultStorage().</code>'
         RTE_imageStorageDir:
             type: text
             description: 'Default storage directory for Rich Text Editor files.'
         lockRootPath:
             type: text
-            description: 'This path is used to evaluate if paths outside of PATH_site should be allowed. Ending slash required!'
+            description: 'This path is used to evaluate if paths outside of public web path should be allowed. Ending slash required!'
         userHomePath:
             type: text
             description: 'Combined folder identifier of the directory where TYPO3 backend-users have their home-dirs. A combined folder identifier looks like this: [storageUid]:[folderIdentifier]. Eg. <code>2:users/</code>. A home for backend user 2 would be: <code>2:users/2/</code>. Ending slash required!'
diff --git a/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php b/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php
index 4506a002bb8e..2001cf807e56 100644
--- a/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php
+++ b/typo3/sysext/core/Tests/Functional/Resource/ResourceStorageTest.php
@@ -14,22 +14,24 @@ namespace TYPO3\CMS\Core\Tests\Functional\Resource;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\FolderInterface;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
 use TYPO3\CMS\Core\Resource\StorageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 
 /**
  * Test case
  */
-class ResourceStorageTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
+class ResourceStorageTest extends FunctionalTestCase
 {
     protected function tearDown()
     {
         // cleanup manually created folders
-        foreach (glob(PATH_site . 'fileadmin/*') as $folderToRemove) {
+        foreach (glob(Environment::getPublicPath() . '/fileadmin/*') as $folderToRemove) {
             GeneralUtility::rmdir($folderToRemove, true);
         }
     }
@@ -44,10 +46,10 @@ class ResourceStorageTest extends \TYPO3\TestingFramework\Core\Functional\Functi
         $subject = (new StorageRepository())->findByUid(1);
         $subject->setEvaluatePermissions(false);
 
-        GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/_processed_');
-        GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/adirectory');
-        GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/assets/_processed_/');
-        file_put_contents(PATH_site . 'fileadmin/adirectory/bar.txt', 'myData');
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/_processed_');
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/adirectory');
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/typo3temp/assets/_processed_/');
+        file_put_contents(Environment::getPublicPath() . '/fileadmin/adirectory/bar.txt', 'myData');
         clearstatcache();
         $subject->addFileMount('/adirectory/', ['read_only' => false]);
         $file = ResourceFactory::getInstance()->getFileObjectFromCombinedIdentifier('1:/adirectory/bar.txt');
@@ -78,12 +80,12 @@ class ResourceStorageTest extends \TYPO3\TestingFramework\Core\Functional\Functi
         $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/sys_file_storage.xml');
         $fileName = 'bar.txt';
         $this->setUpBackendUserFromFixture(1);
-        GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/_processed_');
-        GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/' . $targetDirectory);
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/_processed_');
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/' . $targetDirectory);
         if ($fileMountFolder !== $targetDirectory) {
-            GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/' . $fileMountFolder);
+            GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/' . $fileMountFolder);
         }
-        file_put_contents(PATH_site . 'fileadmin/' . $targetDirectory . '/' . $fileName, 'myData');
+        file_put_contents(Environment::getPublicPath() . '/fileadmin/' . $targetDirectory . '/' . $fileName, 'myData');
         clearstatcache();
         $file = ResourceFactory::getInstance()->getFileObjectFromCombinedIdentifier('1:/' . $targetDirectory . '/' . $fileName);
 
@@ -186,14 +188,14 @@ class ResourceStorageTest extends \TYPO3\TestingFramework\Core\Functional\Functi
         $this->setUpBackendUserFromFixture(1);
         $subject = (new StorageRepository())->findByUid(1);
 
-        GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/foo');
-        file_put_contents(PATH_site . 'fileadmin/foo/bar.txt', 'myData');
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/foo');
+        file_put_contents(Environment::getPublicPath() . '/fileadmin/foo/bar.txt', 'myData');
         clearstatcache();
         $file = ResourceFactory::getInstance()->getFileObjectFromCombinedIdentifier('1:/foo/bar.txt');
 
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode(1325842622);
-        $subject->replaceFile($file, PATH_site . $this->getUniqueId());
+        $subject->replaceFile($file, Environment::getPublicPath() . '/' . $this->getUniqueId());
     }
 
     /**
@@ -219,16 +221,16 @@ class ResourceStorageTest extends \TYPO3\TestingFramework\Core\Functional\Functi
         $this->setUpBackendUserFromFixture(1);
         $subject = (new StorageRepository())->findByUid(1);
 
-        GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/foo');
-        GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/_recycler_');
-        file_put_contents(PATH_site . 'fileadmin/foo/bar.txt', 'myData');
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/foo');
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/_recycler_');
+        file_put_contents(Environment::getPublicPath() . '/fileadmin/foo/bar.txt', 'myData');
         clearstatcache();
 
         $file = ResourceFactory::getInstance()->getFileObjectFromCombinedIdentifier('1:/foo/bar.txt');
         $subject->deleteFile($file);
 
-        $this->assertTrue(file_exists(PATH_site . 'fileadmin/_recycler_/bar.txt'));
-        $this->assertFalse(file_exists(PATH_site . 'fileadmin/foo/bar.txt'));
+        $this->assertTrue(file_exists(Environment::getPublicPath() . '/fileadmin/_recycler_/bar.txt'));
+        $this->assertFalse(file_exists(Environment::getPublicPath() . '/fileadmin/foo/bar.txt'));
     }
 
     /**
@@ -240,13 +242,13 @@ class ResourceStorageTest extends \TYPO3\TestingFramework\Core\Functional\Functi
         $this->setUpBackendUserFromFixture(1);
         $subject = (new StorageRepository())->findByUid(1);
 
-        GeneralUtility::mkdir_deep(PATH_site . 'fileadmin/foo');
-        file_put_contents(PATH_site . 'fileadmin/foo/bar.txt', 'myData');
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/fileadmin/foo');
+        file_put_contents(Environment::getPublicPath() . '/fileadmin/foo/bar.txt', 'myData');
         clearstatcache();
 
         $file = ResourceFactory::getInstance()->getFileObjectFromCombinedIdentifier('1:/foo/bar.txt');
         $subject->deleteFile($file);
 
-        $this->assertFalse(file_exists(PATH_site . 'fileadmin/foo/bar.txt'));
+        $this->assertFalse(file_exists(Environment::getPublicPath() . '/fileadmin/foo/bar.txt'));
     }
 }
diff --git a/typo3/sysext/core/Tests/Unit/Configuration/ConfigurationManagerTest.php b/typo3/sysext/core/Tests/Unit/Configuration/ConfigurationManagerTest.php
index dde53514f50b..160aa9cd3c46 100644
--- a/typo3/sysext/core/Tests/Unit/Configuration/ConfigurationManagerTest.php
+++ b/typo3/sysext/core/Tests/Unit/Configuration/ConfigurationManagerTest.php
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Configuration;
  */
 
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -57,7 +58,7 @@ class ConfigurationManagerTest extends UnitTestCase
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1310203814);
 
-        $defaultConfigurationFile = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('defaultConfiguration');
+        $defaultConfigurationFile = Environment::getVarPath() . '/tests/' . $this->getUniqueId('defaultConfiguration');
         file_put_contents(
             $defaultConfigurationFile,
             '<?php throw new \RuntimeException(\'foo\', 1310203814); ?>'
@@ -78,7 +79,7 @@ class ConfigurationManagerTest extends UnitTestCase
     {
         $this->expectException(\RuntimeException::class);
 
-        $configurationFile = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('localConfiguration');
+        $configurationFile = Environment::getVarPath() . '/tests/' . $this->getUniqueId('localConfiguration');
         file_put_contents(
             $configurationFile,
             '<?php throw new \RuntimeException(\'foo\', 1310203815); ?>'
@@ -380,7 +381,7 @@ class ConfigurationManagerTest extends UnitTestCase
         $subject = $this->getAccessibleMock(ConfigurationManager::class, ['dummy']);
 
         $file = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
-        $absoluteFile = PATH_site . $file;
+        $absoluteFile = Environment::getPublicPath() . '/' . $file;
         touch($absoluteFile);
         $this->testFilesToDelete[] = $absoluteFile;
         chmod($absoluteFile, 0444);
@@ -404,11 +405,11 @@ class ConfigurationManagerTest extends UnitTestCase
         $subject = $this->getAccessibleMock(ConfigurationManager::class, ['dummy']);
 
         $directory = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
-        $absoluteDirectory = PATH_site . $directory;
+        $absoluteDirectory = Environment::getPublicPath() . '/' . $directory;
         mkdir($absoluteDirectory);
 
         $file = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
-        $absoluteFile1 = PATH_site . $file;
+        $absoluteFile1 = Environment::getPublicPath() . '/' . $file;
         touch($absoluteFile1);
         $this->testFilesToDelete[] = $absoluteFile1;
         $subject->_set('localConfigurationFile', $absoluteFile1);
@@ -426,7 +427,7 @@ class ConfigurationManagerTest extends UnitTestCase
      */
     public function writeLocalConfigurationWritesSortedContentToConfigurationFile(): void
     {
-        $configurationFile = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('localConfiguration');
+        $configurationFile = Environment::getVarPath() . '/tests/' . $this->getUniqueId('localConfiguration');
         if (!is_file($configurationFile)) {
             if (!$fh = fopen($configurationFile, 'wb')) {
                 $this->markTestSkipped('Can not create file ' . $configurationFile . '. Please check your write permissions.');
@@ -473,7 +474,7 @@ class ConfigurationManagerTest extends UnitTestCase
         $subject = $this->getAccessibleMock(ConfigurationManager::class, ['dummy']);
 
         $file = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
-        $absoluteFile = PATH_site . $file;
+        $absoluteFile = Environment::getPublicPath() . '/' . $file;
         touch($absoluteFile);
         $this->testFilesToDelete[] = $absoluteFile;
         $subject->_set('localConfigurationFile', $file);
@@ -491,7 +492,7 @@ class ConfigurationManagerTest extends UnitTestCase
         $subject->_set('localConfigurationFile', 'typo3temp/var/tests/' . $this->getUniqueId('dummy_'));
 
         $factoryConfigurationFile = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '.php';
-        $factoryConfigurationAbsoluteFile = PATH_site . $factoryConfigurationFile;
+        $factoryConfigurationAbsoluteFile = Environment::getPublicPath() . '/' . $factoryConfigurationFile;
         $uniqueContentString = $this->getUniqueId('string_');
         $validFactoryConfigurationFileContent =
             '<?php' . LF .
@@ -523,7 +524,7 @@ class ConfigurationManagerTest extends UnitTestCase
         $subject->_set('localConfigurationFile', 'typo3temp/var/tests/' . $this->getUniqueId('dummy_'));
 
         $factoryConfigurationFile = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '.php';
-        $factoryConfigurationAbsoluteFile = PATH_site . $factoryConfigurationFile;
+        $factoryConfigurationAbsoluteFile = Environment::getPublicPath() . '/' . $factoryConfigurationFile;
         $validFactoryConfigurationFileContent =
             '<?php' . LF .
             'return [];' . LF;
@@ -535,7 +536,7 @@ class ConfigurationManagerTest extends UnitTestCase
         $subject->_set('factoryConfigurationFile', $factoryConfigurationFile);
 
         $additionalFactoryConfigurationFile = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '.php';
-        $additionalFactoryConfigurationAbsoluteFile = PATH_site . $additionalFactoryConfigurationFile;
+        $additionalFactoryConfigurationAbsoluteFile = Environment::getPublicPath() . '/' . $additionalFactoryConfigurationFile;
         $uniqueContentString = $this->getUniqueId('string_');
         $validAdditionalFactoryConfigurationFileContent =
             '<?php' . LF .
diff --git a/typo3/sysext/core/Tests/Unit/Http/NormalizedParamsTest.php b/typo3/sysext/core/Tests/Unit/Http/NormalizedParamsTest.php
index 0e0354776527..66f8c3e2e0dd 100644
--- a/typo3/sysext/core/Tests/Unit/Http/NormalizedParamsTest.php
+++ b/typo3/sysext/core/Tests/Unit/Http/NormalizedParamsTest.php
@@ -964,7 +964,7 @@ class NormalizedParamsTest extends UnitTestCase
             'PATH_INFO' => '/typo3/index.php',
         ];
         $pathThisScript = '/var/www/myInstance/Web/typo3/index.php';
-        $pathSite = '/var/www/myInstance/Web/';
+        $pathSite = '/var/www/myInstance/Web';
         $expected = 'http://www.domain.com/';
         $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);
         $serverRequestProphecy->getServerParams()->willReturn($serverParams);
@@ -990,7 +990,7 @@ class NormalizedParamsTest extends UnitTestCase
                     'HTTP_HOST' => 'www.domain.com',
                 ],
                 '/var/www/myInstance/Web/typo3/index.php',
-                '/var/www/myInstance/Web/',
+                '/var/www/myInstance/Web',
                 '/'
             ],
             'in a sub directory' => [
@@ -999,7 +999,7 @@ class NormalizedParamsTest extends UnitTestCase
                     'HTTP_HOST' => 'www.domain.com',
                 ],
                 '/var/www/myInstance/Web/typo3/index.php',
-                '/var/www/myInstance/Web/',
+                '/var/www/myInstance/Web',
                 '/some/sub/dir/'
             ],
         ];
@@ -1033,7 +1033,7 @@ class NormalizedParamsTest extends UnitTestCase
                     'HTTP_HOST' => 'www.domain.com',
                 ],
                 '/var/www/myInstance/Web/typo3/index.php',
-                '/var/www/myInstance/Web/',
+                '/var/www/myInstance/Web',
                 'typo3/index.php?id=42&foo=bar'
             ],
             'in a sub directory' => [
@@ -1042,7 +1042,7 @@ class NormalizedParamsTest extends UnitTestCase
                     'HTTP_HOST' => 'www.domain.com',
                 ],
                 '/var/www/myInstance/Web/typo3/index.php',
-                '/var/www/myInstance/Web/',
+                '/var/www/myInstance/Web',
                 'typo3/index.php?id=42&foo=bar'
             ],
         ];
diff --git a/typo3/sysext/core/Tests/Unit/Http/StreamTest.php b/typo3/sysext/core/Tests/Unit/Http/StreamTest.php
index ddd194c9f4fd..060b280434a0 100644
--- a/typo3/sysext/core/Tests/Unit/Http/StreamTest.php
+++ b/typo3/sysext/core/Tests/Unit/Http/StreamTest.php
@@ -14,14 +14,16 @@ namespace TYPO3\CMS\Core\Tests\Unit\Http;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Http\Stream;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for \TYPO3\CMS\Core\Http\StreamTest
+ * Test case
  *
  * Adapted from https://github.com/phly/http/
  */
-class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class StreamTest extends UnitTestCase
 {
     /**
      * @var Stream
@@ -56,7 +58,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isReadableReturnsFalseIfStreamIsNotReadable()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $stream = new Stream($fileName, 'w');
@@ -106,7 +108,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function toStringSerializationReturnsEmptyStringWhenStreamIsNotReadable()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
@@ -120,7 +122,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function closeClosesResource()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'wb+');
@@ -134,7 +136,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function closeUnsetsResource()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'wb+');
@@ -149,7 +151,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function closeDoesNothingAfterDetach()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'wb+');
@@ -175,7 +177,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function tellReportsCurrentPositionInResource()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -191,7 +193,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function tellRaisesExceptionIfResourceIsDetached()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -209,7 +211,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function eofReportsFalseWhenNotAtEndOfStream()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -224,7 +226,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function eofReportsTrueWhenAtEndOfStream()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -241,7 +243,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function eofReportsTrueWhenStreamIsDetached()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -257,7 +259,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isSeekableReturnsTrueForReadableStreams()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -270,7 +272,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isSeekableReturnsFalseForDetachedStreams()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -284,7 +286,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function seekAdvancesToGivenOffsetOfStream()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -298,7 +300,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function rewindResetsToStartOfStream()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -313,7 +315,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function seekRaisesExceptionWhenStreamIsDetached()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -329,7 +331,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isWritableReturnsFalseWhenStreamIsDetached()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -343,7 +345,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function writeRaisesExceptionWhenStreamIsDetached()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -359,7 +361,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isReadableReturnsFalseWhenStreamIsDetached()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'wb+');
@@ -373,7 +375,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function readRaisesExceptionWhenStreamIsDetached()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'r');
@@ -389,7 +391,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function readReturnsEmptyStringWhenAtEndOfFile()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'r');
@@ -405,7 +407,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getContentsReturnsEmptyStringIfStreamIsNotReadable()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         $this->testFilesToDelete[] = $fileName;
         file_put_contents($fileName, 'FOO BAR');
         $resource = fopen($fileName, 'w');
@@ -458,7 +460,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function attachWithResourceAttachesResource()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'r+');
@@ -475,7 +477,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function attachWithStringRepresentingResourceCreatesAndAttachesResource()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $this->stream->attach($fileName);
@@ -493,7 +495,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getContentsShouldGetFullStreamContents()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'r+');
@@ -512,7 +514,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getContentsShouldReturnStreamContentsFromCurrentPointer()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'r+');
@@ -531,7 +533,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getMetadataReturnsAllMetadataWhenNoKeyPresent()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'r+');
@@ -548,7 +550,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getMetadataReturnsDataForSpecifiedKey()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'r+');
@@ -567,7 +569,7 @@ class StreamTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getMetadataReturnsNullIfNoDataExistsForKey()
     {
-        $fileName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $fileName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_');
         touch($fileName);
         $this->testFilesToDelete[] = $fileName;
         $resource = fopen($fileName, 'r+');
diff --git a/typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php b/typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php
index 7dc17d68140f..c2f07d2a06dc 100644
--- a/typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php
+++ b/typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php
@@ -18,6 +18,7 @@ use Prophecy\Argument;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Localization\Exception\FileNotFoundException;
 use TYPO3\CMS\Core\Localization\LanguageStore;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
@@ -59,7 +60,7 @@ class LocalizationFactoryTest extends UnitTestCase
 					</languageKey>
 				</data>
 			</T3locallang>';
-        $file = PATH_site . 'typo3temp/var/tests/' . $unique . '.xml';
+        $file = Environment::getVarPath() . '/tests/' . $unique . '.xml';
         GeneralUtility::writeFileToTypo3tempDir($file, $xml);
         $this->testFilesToDelete[] = $file;
 
diff --git a/typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php b/typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php
index 1b7e2ce730b3..e665683bd6f3 100644
--- a/typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php
+++ b/typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php
@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization\Parser;
 use Prophecy\Argument;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Localization\LanguageStore;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Localization\Parser\LocallangXmlParser;
@@ -57,7 +58,7 @@ class LocallangXmlParserTest extends UnitTestCase
     protected static function getFixtureFilePath($filename)
     {
         // We have to take the whole relative path as otherwise this test fails on Windows systems
-        return PATH_site . 'typo3/sysext/core/Tests/Unit/Localization/Parser/Fixtures/' . $filename;
+        return Environment::getPublicPath() . '/typo3/sysext/core/Tests/Unit/Localization/Parser/Fixtures/' . $filename;
     }
 
     /**
diff --git a/typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php b/typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php
index 2f6f6b4eb136..a9b2e2a7afb3 100644
--- a/typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php
+++ b/typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization\Parser;
 use Prophecy\Argument;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Localization\Parser\XliffParser;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -38,7 +39,7 @@ class XliffParserTest extends UnitTestCase
     protected function setUp()
     {
         // We have to take the whole relative path as otherwise this test fails on Windows systems
-        $fixturePath = PATH_site . 'typo3/sysext/core/Tests/Unit/Localization/Parser/Fixtures/';
+        $fixturePath = Environment::getPublicPath() . '/typo3/sysext/core/Tests/Unit/Localization/Parser/Fixtures/';
         $this->xliffFileNames = [
             'locallang' => $fixturePath . 'locallang.xlf',
             'locallang_override' => $fixturePath . 'locallang_override.xlf',
diff --git a/typo3/sysext/core/Tests/Unit/Locking/SemaphoreLockStrategyTest.php b/typo3/sysext/core/Tests/Unit/Locking/SemaphoreLockStrategyTest.php
index d02e8af29e32..39d6d61ae89b 100644
--- a/typo3/sysext/core/Tests/Unit/Locking/SemaphoreLockStrategyTest.php
+++ b/typo3/sysext/core/Tests/Unit/Locking/SemaphoreLockStrategyTest.php
@@ -15,11 +15,12 @@ namespace TYPO3\CMS\Core\Tests\Unit\Locking;
  */
 
 use TYPO3\CMS\Core\Locking\SemaphoreLockStrategy;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for \TYPO3\CMS\Core\Locking\SemaphoreLockStrategy
+ * Test case
  */
-class SemaphoreLockStrategyTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class SemaphoreLockStrategyTest extends UnitTestCase
 {
     /**
      * Set up the tests
diff --git a/typo3/sysext/core/Tests/Unit/Locking/SimpleLockStrategyTest.php b/typo3/sysext/core/Tests/Unit/Locking/SimpleLockStrategyTest.php
index 6098e62e5654..d5b220eafee7 100644
--- a/typo3/sysext/core/Tests/Unit/Locking/SimpleLockStrategyTest.php
+++ b/typo3/sysext/core/Tests/Unit/Locking/SimpleLockStrategyTest.php
@@ -90,7 +90,7 @@ class SimpleLockStrategyTest extends UnitTestCase
     public function invalidFileReferences()
     {
         return [
-            'not within PATH_site' => [tempnam(sys_get_temp_dir(), 'foo')],
+            'not within project path' => [tempnam(sys_get_temp_dir(), 'foo')],
             'directory traversal' => [Environment::getVarPath() . '/../var/lock/foo'],
             'directory traversal 2' => [Environment::getVarPath() . '/lock/../../var/lock/foo'],
             'within uploads' => [Environment::getPublicPath() . '/uploads/TYPO3-Lock-Test']
diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
index ee6b68e07e52..61bfbe957378 100644
--- a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
+++ b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
@@ -86,7 +86,7 @@ class LocalDriverTest extends BaseTestCase
      */
     protected function createRealTestdir(): string
     {
-        $basedir = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('fal-test-');
+        $basedir = Environment::getVarPath() . '/tests/' . $this->getUniqueId('fal-test-');
         mkdir($basedir);
         $this->testDirs[] = $basedir;
         return $basedir;
@@ -164,7 +164,7 @@ class LocalDriverTest extends BaseTestCase
 
         // This test checks if "/../" are properly filtered out (i.e. from "Base path" field of sys_file_storage)
         $relativeDriverConfiguration = [
-            'basePath' => PATH_site . 'typo3temp/var/tests/../../../typo3temp/var/tests/',
+            'basePath' => Environment::getVarPath() . '/tests/../../../typo3temp/var/tests/',
         ];
         $basePath = $subject->_call('calculateBasePath', $relativeDriverConfiguration);
 
@@ -200,7 +200,7 @@ class LocalDriverTest extends BaseTestCase
             ->will(
                 $this->returnValue(true)
             );
-        $driver->_set('absoluteBasePath', PATH_site . 'un encö/ded %path/');
+        $driver->_set('absoluteBasePath', Environment::getPublicPath() . '/un encö/ded %path/');
         $driver->_call('determineBaseUrl');
         $baseUri = $driver->_get('baseUri');
         $this->assertEquals(rawurlencode('un encö') . '/' . rawurlencode('ded %path') . '/', $baseUri);
@@ -377,13 +377,13 @@ class LocalDriverTest extends BaseTestCase
         if (in_array($property, ['mtime', 'ctime', 'atime'])) {
             $expectedValue = $directory->getChild('Dummy.html')->filemtime();
         }
-        FileStreamWrapper::init(PATH_site);
+        FileStreamWrapper::init(Environment::getPublicPath() . '/');
         FileStreamWrapper::registerOverlayPath('fileadmin', 'vfs://root/fileadmin', false);
 
-        $subject = $this->createDriver(['basePath' => PATH_site . 'fileadmin']);
+        $subject = $this->createDriver(['basePath' => Environment::getPublicPath() . '/fileadmin']);
         $this->assertSame(
             $expectedValue,
-            $subject->getSpecificFileInformation(PATH_site . 'fileadmin/Dummy.html', '/', $property)
+            $subject->getSpecificFileInformation(Environment::getPublicPath() . '/fileadmin/Dummy.html', '/', $property)
         );
 
         FileStreamWrapper::destroy();
@@ -659,10 +659,10 @@ class LocalDriverTest extends BaseTestCase
         $root->addChild($subFolder);
         // Load fixture files and folders from disk
         vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/', $subFolder, 1024*1024);
-        FileStreamWrapper::init(PATH_site);
+        FileStreamWrapper::init(Environment::getPublicPath() . '/');
         FileStreamWrapper::registerOverlayPath('fileadmin/', 'vfs://root/fileadmin/', false);
 
-        $subject = $this->createDriver(['basePath' => PATH_site . 'fileadmin']);
+        $subject = $this->createDriver(['basePath' => Environment::getPublicPath() . '/fileadmin']);
 
         $subdirFileInfo = $subject->getFileInfoByIdentifier('Dummy.html');
         $this->assertEquals('/Dummy.html', $subdirFileInfo['identifier']);
diff --git a/typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorIntegrationTest.php b/typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorIntegrationTest.php
index 15bbc7c3b709..f7a4d6d89b4e 100644
--- a/typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorIntegrationTest.php
+++ b/typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorIntegrationTest.php
@@ -15,11 +15,12 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Tests\Unit\Resource\ResourceCompressorTest\Fixtures\TestableResourceCompressor;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
- * Testcase for the ResourceCompressor class
+ * Test case
  */
 class ResourceCompressorIntegrationTest extends BaseTestCase
 {
@@ -55,7 +56,7 @@ class ResourceCompressorIntegrationTest extends BaseTestCase
     public function constructorCreatesTargetDirectory()
     {
         $this->resourceCompressor = new TestableResourceCompressor();
-        $dir = PATH_site . $this->resourceCompressor->getTargetDirectory();
+        $dir = Environment::getPublicPath() . '/' . $this->resourceCompressor->getTargetDirectory();
         self::assertFileExists($dir);
     }
 
@@ -66,7 +67,7 @@ class ResourceCompressorIntegrationTest extends BaseTestCase
     {
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['generateApacheHtaccess'] = true;
         $this->resourceCompressor = new TestableResourceCompressor();
-        $htaccessPath = PATH_site . $this->resourceCompressor->getTargetDirectory() . '.htaccess';
+        $htaccessPath = Environment::getPublicPath() . '/' . $this->resourceCompressor->getTargetDirectory() . '.htaccess';
         self::assertStringEqualsFile($htaccessPath, $this->resourceCompressor->getHtaccessTemplate());
     }
 
@@ -77,7 +78,7 @@ class ResourceCompressorIntegrationTest extends BaseTestCase
     {
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['generateApacheHtaccess'] = false;
         $this->resourceCompressor = new TestableResourceCompressor();
-        $htaccessPath = PATH_site . $this->resourceCompressor->getTargetDirectory() . '.htaccess';
+        $htaccessPath = Environment::getPublicPath() . '/' . $this->resourceCompressor->getTargetDirectory() . '.htaccess';
         self::assertFileNotExists($htaccessPath);
     }
 
@@ -100,7 +101,7 @@ class ResourceCompressorIntegrationTest extends BaseTestCase
         $expected = file_get_contents(
             $this->fixtureDirFromTest . 'expected' . DIRECTORY_SEPARATOR . 'merged-css_input_with_import.css'
         );
-        self::assertStringEqualsFile(GeneralUtility::fixWindowsFilePath(PATH_site . $mergedFile['file']), $expected);
+        self::assertStringEqualsFile(GeneralUtility::fixWindowsFilePath(Environment::getPublicPath() . '/' . $mergedFile['file']), $expected);
     }
 
     /**
@@ -108,7 +109,7 @@ class ResourceCompressorIntegrationTest extends BaseTestCase
      */
     public function concatenateCssFilesWorksWithFileFromNonRootPath()
     {
-        $testFile = PATH_site . 'typo3temp/var/transient/css_input_with_import.css';
+        $testFile = Environment::getPublicPath() . '/typo3temp/var/transient/css_input_with_import.css';
         $this->testFilesToDelete[] = $testFile;
         copy(PATH_typo3 . $this->fixtureDir . 'css_input_with_import.css', $testFile);
         $files = [
@@ -125,12 +126,12 @@ class ResourceCompressorIntegrationTest extends BaseTestCase
         $expected = file_get_contents(
             $this->fixtureDirFromTest . 'expected' . DIRECTORY_SEPARATOR . 'merged-css_input_with_import_non_root.css'
         );
-        self::assertStringEqualsFile(GeneralUtility::fixWindowsFilePath(PATH_site . $mergedFile['file']), $expected);
+        self::assertStringEqualsFile(GeneralUtility::fixWindowsFilePath(Environment::getPublicPath() . '/' . $mergedFile['file']), $expected);
     }
 
     public function tearDown()
     {
-        $this->testFilesToDelete[] = PATH_site . $this->resourceCompressor->getTargetDirectory();
+        $this->testFilesToDelete[] = Environment::getPublicPath() . '/' . $this->resourceCompressor->getTargetDirectory();
         parent::tearDown();
     }
 }
diff --git a/typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorTest.php b/typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorTest.php
index 4c873a1be4fd..8a5641a3aa0b 100644
--- a/typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorTest.php
+++ b/typo3/sysext/core/Tests/Unit/Resource/ResourceCompressorTest.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Resource\ResourceCompressor;
 use TYPO3\CMS\Core\Utility\PathUtility;
 
@@ -521,7 +522,7 @@ class ResourceCompressorTest extends BaseTestCase
         $cssContent = file_get_contents($cssFile);
         $compressedCss = $this->subject->_call('compressCssString', $cssContent);
         // we have to fix relative paths, if we aren't working on a file in our target directory
-        $relativeFilename = str_replace(PATH_site, '', $cssFile);
+        $relativeFilename = str_replace(Environment::getPublicPath() . '/', '', $cssFile);
         if (strpos($relativeFilename, $this->subject->_get('targetDirectory')) === false) {
             $compressedCss = $this->subject->_call('cssFixRelativeUrlPaths', $compressedCss, PathUtility::dirname($relativeFilename) . '/');
         }
diff --git a/typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php b/typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php
index bdcb7f42bb20..1b9a387ca43b 100644
--- a/typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php
+++ b/typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -132,7 +133,7 @@ class ResourceFactoryTest extends UnitTestCase
             ->expects($this->once())
             ->method('getFolderObjectFromCombinedIdentifier')
             ->with('typo3');
-        $subject->retrieveFileOrFolderObject(PATH_site . 'typo3');
+        $subject->retrieveFileOrFolderObject(Environment::getPublicPath() . '/typo3');
     }
 
     /**
@@ -146,8 +147,8 @@ class ResourceFactoryTest extends UnitTestCase
             ->method('getFileObjectFromCombinedIdentifier')
             ->with($filename);
         // Create and prepare test file
-        \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filename, '42');
-        $this->filesCreated[] = PATH_site . $filename;
+        \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir(Environment::getPublicPath() . '/' . $filename, '42');
+        $this->filesCreated[] = Environment::getPublicPath() . '/' . $filename;
         $this->subject->retrieveFileOrFolderObject($filename);
     }
 
diff --git a/typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php
index 4dd677ee81f1..54d2296c1f8e 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php
@@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend;
 use TYPO3\CMS\Core\Category\CategoryRegistry;
 use TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Package\MetaData;
 use TYPO3\CMS\Core\Package\Package;
 use TYPO3\CMS\Core\Package\PackageManager;
@@ -73,7 +74,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
      */
     protected function createMockPackageManagerWithMockPackage($packageKey, $packageMethods = ['getPackagePath', 'getPackageKey'])
     {
-        $packagePath = PATH_site . 'typo3temp/var/tests/' . $packageKey . '/';
+        $packagePath = Environment::getVarPath() . '/tests/' . $packageKey . '/';
         GeneralUtility::mkdir_deep($packagePath);
         $this->testFilesToDelete[] = $packagePath;
         $package = $this->getMockBuilder(Package::class)
@@ -158,7 +159,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
             ->getMock();
         $package->expects($this->once())
                 ->method('getPackagePath')
-                ->will($this->returnValue(PATH_site . 'foo/'));
+                ->will($this->returnValue(Environment::getPublicPath() . '/foo/'));
         $packageManager->expects($this->once())
                 ->method('isPackageActive')
                 ->with($this->equalTo('foo'))
@@ -168,7 +169,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
                 ->with('foo')
                 ->will($this->returnValue($package));
         ExtensionManagementUtility::setPackageManager($packageManager);
-        $this->assertSame(PATH_site . 'foo/bar.txt', ExtensionManagementUtility::extPath('foo', 'bar.txt'));
+        $this->assertSame(Environment::getPublicPath() . '/foo/bar.txt', ExtensionManagementUtility::extPath('foo', 'bar.txt'));
     }
 
     //////////////////////
@@ -1573,7 +1574,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
     public function createExtTablesCacheEntryWritesCacheEntryWithContentOfLoadedExtensionExtTables()
     {
         $extensionName = $this->getUniqueId('foo');
-        $extTablesLocation = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_ext_tables') . '.php';
+        $extTablesLocation = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_ext_tables') . '.php';
         $this->testFilesToDelete[] = $extTablesLocation;
         $uniqueStringInTables = $this->getUniqueId('foo');
         file_put_contents($extTablesLocation, "<?php\n\n$uniqueStringInTables\n\n?>");
diff --git a/typo3/sysext/core/Tests/Unit/Utility/Fixtures/GeneralUtilityFilesystemFixture.php b/typo3/sysext/core/Tests/Unit/Utility/Fixtures/GeneralUtilityFilesystemFixture.php
index eb08077df995..cae860642e5f 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/Fixtures/GeneralUtilityFilesystemFixture.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/Fixtures/GeneralUtilityFilesystemFixture.php
@@ -57,7 +57,7 @@ class GeneralUtilityFilesystemFixture extends GeneralUtility
     /**
      * For testing we must skip the path checks
      *
-     * @param string $filepath Absolute file path to write to inside "typo3temp/". First part of this string must match PATH_site."typo3temp/"
+     * @param string $filepath Absolute file path to write to inside "typo3temp/". First part of this string must match Environment::getPublicPath() ."/typo3temp/"
      * @param string $content Content string to write
      * @return string Returns NULL on success, otherwise an error string telling about the problem.
      */
diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
index d2123fa2776d..f0ca838fb7f7 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
@@ -1976,7 +1976,7 @@ class GeneralUtilityTest extends UnitTestCase
             '../typo3/alt_intro.php' => ['../typo3/alt_intro.php'],
             '../~userDirectory/index.php' => ['../~userDirectory/index.php'],
             '../typo3/index.php?var1=test-case&var2=~user' => ['../typo3/index.php?var1=test-case&var2=~user'],
-            PATH_site . 'typo3/alt_intro.php' => [PATH_site . 'typo3/alt_intro.php'],
+            Environment::getPublicPath() . '/typo3/alt_intro.php' => [Environment::getPublicPath() . '/typo3/alt_intro.php'],
         ];
     }
 
@@ -2110,7 +2110,7 @@ class GeneralUtilityTest extends UnitTestCase
     public function unlink_tempfileRemovesValidFileInTypo3temp()
     {
         $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
-        $testFilename = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '.gif';
+        $testFilename = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_') . '.gif';
         @copy($fixtureFile, $testFilename);
         GeneralUtility::unlink_tempfile($testFilename);
         $fileExists = file_exists($testFilename);
@@ -2123,7 +2123,7 @@ class GeneralUtilityTest extends UnitTestCase
     public function unlink_tempfileRemovesHiddenFile()
     {
         $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
-        $testFilename = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('.test_') . '.gif';
+        $testFilename = Environment::getVarPath() . '/tests/' . $this->getUniqueId('.test_') . '.gif';
         @copy($fixtureFile, $testFilename);
         GeneralUtility::unlink_tempfile($testFilename);
         $fileExists = file_exists($testFilename);
@@ -2136,7 +2136,7 @@ class GeneralUtilityTest extends UnitTestCase
     public function unlink_tempfileReturnsTrueIfFileWasRemoved()
     {
         $fixtureFile = __DIR__ . '/Fixtures/clear.gif';
-        $testFilename = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '.gif';
+        $testFilename = Environment::getVarPath() . '/tests/' . $this->getUniqueId('test_') . '.gif';
         @copy($fixtureFile, $testFilename);
         $returnValue = GeneralUtility::unlink_tempfile($testFilename);
         $this->assertTrue($returnValue);
@@ -2147,7 +2147,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function unlink_tempfileReturnsNullIfFileDoesNotExist()
     {
-        $returnValue = GeneralUtility::unlink_tempfile(PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('i_do_not_exist'));
+        $returnValue = GeneralUtility::unlink_tempfile(Environment::getVarPath() . '/tests/' . $this->getUniqueId('i_do_not_exist'));
         $this->assertNull($returnValue);
     }
 
@@ -2192,7 +2192,7 @@ class GeneralUtilityTest extends UnitTestCase
     {
         $filePath = GeneralUtility::tempnam('foo');
         $this->testFilesToDelete[] = $filePath;
-        $this->assertStringStartsWith(PATH_site, $filePath);
+        $this->assertStringStartsWith(Environment::getPublicPath() . '/', $filePath);
     }
 
     //////////////////////////////////////
@@ -2700,7 +2700,7 @@ class GeneralUtilityTest extends UnitTestCase
             $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
         }
         // Create and prepare test file
-        $filename = PATH_site . 'typo3temp/var/tests/../../../typo3temp/var/tests/' . $this->getUniqueId('test_');
+        $filename = Environment::getVarPath() . '/tests/../../../typo3temp/var/tests/' . $this->getUniqueId('test_');
         // Set target permissions and run method
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
         $fixPermissionsResult = GeneralUtility::fixPermissions($filename);
@@ -2716,15 +2716,15 @@ class GeneralUtilityTest extends UnitTestCase
             $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
         }
         $filename = 'typo3temp/var/tests/' . $this->getUniqueId('test_');
-        GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filename, '42');
-        $this->testFilesToDelete[] = PATH_site . $filename;
-        chmod(PATH_site . $filename, 482);
+        GeneralUtility::writeFileToTypo3tempDir(Environment::getPublicPath() . '/' . $filename, '42');
+        $this->testFilesToDelete[] = Environment::getPublicPath() . '/' . $filename;
+        chmod(Environment::getPublicPath() . '/' . $filename, 482);
         // Set target permissions and run method
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0660';
         $fixPermissionsResult = GeneralUtility::fixPermissions($filename);
         clearstatcache();
         $this->assertTrue($fixPermissionsResult);
-        $this->assertEquals('0660', substr(decoct(fileperms(PATH_site . $filename)), 2));
+        $this->assertEquals('0660', substr(decoct(fileperms(Environment::getPublicPath() . '/' . $filename)), 2));
     }
 
     /**
@@ -2884,32 +2884,32 @@ class GeneralUtilityTest extends UnitTestCase
     {
         return [
             [
-                PATH_site . '../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
-                'Input filepath "' . PATH_site . '../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
+                Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
+                'Input filepath "' . Environment::getPublicPath() . '/../path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
             ],
             [
-                PATH_site . 'dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
-                'Input filepath "' . PATH_site . 'dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
+                Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
+                'Input filepath "' . Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
             ],
             [
-                PATH_site . 'dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
-                'Input filepath "' . PATH_site . 'dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
+                Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more',
+                'Input filepath "' . Environment::getPublicPath() . '/dummy/path/this-path-has-more-than-60-characters-in-one-base-path-you-can-even-count-more" was generally invalid!'
             ],
             [
                 '/dummy/path/awesome',
-                '"/dummy/path/" was not within directory PATH_site + "typo3temp/"'
+                '"/dummy/path/" was not within directory Environment::getPublicPath() + "/typo3temp/"'
             ],
             [
-                PATH_site . 'typo3conf/path',
-                '"' . PATH_site . 'typo3conf/" was not within directory PATH_site + "typo3temp/"',
+                Environment::getPublicPath() . '/typo3conf/path',
+                '"' . Environment::getPublicPath() . '/typo3conf/" was not within directory Environment::getPublicPath() + "/typo3temp/"',
             ],
             [
-                PATH_site . 'typo3temp/táylor/swíft',
+                Environment::getPublicPath() . '/typo3temp/táylor/swíft',
                 'Subdir, "táylor/", was NOT on the form "[[:alnum:]_]/+"',
             ],
             'Path instead of file given' => [
-                PATH_site . 'typo3temp/dummy/path/',
-                'Calculated file location didn\'t match input "' . PATH_site . 'typo3temp/dummy/path/".'
+                Environment::getPublicPath() . '/typo3temp/dummy/path/',
+                'Calculated file location didn\'t match input "' . Environment::getPublicPath() . '/typo3temp/dummy/path/".'
             ],
         ];
     }
@@ -2933,16 +2933,16 @@ class GeneralUtilityTest extends UnitTestCase
     {
         return [
             'Default text file' => [
-                PATH_site . 'typo3temp/var/paranoid/android.txt',
+                Environment::getPublicPath() . '/typo3temp/var/paranoid/android.txt',
             ],
             'Html file extension' => [
-                PATH_site . 'typo3temp/var/karma.html',
+                Environment::getPublicPath() . '/typo3temp/var/karma.html',
             ],
             'No file extension' => [
-                PATH_site . 'typo3temp/var/no-surprises',
+                Environment::getPublicPath() . '/typo3temp/var/no-surprises',
             ],
             'Deep directory' => [
-                PATH_site . 'typo3temp/var/climbing/up/the/walls',
+                Environment::getPublicPath() . '/typo3temp/var/climbing/up/the/walls',
             ],
         ];
     }
@@ -2996,8 +2996,8 @@ class GeneralUtilityTest extends UnitTestCase
     public function mkdirDeepCreatesDirectoryWithAndWithoutDoubleSlashesDataProvider()
     {
         return [
-            'no double slash if concatenated with PATH_site' => ['fileadmin/testDir1'],
-            'double slash if concatenated with PATH_site' => ['/fileadmin/testDir2'],
+            'no double slash if concatenated with Environment::getPublicPath()' => ['fileadmin/testDir1'],
+            'double slash if concatenated with Environment::getPublicPath()' => ['/fileadmin/testDir2'],
         ];
     }
 
@@ -3009,10 +3009,10 @@ class GeneralUtilityTest extends UnitTestCase
     {
         vfsStream::setup();
         // Load fixture files and folders from disk
-        FileStreamWrapper::init(PATH_site);
+        FileStreamWrapper::init(Environment::getPublicPath());
         FileStreamWrapper::registerOverlayPath('fileadmin', 'vfs://root/fileadmin', true);
-        GeneralUtility::mkdir_deep(PATH_site . $directoryToCreate);
-        $this->assertTrue(is_dir(PATH_site . $directoryToCreate));
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/' . $directoryToCreate);
+        $this->assertTrue(is_dir(Environment::getPublicPath() . '/' . $directoryToCreate));
         FileStreamWrapper::destroy();
     }
 
@@ -3027,11 +3027,11 @@ class GeneralUtilityTest extends UnitTestCase
         $directory = $this->getUniqueId('mkdirdeeptest_');
         $oldUmask = umask(19);
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
-        GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $directory);
-        $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory;
+        GeneralUtility::mkdir_deep(Environment::getVarPath() . '/tests/' . $directory);
+        $this->testFilesToDelete[] = Environment::getVarPath() . '/tests/' . $directory;
         clearstatcache();
         umask($oldUmask);
-        $this->assertEquals('777', substr(decoct(fileperms(PATH_site . 'typo3temp/var/tests/' . $directory)), -3, 3));
+        $this->assertEquals('777', substr(decoct(fileperms(Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
     }
 
     /**
@@ -3046,11 +3046,11 @@ class GeneralUtilityTest extends UnitTestCase
         $subDirectory = $directory . '/bar';
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] = '0777';
         $oldUmask = umask(19);
-        GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $subDirectory);
-        $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory;
+        GeneralUtility::mkdir_deep(Environment::getVarPath() . '/tests/' . $subDirectory);
+        $this->testFilesToDelete[] = Environment::getVarPath() . '/tests/' . $directory;
         clearstatcache();
         umask($oldUmask);
-        $this->assertEquals('777', substr(decoct(fileperms(PATH_site . 'typo3temp/var/tests/' . $directory)), -3, 3));
+        $this->assertEquals('777', substr(decoct(fileperms(Environment::getVarPath() . '/tests/' . $directory)), -3, 3));
     }
 
     /**
@@ -3061,7 +3061,7 @@ class GeneralUtilityTest extends UnitTestCase
         if (Environment::isWindows()) {
             $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
         }
-        $baseDirectory = PATH_site . 'typo3temp/var/tests/';
+        $baseDirectory = Environment::getVarPath() . '/tests/';
         $existingDirectory = $this->getUniqueId('test_existing_') . '/';
         $newSubDirectory = $this->getUniqueId('test_new_');
         @mkdir($baseDirectory . $existingDirectory);
@@ -3080,10 +3080,10 @@ class GeneralUtilityTest extends UnitTestCase
         if ($swapGroup !== false) {
             $GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup;
             $directory = $this->getUniqueId('mkdirdeeptest_');
-            GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $directory);
-            $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory;
+            GeneralUtility::mkdir_deep(Environment::getVarPath() . '/tests/' . $directory);
+            $this->testFilesToDelete[] = Environment::getVarPath() . '/tests/' . $directory;
             clearstatcache();
-            $resultDirectoryGroup = filegroup(PATH_site . 'typo3temp/var/tests/' . $directory);
+            $resultDirectoryGroup = filegroup(Environment::getVarPath() . '/tests/' . $directory);
             $this->assertEquals($resultDirectoryGroup, $swapGroup);
         }
     }
@@ -3098,10 +3098,10 @@ class GeneralUtilityTest extends UnitTestCase
             $GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup;
             $directory = $this->getUniqueId('mkdirdeeptest_');
             $subDirectory = $directory . '/bar';
-            GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $subDirectory);
-            $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory;
+            GeneralUtility::mkdir_deep(Environment::getVarPath() . '/tests/' . $subDirectory);
+            $this->testFilesToDelete[] = Environment::getVarPath() . '/tests/' . $directory;
             clearstatcache();
-            $resultDirectoryGroup = filegroup(PATH_site . 'typo3temp/var/tests/' . $directory);
+            $resultDirectoryGroup = filegroup(Environment::getVarPath() . '/tests/' . $directory);
             $this->assertEquals($resultDirectoryGroup, $swapGroup);
         }
     }
@@ -3116,10 +3116,10 @@ class GeneralUtilityTest extends UnitTestCase
             $GLOBALS['TYPO3_CONF_VARS']['SYS']['createGroup'] = $swapGroup;
             $directory = $this->getUniqueId('mkdirdeeptest_');
             $subDirectory = $directory . '/bar';
-            GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/var/tests/' . $subDirectory);
-            $this->testFilesToDelete[] = PATH_site . 'typo3temp/var/tests/' . $directory;
+            GeneralUtility::mkdir_deep(Environment::getVarPath() . '/tests/' . $subDirectory);
+            $this->testFilesToDelete[] = Environment::getVarPath() . '/tests/' . $directory;
             clearstatcache();
-            $resultDirectoryGroup = filegroup(PATH_site . 'typo3temp/var/tests/' . $directory);
+            $resultDirectoryGroup = filegroup(Environment::getVarPath() . '/tests/' . $directory);
             $this->assertEquals($resultDirectoryGroup, $swapGroup);
         }
     }
@@ -3169,7 +3169,7 @@ class GeneralUtilityTest extends UnitTestCase
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode(1303662956);
 
-        GeneralUtility::mkdir_deep(PATH_site . 'typo3temp/foo', []);
+        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/typo3temp/foo', []);
     }
 
     ///////////////////////////////
@@ -3181,7 +3181,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirRemovesFile()
     {
-        $file = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('file_');
+        $file = Environment::getVarPath() . '/tests/' . $this->getUniqueId('file_');
         touch($file);
         GeneralUtility::rmdir($file);
         $this->assertFalse(file_exists($file));
@@ -3192,7 +3192,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirReturnTrueIfFileWasRemoved()
     {
-        $file = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('file_');
+        $file = Environment::getVarPath() . '/tests/' . $this->getUniqueId('file_');
         touch($file);
         $this->assertTrue(GeneralUtility::rmdir($file));
     }
@@ -3202,7 +3202,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirReturnFalseIfNoFileWasRemoved()
     {
-        $file = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('file_');
+        $file = Environment::getVarPath() . '/tests/' . $this->getUniqueId('file_');
         $this->assertFalse(GeneralUtility::rmdir($file));
     }
 
@@ -3211,7 +3211,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirRemovesDirectory()
     {
-        $directory = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('directory_');
+        $directory = Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_');
         mkdir($directory);
         GeneralUtility::rmdir($directory);
         $this->assertFalse(file_exists($directory));
@@ -3222,7 +3222,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirRemovesDirectoryWithTrailingSlash()
     {
-        $directory = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('directory_') . '/';
+        $directory = Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_') . '/';
         mkdir($directory);
         GeneralUtility::rmdir($directory);
         $this->assertFalse(file_exists($directory));
@@ -3233,7 +3233,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirDoesNotRemoveDirectoryWithFilesAndReturnsFalseIfRecursiveDeletionIsOff()
     {
-        $directory = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('directory_') . '/';
+        $directory = Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_') . '/';
         mkdir($directory);
         $file = $this->getUniqueId('file_');
         touch($directory . $file);
@@ -3249,7 +3249,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirRemovesDirectoriesRecursiveAndReturnsTrue()
     {
-        $directory = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('directory_') . '/';
+        $directory = Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_') . '/';
         mkdir($directory);
         mkdir($directory . 'sub/');
         touch($directory . 'sub/file');
@@ -3263,10 +3263,10 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirRemovesLinkToDirectory()
     {
-        $existingDirectory = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('notExists_') . '/';
+        $existingDirectory = Environment::getVarPath() . '/tests/' . $this->getUniqueId('notExists_') . '/';
         mkdir($existingDirectory);
         $this->testFilesToDelete[] = $existingDirectory;
-        $symlinkName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('link_');
+        $symlinkName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
         symlink($existingDirectory, $symlinkName);
         GeneralUtility::rmdir($symlinkName, true);
         $this->assertFalse(is_link($symlinkName));
@@ -3277,8 +3277,8 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirRemovesDeadLinkToDirectory()
     {
-        $notExistingDirectory = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('notExists_') . '/';
-        $symlinkName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('link_');
+        $notExistingDirectory = Environment::getVarPath() . '/tests/' . $this->getUniqueId('notExists_') . '/';
+        $symlinkName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
         mkdir($notExistingDirectory);
         symlink($notExistingDirectory, $symlinkName);
         rmdir($notExistingDirectory);
@@ -3292,8 +3292,8 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function rmdirRemovesDeadLinkToFile()
     {
-        $notExistingFile = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('notExists_');
-        $symlinkName = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('link_');
+        $notExistingFile = Environment::getVarPath() . '/tests/' . $this->getUniqueId('notExists_');
+        $symlinkName = Environment::getVarPath() . '/tests/' . $this->getUniqueId('link_');
         touch($notExistingFile);
         symlink($notExistingFile, $symlinkName);
         unlink($notExistingFile);
@@ -3698,7 +3698,7 @@ class GeneralUtilityTest extends UnitTestCase
     public function splitFileRefReturnsFileTypeNotForFolders()
     {
         $directoryName = $this->getUniqueId('test_') . '.com';
-        $directoryPath = PATH_site . 'typo3temp/var/tests/';
+        $directoryPath = Environment::getVarPath() . '/tests/';
         $directory = $directoryPath . $directoryName;
         mkdir($directory, octdec($GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']));
         $fileInfo = GeneralUtility::split_fileref($directory);
@@ -4141,17 +4141,50 @@ class GeneralUtilityTest extends UnitTestCase
     public function getFileAbsFileNameDateprovider()
     {
         return [
-            'typo3/sysext/core/Resources/Public/Icons/Extension.png' => ['typo3/sysext/core/Resources/Public/Icons/Extension.png', PATH_site . 'typo3/sysext/core/Resources/Public/Icons/Extension.png'],
-            'sysext/core/Resources/Public/Icons/Extension.png' => ['sysext/core/Resources/Public/Icons/Extension.png', PATH_site . 'sysext/core/Resources/Public/Icons/Extension.png'],
-            './typo3/sysext/core/Resources/Public/Icons/Extension.png' => ['./typo3/sysext/core/Resources/Public/Icons/Extension.png', PATH_site . './typo3/sysext/core/Resources/Public/Icons/Extension.png'],
-            'fileadmin/foo.txt' => ['fileadmin/foo.txt', PATH_site . 'fileadmin/foo.txt'],
-            './fileadmin/foo.txt' => ['./fileadmin/foo.txt', PATH_site . './fileadmin/foo.txt'],
-            '../sysext/core/Resources/Public/Icons/Extension.png' => ['../sysext/core/Resources/Public/Icons/Extension.png', ''],
-            '../fileadmin/foo.txt' => ['../fileadmin/foo.txt', ''],
-            'PATH_site . ../sysext/core/Resources/Public/Icons/Extension.png' => [PATH_site . '../sysext/core/Resources/Public/Icons/Extension.png', ''],
-            'PATH_site . fileadmin/foo.txt' => [PATH_site . 'fileadmin/foo.txt', PATH_site . 'fileadmin/foo.txt'],
-            'PATH_site . typo3/sysext/core/Resources/Public/Icons/Extension.png' => [PATH_site . 'typo3/sysext/core/Resources/Public/Icons/Extension.png', PATH_site . 'typo3/sysext/core/Resources/Public/Icons/Extension.png'],
-            'EXT:foo/Resources/Public/Icons/Extension.png' => ['EXT:foo/Resources/Public/Icons/Extension.png', PATH_site . 'typo3/sysext/foo/Resources/Public/Icons/Extension.png']
+            'typo3/sysext/core/Resources/Public/Icons/Extension.png' => [
+                'typo3/sysext/core/Resources/Public/Icons/Extension.png',
+                Environment::getPublicPath() . '/typo3/sysext/core/Resources/Public/Icons/Extension.png'
+            ],
+            'sysext/core/Resources/Public/Icons/Extension.png' => [
+                'sysext/core/Resources/Public/Icons/Extension.png',
+                Environment::getPublicPath() . '/sysext/core/Resources/Public/Icons/Extension.png'
+            ],
+            './typo3/sysext/core/Resources/Public/Icons/Extension.png' => [
+                './typo3/sysext/core/Resources/Public/Icons/Extension.png',
+                Environment::getPublicPath() . '/./typo3/sysext/core/Resources/Public/Icons/Extension.png'
+            ],
+            'fileadmin/foo.txt' => [
+                'fileadmin/foo.txt',
+                Environment::getPublicPath() . '/fileadmin/foo.txt'
+            ],
+            './fileadmin/foo.txt' => [
+                './fileadmin/foo.txt',
+                Environment::getPublicPath() . '/./fileadmin/foo.txt'
+            ],
+            '../sysext/core/Resources/Public/Icons/Extension.png' => [
+                '../sysext/core/Resources/Public/Icons/Extension.png',
+                ''
+            ],
+            '../fileadmin/foo.txt' => [
+                '../fileadmin/foo.txt',
+                ''
+            ],
+            'Public web path . ../sysext/core/Resources/Public/Icons/Extension.png' => [
+                Environment::getPublicPath() . '/../sysext/core/Resources/Public/Icons/Extension.png',
+                ''
+            ],
+            'Public web path . fileadmin/foo.txt' => [
+                Environment::getPublicPath() . '/fileadmin/foo.txt',
+                Environment::getPublicPath() . '/fileadmin/foo.txt'
+            ],
+            'Public web path . typo3/sysext/core/Resources/Public/Icons/Extension.png' => [
+                Environment::getPublicPath() . '/typo3/sysext/core/Resources/Public/Icons/Extension.png',
+                Environment::getPublicPath() . '/typo3/sysext/core/Resources/Public/Icons/Extension.png'
+            ],
+            'EXT:foo/Resources/Public/Icons/Extension.png' => [
+                'EXT:foo/Resources/Public/Icons/Extension.png',
+                Environment::getPublicPath() . '/typo3/sysext/foo/Resources/Public/Icons/Extension.png'
+            ]
         ];
     }
 
@@ -4176,7 +4209,7 @@ class GeneralUtilityTest extends UnitTestCase
             ->getMock();
         $package->expects($this->any())
             ->method('getPackagePath')
-            ->will($this->returnValue(PATH_site . 'typo3/sysext/foo/'));
+            ->will($this->returnValue(Environment::getPublicPath() . '/typo3/sysext/foo/'));
         $packageManager->expects($this->any())
             ->method('isPackageActive')
             ->with($this->equalTo('foo'))
@@ -4301,12 +4334,12 @@ class GeneralUtilityTest extends UnitTestCase
     public function copyDirectoryCopiesFilesAndDirectoriesWithRelativePaths()
     {
         $sourceDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
-        $absoluteSourceDirectory = PATH_site . $sourceDirectory;
+        $absoluteSourceDirectory = Environment::getPublicPath() . '/' . $sourceDirectory;
         $this->testFilesToDelete[] = $absoluteSourceDirectory;
         GeneralUtility::mkdir($absoluteSourceDirectory);
 
         $targetDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
-        $absoluteTargetDirectory = PATH_site . $targetDirectory;
+        $absoluteTargetDirectory = Environment::getPublicPath() . '/' . $targetDirectory;
         $this->testFilesToDelete[] = $absoluteTargetDirectory;
 
         GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
@@ -4325,12 +4358,12 @@ class GeneralUtilityTest extends UnitTestCase
     public function copyDirectoryCopiesFilesAndDirectoriesWithAbsolutePaths()
     {
         $sourceDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
-        $absoluteSourceDirectory = PATH_site . $sourceDirectory;
+        $absoluteSourceDirectory = Environment::getPublicPath() . '/' . $sourceDirectory;
         $this->testFilesToDelete[] = $absoluteSourceDirectory;
         GeneralUtility::mkdir($absoluteSourceDirectory);
 
         $targetDirectory = 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '/';
-        $absoluteTargetDirectory = PATH_site . $targetDirectory;
+        $absoluteTargetDirectory = Environment::getPublicPath() . '/' . $targetDirectory;
         $this->testFilesToDelete[] = $absoluteTargetDirectory;
 
         GeneralUtility::writeFileToTypo3tempDir($absoluteSourceDirectory . 'file', '42');
@@ -4445,7 +4478,7 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function getAllFilesAndFoldersInPathReturnsArrayWithMd5Keys()
     {
-        $directory = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('directory_');
+        $directory = Environment::getVarPath() . '/tests/' . $this->getUniqueId('directory_');
         mkdir($directory);
         $filesAndDirectories = GeneralUtility::getAllFilesAndFoldersInPath([], $directory, '', true);
         $check = true;
diff --git a/typo3/sysext/core/Tests/Unit/Utility/PathUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/PathUtilityTest.php
index b95d7db4678a..0be9b4d50f23 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/PathUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/PathUtilityTest.php
@@ -18,7 +18,7 @@ use TYPO3\CMS\Core\Utility\PathUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for class \TYPO3\CMS\Core\Utility\PathUtility
+ * Test case
  */
 class PathUtilityTest extends UnitTestCase
 {
@@ -142,32 +142,32 @@ class PathUtilityTest extends UnitTestCase
         return [
             [
                 '/',
-                PATH_site . 'directory',
+                Environment::getPublicPath() . '/directory',
                 null
             ],
             [
-                PATH_site . 't3lib/',
-                PATH_site . 't3lib/',
+                Environment::getPublicPath() . '/t3lib/',
+                Environment::getPublicPath() . '/t3lib/',
                 ''
             ],
             [
-                PATH_site . 'typo3/',
-                PATH_site . 't3lib/',
+                Environment::getPublicPath() . '/typo3/',
+                Environment::getPublicPath() . '/t3lib/',
                 '../t3lib/'
             ],
             [
-                PATH_site,
-                PATH_site . 't3lib/',
+                Environment::getPublicPath() . '/',
+                Environment::getPublicPath() . '/t3lib/',
                 't3lib/'
             ],
             [
-                PATH_site . 't3lib/',
-                PATH_site . 't3lib/stddb/',
+                Environment::getPublicPath() . '/t3lib/',
+                Environment::getPublicPath() . '/t3lib/stddb/',
                 'stddb/'
             ],
             [
-                PATH_site . 'typo3/sysext/frontend/',
-                PATH_site . 't3lib/utility/',
+                Environment::getPublicPath() . '/typo3/sysext/frontend/',
+                Environment::getPublicPath() . '/t3lib/utility/',
                 '../../../t3lib/utility/'
             ],
         ];
diff --git a/typo3/sysext/core/Tests/UnitDeprecated/Utility/ExtensionManagementUtilityTest.php b/typo3/sysext/core/Tests/UnitDeprecated/Utility/ExtensionManagementUtilityTest.php
index 41f038652768..29a9e9f8b25f 100644
--- a/typo3/sysext/core/Tests/UnitDeprecated/Utility/ExtensionManagementUtilityTest.php
+++ b/typo3/sysext/core/Tests/UnitDeprecated/Utility/ExtensionManagementUtilityTest.php
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Utility;
 
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Package\Package;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy;
@@ -60,7 +61,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
      */
     protected function createMockPackageManagerWithMockPackage($packageKey, $packageMethods = ['getPackagePath', 'getPackageKey'])
     {
-        $packagePath = PATH_site . 'typo3temp/var/tests/' . $packageKey . '/';
+        $packagePath = Environment::getVarPath() . '/tests/' . $packageKey . '/';
         GeneralUtility::mkdir_deep($packagePath);
         $this->testFilesToDelete[] = $packagePath;
         $package = $this->getMockBuilder(Package::class)
@@ -142,7 +143,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
             ->getMock();
         $package->expects($this->once())
                 ->method('getPackagePath')
-                ->will($this->returnValue(PATH_site . 'foo/'));
+                ->will($this->returnValue(Environment::getPublicPath() . '/foo/'));
         $packageManager->expects($this->once())
                 ->method('isPackageActive')
                 ->with($this->equalTo('foo'))
@@ -152,7 +153,7 @@ class ExtensionManagementUtilityTest extends UnitTestCase
                 ->with('foo')
                 ->will($this->returnValue($package));
         ExtensionManagementUtility::setPackageManager($packageManager);
-        $this->assertSame(PATH_site . 'foo/bar.txt', ExtensionManagementUtility::extPath('foo', 'bar.txt'));
+        $this->assertSame(Environment::getPublicPath() . '/foo/bar.txt', ExtensionManagementUtility::extPath('foo', 'bar.txt'));
     }
 
     //////////////////////
-- 
GitLab