예제 #1
0
 public function testValueOfElementWhichChangedItsValueIsUpdatedInBlacklistArray()
 {
     $data = ['o' => 'p', 'y' => 'u'];
     $this->subjectUnderTest->applyBlacklist($data);
     //This will add entries from $data to blacklist
     $data['o'] = 'x';
     $this->subjectUnderTest->applyBlacklist($data);
     $blacklist = $this->subjectUnderTest->getBlacklist();
     $this->assertArrayHasKey('o', $blacklist);
     $this->assertSame('x', $blacklist['o']);
 }
예제 #2
0
 /**
  * Triggers downloading new data from origin and parsing it.
  * Normally this method is executed by ping(), but you may decide to call it manually at any time.
  */
 public function getNewDataFromOrigin()
 {
     //TODO maybe add checksum to skip all operations if it's the same as previous?
     $feed = $this->fetchFeed($this->configuration->getUrl());
     if ($feed === false) {
         $this->logger->error($this->getName() . ': Failed to fetch feed from ' . $this->configuration->getUrl());
         return;
     }
     $this->logger->debug('Downloaded RSS for ' . $this->configuration->getUrl() . ' (' . strlen($feed) . ' bytes)');
     $this->lastSuccessfulDownload = time();
     $feed = $this->parseFeedXml($feed);
     if ($feed === false) {
         return;
     }
     $this->blacklist->applyBlacklist($feed);
     if (empty($feed)) {
         $this->logger->debug($this->getName() . ': No new links in feed');
         return;
     }
     foreach ($feed as $name => $link) {
         $this->links[] = ['name' => $name, 'link' => $link];
     }
 }