Example #1
0
 /**
  * Test that we can obtain the lock if the current lock has exceeded the
  * maximum lifetime
  *
  * @covers \OpenWeatherMap\Lock\File::acquire
  */
 public function testLockIsUnlockedIfCurrentLockAgeIsGreaterThanMaxium()
 {
     $vfs = vfsStream::setup('exampleDir');
     $file = vfsStream::url('exampleDir/my.lock');
     $maxLifetime = 2;
     $lock = new File(array('file' => $file, 'maxlifetime' => $maxLifetime));
     $this->assertEquals($maxLifetime, $lock->getMaxLifetime());
     $this->assertTrue($lock->acquire());
     sleep(3);
     $this->assertTrue($lock->acquire());
 }