2018-07-04 21:37:22 +00:00
|
|
|
<?php
|
2020-02-09 14:45:36 +00:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (C) 2020, Friendica
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2018-07-04 21:37:22 +00:00
|
|
|
|
2018-07-05 18:57:31 +00:00
|
|
|
namespace Friendica\Test\src\Core\Lock;
|
2018-07-04 21:37:22 +00:00
|
|
|
|
2019-08-04 08:26:53 +00:00
|
|
|
use Friendica\Core\Lock\DatabaseLock;
|
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-04 08:26:53 +00:00
|
|
|
return new DatabaseLock($dba, $this->pid);
|
2019-03-04 20:28:36 +00:00
|
|
|
}
|
2018-07-07 14:15:03 +00:00
|
|
|
}
|