Fix DBA lock test

This commit is contained in:
Philipp 2022-12-29 22:56:27 +01:00
parent f95d5c7f89
commit 9936081c7e
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432

View File

@ -21,15 +21,16 @@
namespace Friendica\Test\src\Core\Lock; namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Lock\Type\DatabaseLock; use Friendica\Core\Lock\Type\DatabaseLock;
use Friendica\Core\Config\Factory\Config; use Friendica\Database\Database;
use Friendica\DI; use Friendica\Database\Definition\DbaDefinition;
use Friendica\Database\Definition\ViewDefinition;
use Friendica\Test\DatabaseTestTrait; use Friendica\Test\DatabaseTestTrait;
use Friendica\Test\Util\Database\StaticDatabase; use Friendica\Test\Util\Database\StaticDatabase;
use Friendica\Test\Util\VFSTrait; use Friendica\Test\Util\VFSTrait;
use Friendica\Util\BasePath;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Mockery;
use Psr\Log\NullLogger;
class DatabaseLockDriverTest extends LockTest class DatabaseLockDriverTest extends LockTest
{ {
@ -38,6 +39,9 @@ class DatabaseLockDriverTest extends LockTest
protected $pid = 123; protected $pid = 123;
/** @var Database */
protected $database;
protected function setUp(): void protected function setUp(): void
{ {
$this->setUpVfsDir(); $this->setUpVfsDir();
@ -49,7 +53,15 @@ class DatabaseLockDriverTest extends LockTest
protected function getInstance() 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 protected function tearDown(): void