public function testRecheck() { $testFile = "test.pid"; $initialPid = 12345; $pid = new Pid($this->getPath($testFile), $initialPid); $this->assertEquals($initialPid, $pid->getPid()); // check the pid set properly $finalPid = 67890; /** @var vfsStreamFile $file */ $file = vfsStreamWrapper::getRoot()->getChild($testFile); $file->setContent("{$finalPid}"); $this->assertEquals($initialPid, $pid->getPid()); // check it doesn't update automatically $this->assertEquals($finalPid, $pid->getPid(true)); // check a recheck pull the latest value }
/** * gets the PID number from the PID file and caches it * * @param bool $skipCache * @return int */ protected function getPid($skipCache = false) { $skipCache = (bool) $skipCache; if (!$skipCache && !empty($this->pid) && $this->pid instanceof Pid) { return $this->pid->getPid(); } $pid = $this->pidFactory->create($this->poolPidFile); $pidNum = $pid->getPid(); $this->pid = $pid; return $pidNum; }