2018-07-04 23:37:22 +02:00
|
|
|
<?php
|
2020-02-09 15:45:36 +01:00
|
|
|
/**
|
2023-01-01 09:36:24 -05:00
|
|
|
* @copyright Copyright (C) 2010-2023, the Friendica project
|
2020-02-09 15:45:36 +01:00
|
|
|
*
|
|
|
|
* @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 23:37:22 +02:00
|
|
|
|
2018-07-05 20:57:31 +02:00
|
|
|
namespace Friendica\Test\src\Core\Lock;
|
2018-07-04 23:37:22 +02:00
|
|
|
|
2022-12-29 22:56:27 +01:00
|
|
|
use Friendica\Core\Config\ValueObject\Cache;
|
2021-10-23 11:36:37 +02:00
|
|
|
use Friendica\Core\Lock\Type\DatabaseLock;
|
2022-12-29 22:56:27 +01:00
|
|
|
use Friendica\Database\Database;
|
|
|
|
use Friendica\Database\Definition\DbaDefinition;
|
|
|
|
use Friendica\Database\Definition\ViewDefinition;
|
2019-08-03 20:48:56 +02:00
|
|
|
use Friendica\Test\DatabaseTestTrait;
|
|
|
|
use Friendica\Test\Util\Database\StaticDatabase;
|
|
|
|
use Friendica\Test\Util\VFSTrait;
|
2022-12-29 22:56:27 +01:00
|
|
|
use Friendica\Util\BasePath;
|
2019-08-03 20:48:56 +02:00
|
|
|
use Friendica\Util\Profiler;
|
2018-07-04 23:37:22 +02:00
|
|
|
|
|
|
|
class DatabaseLockDriverTest extends LockTest
|
|
|
|
{
|
2019-08-03 20:48:56 +02:00
|
|
|
use VFSTrait;
|
|
|
|
use DatabaseTestTrait;
|
2019-01-30 20:26:17 +01:00
|
|
|
|
|
|
|
protected $pid = 123;
|
|
|
|
|
2022-12-29 22:56:27 +01:00
|
|
|
/** @var Database */
|
|
|
|
protected $database;
|
|
|
|
|
2021-04-01 23:04:30 +02:00
|
|
|
protected function setUp(): void
|
2019-01-30 20:26:17 +01:00
|
|
|
{
|
2019-08-03 20:48:56 +02:00
|
|
|
$this->setUpVfsDir();
|
2019-01-30 20:26:17 +01:00
|
|
|
|
2021-04-01 23:04:30 +02:00
|
|
|
$this->setUpDb();
|
|
|
|
|
2019-01-30 20:26:17 +01:00
|
|
|
parent::setUp();
|
|
|
|
}
|
|
|
|
|
2018-07-04 23:37:22 +02:00
|
|
|
protected function getInstance()
|
|
|
|
{
|
2022-12-29 22:56:27 +01:00
|
|
|
$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);
|
2019-03-04 21:28:36 +01:00
|
|
|
}
|
2021-04-01 23:04:30 +02:00
|
|
|
|
|
|
|
protected function tearDown(): void
|
|
|
|
{
|
|
|
|
$this->tearDownDb();
|
|
|
|
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
2018-07-07 16:15:03 +02:00
|
|
|
}
|