You are here

public function Redis_Tests_Lock_LockingUnitTestCase::testLock in Redis 7.3

File

lib/Redis/Tests/Lock/LockingUnitTestCase.php, line 52

Class

Redis_Tests_Lock_LockingUnitTestCase

Code

public function testLock() {
  $b1 = $this
    ->createLockBackend();
  $b2 = $this
    ->createLockBackend();
  $s = $b1
    ->lockAcquire('test1', 20000);
  $this
    ->assertTrue($s, "Lock test1 acquired");
  $s = $b1
    ->lockAcquire('test1', 20000);
  $this
    ->assertTrue($s, "Lock test1 acquired a second time by the same thread");
  $s = $b2
    ->lockAcquire('test1', 20000);
  $this
    ->assertFalse($s, "Lock test1 could not be acquired by another thread");
  $b2
    ->lockRelease('test1');
  $s = $b2
    ->lockAcquire('test1');
  $this
    ->assertFalse($s, "Lock test1 could not be released by another thread");
  $b1
    ->lockRelease('test1');
  $s = $b2
    ->lockAcquire('test1');
  $this
    ->assertTrue($s, "Lock test1 has been released by the first thread");
}