]> git.mxchange.org Git - friendica.git/commitdiff
Fix dba cache
authorPhilipp <admin@philipp.info>
Sun, 12 Feb 2023 12:23:39 +0000 (13:23 +0100)
committerPhilipp <admin@philipp.info>
Sun, 12 Feb 2023 12:23:39 +0000 (13:23 +0100)
tests/src/Core/Cache/DatabaseCacheTest.php

index 9088c38af0353dee6db1e0dcb2d2c47a181e54f3..98afa9e2485e7cff92629a141bddbf3806d2dbc4 100644 (file)
 namespace Friendica\Test\src\Core\Cache;
 
 use Friendica\Core\Cache;
-use Friendica\Core\Config\Factory\Config;
-use Friendica\Database\Definition\DbaDefinition;
-use Friendica\Database\Definition\ViewDefinition;
 use Friendica\Test\DatabaseTestTrait;
-use Friendica\Test\Util\Database\StaticDatabase;
+use Friendica\Test\Util\CreateDatabaseTrait;
 use Friendica\Test\Util\VFSTrait;
-use Friendica\Util\Profiler;
-use Mockery;
-use Psr\Log\NullLogger;
 
 class DatabaseCacheTest extends CacheTest
 {
        use DatabaseTestTrait;
+       use CreateDatabaseTrait;
        use VFSTrait;
 
        protected function setUp(): void
@@ -48,23 +43,7 @@ class DatabaseCacheTest extends CacheTest
 
        protected function getInstance()
        {
-               $profiler = Mockery::mock(Profiler::class);
-               $profiler->shouldReceive('startRecording');
-               $profiler->shouldReceive('stopRecording');
-               $profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
-
-               // load real config to avoid mocking every config-entry which is related to the Database class
-               $configFactory     = new Config();
-               $configFileManager = (new Config())->createConfigFileManager($this->root->url(), []);
-               $configCache       = $configFactory->createCache($configFileManager);
-               $config            = new \Friendica\Core\Config\Model\ReadOnlyFileConfig($configCache);
-
-               $dbaDefinition  = (new DbaDefinition($configCache->get('system', 'basepath')))->load();
-               $viewDefinition = (new ViewDefinition($configCache->get('system', 'basepath')))->load();
-
-               $dba = new StaticDatabase($config, $dbaDefinition, $viewDefinition);
-
-               $this->cache = new Cache\Type\DatabaseCache('database', $dba);
+               $this->cache = new Cache\Type\DatabaseCache('database', $this->getDbInstance());
                return $this->cache;
        }