summaryrefslogtreecommitdiffstats
path: root/tests/lib/Lock/DBLockingProviderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Lock/DBLockingProviderTest.php')
-rw-r--r--tests/lib/Lock/DBLockingProviderTest.php33
1 files changed, 30 insertions, 3 deletions
diff --git a/tests/lib/Lock/DBLockingProviderTest.php b/tests/lib/Lock/DBLockingProviderTest.php
index fb27f9957af..e8419815e31 100644
--- a/tests/lib/Lock/DBLockingProviderTest.php
+++ b/tests/lib/Lock/DBLockingProviderTest.php
@@ -40,14 +40,14 @@ class DBLockingProviderTest extends LockingProvider {
/**
* @var \OCP\IDBConnection
*/
- private $connection;
+ protected $connection;
/**
* @var \OCP\AppFramework\Utility\ITimeFactory
*/
- private $timeFactory;
+ protected $timeFactory;
- private $currentTime;
+ protected $currentTime;
public function setUp() {
$this->currentTime = time();
@@ -96,4 +96,31 @@ class DBLockingProviderTest extends LockingProvider {
$query->execute();
return $query->fetchColumn();
}
+
+ protected function getLockValue($key) {
+ $query = $this->connection->getQueryBuilder();
+ $query->select('lock')
+ ->from('file_locks')
+ ->where($query->expr()->eq('key', $query->createNamedParameter($key)));
+ return $query->execute()->fetchColumn();
+ }
+
+ public function testDoubleShared() {
+ $this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
+ $this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
+
+ $this->assertEquals(1, $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(1, $this->getLockValue('foo'));
+
+ $this->instance->releaseAll();
+
+ $this->assertEquals(0, $this->getLockValue('foo'));
+ }
}