From 0914114eb69c9c64541d14ad3915a1a68ffae80e Mon Sep 17 00:00:00 2001
From: Susanne Moog <look@susi.dev>
Date: Thu, 28 Nov 2019 19:38:00 +0100
Subject: [PATCH] [TASK] Remove dependency to FileStreamWrapper

We can use vfs stream directly nowadays.

Resolves: #89798
Releases: master
Change-Id: Ie41eccb21dff70c6587bfd1380488697c4f6aca3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62473
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
---
 .../Unit/Resource/Driver/LocalDriverTest.php  | 21 +++++++------------
 .../Tests/Unit/Utility/GeneralUtilityTest.php | 11 +++-------
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
index 4c63bb2238ac..43166a4c27c5 100644
--- a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
+++ b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
@@ -28,7 +28,6 @@ use TYPO3\CMS\Core\Resource\ResourceStorage;
 use TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase;
 use TYPO3\CMS\Core\Tests\Unit\Resource\Driver\Fixtures\LocalDriverFilenameFilter;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\TestingFramework\Core\FileStreamWrapper;
 
 /**
  * Test case
@@ -384,24 +383,22 @@ class LocalDriverTest extends BaseTestCase
      */
     public function getSpecificFileInformationReturnsRequestedFileInformation($expectedValue, string $property): void
     {
-        $root = vfsStream::setup();
+        $root = vfsStream::setup('root');
+
         $subFolder = vfsStream::newDirectory('fileadmin');
         $root->addChild($subFolder);
+
         // Load fixture files and folders from disk
         $directory = vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/', $subFolder, 1024 * 1024);
         if (in_array($property, ['mtime', 'ctime', 'atime'])) {
             $expectedValue = $directory->getChild('Dummy.html')->filemtime();
         }
-        FileStreamWrapper::init(Environment::getPublicPath() . '/');
-        FileStreamWrapper::registerOverlayPath('fileadmin', 'vfs://root/fileadmin', false);
 
-        $subject = $this->createDriver(['basePath' => Environment::getPublicPath() . '/fileadmin']);
+        $subject = $this->createDriver(['basePath' => 'vfs://root/fileadmin']);
         self::assertSame(
             $expectedValue,
-            $subject->getSpecificFileInformation(Environment::getPublicPath() . '/fileadmin/Dummy.html', '/', $property)
+            $subject->getSpecificFileInformation('vfs://root/fileadmin/Dummy.html', '/', $property)
         );
-
-        FileStreamWrapper::destroy();
     }
 
     /**
@@ -676,22 +673,18 @@ class LocalDriverTest extends BaseTestCase
      */
     public function getFileReturnsCorrectIdentifier(): void
     {
-        $root = vfsStream::setup();
+        $root = vfsStream::setup('root');
         $subFolder = vfsStream::newDirectory('fileadmin');
         $root->addChild($subFolder);
         // Load fixture files and folders from disk
         vfsStream::copyFromFileSystem(__DIR__ . '/Fixtures/', $subFolder, 1024 * 1024);
-        FileStreamWrapper::init(Environment::getPublicPath() . '/');
-        FileStreamWrapper::registerOverlayPath('fileadmin/', 'vfs://root/fileadmin/', false);
 
-        $subject = $this->createDriver(['basePath' => Environment::getPublicPath() . '/fileadmin']);
+        $subject = $this->createDriver(['basePath' => 'vfs://root/fileadmin']);
 
         $subdirFileInfo = $subject->getFileInfoByIdentifier('Dummy.html');
         self::assertEquals('/Dummy.html', $subdirFileInfo['identifier']);
         $rootFileInfo = $subject->getFileInfoByIdentifier('LocalDriverFilenameFilter.php');
         self::assertEquals('/LocalDriverFilenameFilter.php', $rootFileInfo['identifier']);
-
-        FileStreamWrapper::destroy();
     }
 
     /**
diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
index dd8074fa12c1..2c2011c41bd5 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
@@ -37,7 +37,6 @@ use TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\ReplacementClassFixture;
 use TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\TwoParametersConstructorFixture;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\TestingFramework\Core\FileStreamWrapper;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -2897,13 +2896,9 @@ class GeneralUtilityTest extends UnitTestCase
      */
     public function mkdirDeepCreatesDirectoryWithDoubleSlashes($directoryToCreate)
     {
-        vfsStream::setup();
-        // Load fixture files and folders from disk
-        FileStreamWrapper::init(Environment::getPublicPath());
-        FileStreamWrapper::registerOverlayPath('fileadmin', 'vfs://root/fileadmin', true);
-        GeneralUtility::mkdir_deep(Environment::getPublicPath() . '/' . $directoryToCreate);
-        self::assertTrue(is_dir(Environment::getPublicPath() . '/' . $directoryToCreate));
-        FileStreamWrapper::destroy();
+        vfsStream::setup('root', null, ['public' => []]);
+        GeneralUtility::mkdir_deep('vfs://root/public/' . $directoryToCreate);
+        self::assertTrue(is_dir('vfs://root/public/' . $directoryToCreate));
     }
 
     /**
-- 
GitLab