Example #1
0
 public function testOpenWhenFileOpened()
 {
     $filepath = '/tmp/LockFile/test.lock';
     $this->assertEquals(false, file_exists($filepath));
     touch($filepath);
     $lockFile = new LockFile($filepath);
     $lockFile->lock(LOCK_EX);
     $target = new LockFile($filepath);
     $this->assertEquals(true, $target->getFileInfo()->isFile());
 }
Example #2
0
 /**
  * Unlock file for another thread.
  * 
  * @return bool
  */
 public function unlock()
 {
     $out = $this->file->lock(LOCK_UN);
     $this->lock = !$out;
     return $out;
 }