]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Lock/DatabaseLockTest.php
Merge pull request #8075 from annando/html-escaping
[friendica.git] / tests / src / Core / Lock / DatabaseLockTest.php
1 <?php
2
3 namespace Friendica\Test\src\Core\Lock;
4
5 use Friendica\Core\Lock\DatabaseLock;
6 use Friendica\Factory\ConfigFactory;
7 use Friendica\Test\DatabaseTestTrait;
8 use Friendica\Test\Util\Database\StaticDatabase;
9 use Friendica\Test\Util\VFSTrait;
10 use Friendica\Util\ConfigFileLoader;
11 use Friendica\Util\Profiler;
12 use Psr\Log\NullLogger;
13
14 class DatabaseLockDriverTest extends LockTest
15 {
16         use VFSTrait;
17         use DatabaseTestTrait;
18
19         protected $pid = 123;
20
21         protected function setUp()
22         {
23                 $this->setUpVfsDir();
24
25                 parent::setUp();
26         }
27
28         protected function getInstance()
29         {
30                 $logger   = new NullLogger();
31                 $profiler = \Mockery::mock(Profiler::class);
32                 $profiler->shouldReceive('saveTimestamp')->withAnyArgs()->andReturn(true);
33
34                 // load real config to avoid mocking every config-entry which is related to the Database class
35                 $configFactory = new ConfigFactory();
36                 $loader        = new ConfigFileLoader($this->root->url());
37                 $configCache   = $configFactory->createCache($loader);
38
39                 $dba = new StaticDatabase($configCache, $profiler, $logger);
40
41                 return new DatabaseLock($dba, $this->pid);
42         }
43 }