2018-07-04 21:37:22 +00:00
|
|
|
<?php
|
|
|
|
|
2018-07-05 18:57:31 +00:00
|
|
|
namespace Friendica\Test\src\Core\Lock;
|
2018-07-04 21:37:22 +00:00
|
|
|
|
|
|
|
use Friendica\Core\Lock\DatabaseLockDriver;
|
2019-08-03 18:48:56 +00:00
|
|
|
use Friendica\Factory\ConfigFactory;
|
|
|
|
use Friendica\Test\DatabaseTestTrait;
|
|
|
|
use Friendica\Test\Util\Database\StaticDatabase;
|
|
|
|
use Friendica\Test\Util\VFSTrait;
|
|
|
|
use Friendica\Util\ConfigFileLoader;
|
|
|
|
use Friendica\Util\Profiler;
|
|
|
|
use Psr\Log\NullLogger;
|
2018-07-04 21:37:22 +00:00
|
|
|
|
|
|
|
class DatabaseLockDriverTest extends LockTest
|
|
|
|
{
|
2019-08-03 18:48:56 +00:00
|
|
|
use VFSTrait;
|
|
|
|
use DatabaseTestTrait;
|
2019-01-30 19:26:17 +00:00
|
|
|
|
|
|
|
protected $pid = 123;
|
|
|
|
|
|
|
|
protected function setUp()
|
|
|
|
{
|
2019-08-03 18:48:56 +00:00
|
|
|
$this->setUpVfsDir();
|
2019-01-30 19:26:17 +00:00
|
|
|
|
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
2018-07-04 21:37:22 +00:00
|
|
|
protected function getInstance()
|
|
|
|
{
|
2019-08-03 18:48:56 +00:00
|
|
|
$logger = new NullLogger();
|
|
|
|
$profiler = \Mockery::mock(Profiler::class);
|
|
|
|
$profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
|
2019-01-30 19:26:17 +00:00
|
|
|
|
2019-08-03 18:48:56 +00:00
|
|
|
// 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());
|
|
|
|
$configCache = $configFactory->createCache($loader);
|
2019-01-30 19:26:17 +00:00
|
|
|
|
2019-08-03 18:48:56 +00:00
|
|
|
$dba = new StaticDatabase($configCache, $profiler, $logger);
|
2019-03-04 20:28:36 +00:00
|
|
|
|
2019-08-03 18:48:56 +00:00
|
|
|
return new DatabaseLockDriver($dba, $this->pid);
|
2019-03-04 20:28:36 +00:00
|
|
|
}
|
2018-07-07 14:15:03 +00:00
|
|
|
}
|