Example #1
0
 public function testResponseStreamSetterAcceptsNull()
 {
     $resource = fopen('php://temp', 'w+');
     $this->assertInternalType('resource', $resource, 'Failed to create valid resource for test');
     $this->subjectUnderTest->setResponseStream($resource);
     $this->subjectUnderTest->setResponseStream(null);
     $this->assertNull($this->subjectUnderTest->getResponseStream());
 }
Example #2
0
 /**
  * @param $url
  *
  * @return bool|string Returns false on error or downloaded RSS file content
  */
 private function fetchFeed($url)
 {
     $rssRequest = new Request('GET', $url);
     $fetchJob = new FetchJob($this->appConfiguration, $rssRequest);
     //TODO: Implement RSS size limit when FetchJob start supporting it
     try {
         if (!$fetchJob->execute()) {
             throw new \Exception('RSS download job failed for unknown reason');
         }
     } catch (\Exception $e) {
         $type = get_class($e);
         $this->logger->error($type . ': ' . $e->getMessage());
         return false;
     }
     $responseStream = $fetchJob->getResponseStream();
     fseek($responseStream, 0);
     return stream_get_contents($responseStream);
 }