Ejemplo n.º 1
0
 public function testGetArticleTitles()
 {
     $articles = $this->result->getArticleTitles();
     $this->assertEquals(2, count($articles));
     $this->assertEquals('2015-07-14 19:57:31', (string) $articles[0]['date']);
     $this->assertEquals('Transnational Publics: Asylum and the Arts in the City of Glasgow', $articles[0]['title']);
     $this->assertEquals('2015-07-14 19:57:31', (string) $articles[1]['date']);
     $this->assertEquals('Storytelling and the Lives of Asylum Seekers', $articles[1]['title']);
 }
 public function testGetBody()
 {
     $this->assertEquals('Not found. Please try again.', $this->result->getBody());
 }
Ejemplo n.º 3
0
 public function testPingStatus()
 {
     $this->assertEquals(500, $this->response->getHttpStatus());
 }
Ejemplo n.º 4
0
 /**
  * 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;
     }
 }