/** * Ping a journal, check on it's health, etc. * * @param Journal $journal * * @return PingResult * * @throws Exception */ public function ping(Journal $journal) { $this->logger->notice("Pinging {$journal}"); $url = $journal->getGatewayUrl(); $client = $this->getClient(); try { $response = $client->get($url, array('allow_redirects' => false, 'headers' => array('User-Agent' => 'PkpPlnBot 1.0; http://pkp.sfu.ca', 'Accept' => 'application/xml,text/xml,*/*;q=0.1'))); $pingResponse = new PingResult($response); if ($pingResponse->getHttpStatus() === 200) { $journal->setContacted(new DateTime()); $journal->setTitle($pingResponse->getJournalTitle('(unknown title)')); $journal->setOjsVersion($pingResponse->getOjsRelease()); $journal->setTermsAccepted($pingResponse->areTermsAccepted() === 'yes'); } else { $journal->setStatus('ping-error'); } $this->em->flush($journal); return $pingResponse; } catch (RequestException $e) { $journal->setStatus('ping-error'); $this->em->flush($journal); if ($e->hasResponse()) { return new PingResult($e->getResponse()); } throw $e; } catch (XmlParseException $e) { $journal->setStatus('ping-error'); $this->em->flush($journal); return new PingResult($e->getResponse()); } catch (Exception $e) { $journal->setStatus('ping-error'); $this->em->flush($journal); throw $e; } }
public function testGetOjsRelease() { $this->assertNull($this->result->getOjsRelease()); }
public function testGetOjsRelease() { $this->assertEquals('2.4.8.0', $this->result->getOjsRelease()); }