From 9936081c7e38e82e930aa759363052aa6c682deb Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 29 Dec 2022 22:56:27 +0100 Subject: [PATCH] Fix DBA lock test --- .../src/Core/Lock/DatabaseLockDriverTest.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/src/Core/Lock/DatabaseLockDriverTest.php b/tests/src/Core/Lock/DatabaseLockDriverTest.php index bd4cb9cc9..70c5f3764 100644 --- a/tests/src/Core/Lock/DatabaseLockDriverTest.php +++ b/tests/src/Core/Lock/DatabaseLockDriverTest.php @@ -21,15 +21,16 @@ namespace Friendica\Test\src\Core\Lock; +use Friendica\Core\Config\ValueObject\Cache; use Friendica\Core\Lock\Type\DatabaseLock; -use Friendica\Core\Config\Factory\Config; -use Friendica\DI; +use Friendica\Database\Database; +use Friendica\Database\Definition\DbaDefinition; +use Friendica\Database\Definition\ViewDefinition; use Friendica\Test\DatabaseTestTrait; use Friendica\Test\Util\Database\StaticDatabase; use Friendica\Test\Util\VFSTrait; +use Friendica\Util\BasePath; use Friendica\Util\Profiler; -use Mockery; -use Psr\Log\NullLogger; class DatabaseLockDriverTest extends LockTest { @@ -38,6 +39,9 @@ class DatabaseLockDriverTest extends LockTest protected $pid = 123; + /** @var Database */ + protected $database; + protected function setUp(): void { $this->setUpVfsDir(); @@ -49,7 +53,15 @@ class DatabaseLockDriverTest extends LockTest protected function getInstance() { - return new DatabaseLock(DI::dba(), $this->pid); + $cache = new Cache(); + $cache->set('database', 'disable_pdo', true); + + $basePath = new BasePath(dirname(__FILE__, 5), $_SERVER); + + $this->database = new StaticDatabase($cache, new Profiler($cache), (new DbaDefinition($basePath->getPath()))->load(), (new ViewDefinition($basePath->getPath()))->load()); + $this->database->setTestmode(true); + + return new DatabaseLock($this->database, $this->pid); } protected function tearDown(): void