getLockLifetime() public method

public getLockLifetime ( string $lockFile ) : integer
$lockFile string
return integer
Beispiel #1
0
 /**
  * @covers ::getLockLifetime
  */
 public function testGetLocklifetime()
 {
     $this->helper->acquireLock($this->lockFile);
     $this->assertEquals(0, $this->helper->getLockLifetime($this->lockFile));
     sleep(1);
     $this->assertEquals(1, $this->helper->getLockLifetime($this->lockFile));
     sleep(1);
     $this->assertEquals(2, $this->helper->getLockLifetime($this->lockFile));
     $this->helper->releaseLock($this->lockFile);
 }
Beispiel #2
0
 /**
  * @covers ::getLockLifetime
  */
 public function testGetLocklifetime()
 {
     if ($this->helper->getPlatform() === Helper::WINDOWS) {
         $this->markTestSkipped("Test relies on posix_ functions");
     }
     $this->helper->acquireLock($this->lockFile);
     $this->assertEquals(0, $this->helper->getLockLifetime($this->lockFile));
     sleep(1);
     $this->assertEquals(1, $this->helper->getLockLifetime($this->lockFile));
     sleep(1);
     $this->assertEquals(2, $this->helper->getLockLifetime($this->lockFile));
     $this->helper->releaseLock($this->lockFile);
 }
Beispiel #3
0
 /**
  * @param string $lockfile
  * @throws Exception
  */
 protected function checkMaxRuntime($lockfile)
 {
     $maxRuntime = $this->config["maxRuntime"];
     if ($maxRuntime === null) {
         return;
     }
     if ($this->helper->getPlatform() === Helper::WINDOWS) {
         throw new Exception("'maxRuntime' is not supported on Windows");
     }
     $runtime = $this->helper->getLockLifetime($lockfile);
     if ($runtime < $maxRuntime) {
         return;
     }
     throw new Exception("MaxRuntime of {$maxRuntime} secs exceeded! " . "Current runtime: {$runtime} secs");
 }