Exemplo n.º 1
0
 public function testIsLocked()
 {
     $path = 'application/data/filesystem/test.txt';
     $fs = FileSystem::getInstance();
     $file = new File($path);
     $lockFile = $file->getLockFile();
     if ($lockFile->exists()) {
         $lockFile->delete();
     }
     $this->assertFalse($fs->isLocked($file));
     $lockFile->write('test');
     $this->assertTrue($fs->isLocked($file));
 }
Exemplo n.º 2
0
 /**
  * @dataProvider providerGetLockFile
  */
 public function testGetLockFile($expected, $value)
 {
     $file = new File($value);
     $lockFile = $file->getLockFile($file);
     $this->assertEquals($expected, $lockFile->getPath(), $value);
 }
Exemplo n.º 3
0
 /**
  * Wait until the provided file is unlocked
  * @param File $file The locked file to wait for
  * @param integer $waitTime Time in microseconds to wait between the lock checks
  * @return null
  */
 public function waitForUnlock(File $file, $waitTime = 10000)
 {
     $lockFile = $file->getLockFile();
     $isFileLocked = true;
     do {
         if ($this->exists($lockFile)) {
             usleep($waitTime);
             continue;
         }
         $isFileLocked = false;
     } while ($isFileLocked);
 }