You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nextcloud-server/tests/lib/Lock/NonCachingDBLockingProvider...

42 lines
1.1 KiB

<?php
/**
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Lock;
use OC\Lock\DBLockingProvider;
use OCP\IDBConnection;
use OCP\Lock\ILockingProvider;
use OCP\Server;
/**
* @package Test\Lock
*/
#[\PHPUnit\Framework\Attributes\Group('DB')]
class NonCachingDBLockingProviderTest extends DBLockingProviderTest {
/**
* @return ILockingProvider
*/
protected function getInstance() {
$this->connection = Server::get(IDBConnection::class);
return new DBLockingProvider($this->connection, $this->timeFactory, 3600, false);
}
public function testDoubleShared(): void {
$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'));
}
}