コード例 #1
0
 /**
  * @return void
  *
  * @throws LockingException If the lock is not acquirable
  */
 public function acquire()
 {
     $isAcquired = $this->lock->acquireLock($this->timeout->getValue());
     if (!$isAcquired) {
         throw new LockingException('Lock cannot be acquired.', 1438871269);
     }
 }
コード例 #2
0
 public function testItReleasesLockingOnTheLock()
 {
     $this->backend->expects($this->once())->method('acquireLock')->with('test-lock', 23)->willReturn(true);
     $this->backend->expects($this->once())->method('releaseLock')->with('test-lock')->willReturn(true);
     $this->timeout->expects($this->any())->method('getValue')->willReturn(23);
     $lock = new Lock($this->backend, $this->name, $this->timeout);
     $lock->acquire();
     $lock->release();
 }