0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-03-14 00:13:56 +00:00
nextcloud_server/tests/lib/Lock/NonCachingDBLockingProviderTest.php
Andy Scherzinger 1f7e2ba599
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-05-13 17:41:36 +02:00

39 lines
1 KiB
PHP

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