2018-04-10 12:30:43 -04:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2018-04-10 12:30:43 -04:00
|
|
|
/**
|
2024-05-10 09:09:14 -04:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-04-10 12:30:43 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Test\Lock;
|
|
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
use OC\Lock\DBLockingProvider;
|
|
|
|
|
use OCP\IDBConnection;
|
2018-04-10 12:30:43 -04:00
|
|
|
use OCP\Lock\ILockingProvider;
|
2025-06-12 12:31:58 -04:00
|
|
|
use OCP\Server;
|
2018-04-10 12:30:43 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package Test\Lock
|
|
|
|
|
*/
|
2025-10-20 19:52:40 -04:00
|
|
|
#[\PHPUnit\Framework\Attributes\Group('DB')]
|
2018-04-10 12:30:43 -04:00
|
|
|
class NonCachingDBLockingProviderTest extends DBLockingProviderTest {
|
|
|
|
|
/**
|
2025-06-30 10:56:59 -04:00
|
|
|
* @return ILockingProvider
|
2018-04-10 12:30:43 -04:00
|
|
|
*/
|
|
|
|
|
protected function getInstance() {
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->connection = Server::get(IDBConnection::class);
|
|
|
|
|
return new DBLockingProvider($this->connection, $this->timeFactory, 3600, false);
|
2018-04-10 12:30:43 -04:00
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testDoubleShared(): void {
|
2018-04-10 12:30:43 -04:00
|
|
|
$this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
|
|
|
|
|
$this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(2, $this->getLockValue('foo'));
|
|
|
|
|
|
|
|
|
|
$this->instance->releaseLock('foo', ILockingProvider::LOCK_SHARED);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(1, $this->getLockValue('foo'));
|
|
|
|
|
|
|
|
|
|
$this->instance->releaseLock('foo', ILockingProvider::LOCK_SHARED);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(0, $this->getLockValue('foo'));
|
|
|
|
|
}
|
2019-11-22 14:52:10 -05:00
|
|
|
}
|