/** * Copy data from persistent storage to temporary one. * * @return mixed * @throws ReadException */ private function selectFromStorage() { if (!$this->fs->exists($this->fsPath)) { return $this->getEmptyStorage(); } $data = json_decode($this->fs->read($this->fsPath), true); if (!isset($data['pid']) || !$this->system->existsPid($data['pid'])) { return $this->getEmptyStorage(); } return $data; }
/** * Copy data from persistent storage to temporary one. * * @return string[][] * @throws ReadException */ private function selectFromStorage() { if (!$this->fs->exists($this->fsPath)) { return []; } $processes = []; $data = json_decode($this->fs->read($this->fsPath), true); foreach ($data as $alias => $record) { if ($this->system->existsPid($record['pid'])) { $processes[$alias] = ['pid' => $record['pid'], 'name' => $record['name'], 'verified' => false]; } } return $processes; }
/** * */ public function testApiExists_ThrowsException_WhenModelHasThrowsException() { $this->setExpectedException(ReadException::class); $this->expect('has', ['path'])->willThrow(new Exception()); $this->fs->exists('path'); }