NonCachingDBLockingProviderTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace Test\Lock;
  7. use OCP\Lock\ILockingProvider;
  8. /**
  9. * @group DB
  10. *
  11. * @package Test\Lock
  12. */
  13. class NonCachingDBLockingProviderTest extends DBLockingProviderTest {
  14. /**
  15. * @return \OCP\Lock\ILockingProvider
  16. */
  17. protected function getInstance() {
  18. $this->connection = \OC::$server->getDatabaseConnection();
  19. return new \OC\Lock\DBLockingProvider($this->connection, $this->timeFactory, 3600, false);
  20. }
  21. public function testDoubleShared() {
  22. $this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
  23. $this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
  24. $this->assertEquals(2, $this->getLockValue('foo'));
  25. $this->instance->releaseLock('foo', ILockingProvider::LOCK_SHARED);
  26. $this->assertEquals(1, $this->getLockValue('foo'));
  27. $this->instance->releaseLock('foo', ILockingProvider::LOCK_SHARED);
  28. $this->assertEquals(0, $this->getLockValue('foo'));
  29. }
  30. }