]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/StorageManagerTest.php
Merge pull request #10825 from nupplaphil/feat/Storage_refactor
[friendica.git] / tests / src / Core / StorageManagerTest.php
index 9e8e3aa2c242ebe1bce2db699aac4aae1aaa66bc..77e4946bdf02bf4335aa2a315f2ef3565995107f 100644 (file)
@@ -34,12 +34,13 @@ use Friendica\Factory\ConfigFactory;
 use Friendica\Model\Config\Config;
 use Friendica\Model\Storage;
 use Friendica\Core\Session;
-use Friendica\Network\HTTPRequest;
+use Friendica\Network\HTTPClient;
 use Friendica\Test\DatabaseTest;
 use Friendica\Test\Util\Database\StaticDatabase;
 use Friendica\Test\Util\VFSTrait;
 use Friendica\Util\ConfigFileLoader;
 use Friendica\Util\Profiler;
+use org\bovigo\vfs\vfsStream;
 use Psr\Log\LoggerInterface;
 use Psr\Log\NullLogger;
 use Friendica\Test\Util\SampleStorageBackend;
@@ -55,7 +56,7 @@ class StorageManagerTest extends DatabaseTest
        private $logger;
        /** @var L10n */
        private $l10n;
-       /** @var HTTPRequest */
+       /** @var HTTPClient */
        private $httpRequest;
 
        protected function setUp(): void
@@ -64,6 +65,8 @@ class StorageManagerTest extends DatabaseTest
 
                $this->setUpVfsDir();
 
+               vfsStream::newDirectory(Storage\FilesystemConfig::DEFAULT_BASE_FOLDER, 0777)->at($this->root);
+
                $this->logger = new NullLogger();
 
                $profiler = \Mockery::mock(Profiler::class);
@@ -73,7 +76,7 @@ class StorageManagerTest extends DatabaseTest
 
                // load real config to avoid mocking every config-entry which is related to the Database class
                $configFactory = new ConfigFactory();
-               $loader        = new ConfigFileLoader($this->root->url());
+               $loader        = $configFactory->createConfigFileLoader($this->root->url(), []);
                $configCache   = $configFactory->createCache($loader);
 
                $this->dba = new StaticDatabase($configCache, $profiler, $this->logger);
@@ -81,10 +84,18 @@ class StorageManagerTest extends DatabaseTest
                $configModel  = new Config($this->dba);
                $this->config = new PreloadConfig($configCache, $configModel);
                $this->config->set('storage', 'name', 'Database');
+               $this->config->set('storage', 'filesystem_path', $this->root->getChild(Storage\FilesystemConfig::DEFAULT_BASE_FOLDER)->url());
 
                $this->l10n = \Mockery::mock(L10n::class);
 
-               $this->httpRequest = \Mockery::mock(HTTPRequest::class);
+               $this->httpRequest = \Mockery::mock(HTTPClient::class);
+       }
+
+       protected function tearDown(): void
+       {
+               $this->root->removeChild(Storage\FilesystemConfig::DEFAULT_BASE_FOLDER);
+
+               parent::tearDown();
        }
 
        /**