/**
  * @test
  */
 public function fetchItemsGetsMatchingItemsFromFeed()
 {
     $channel = new \Planetflow3\Domain\Model\Channel();
     $channel->setFeedUrl('file://' . __DIR__ . '/../../Fixtures/Feeds/news.typo3.org-news-teams-flow3-rss.xml');
     $channel->setName('Test Feed');
     $channel->setUrl('http://www.example.com/test');
     $this->channelRepository->add($channel);
     $this->channelService->fetchItems($channel);
     $this->assertEquals(10, count($channel->getItems()), 'Should fetch all 10 items from feed');
 }
 /**
  * Fetch new items from all channels
  *
  * This command should be run by a cronjob to do periodical
  * updates to the channel feeds.
  *
  * @param boolean $verbose TRUE if log messages should be shown on the console
  * @return void
  */
 public function fetchCommand($verbose = FALSE)
 {
     if ($verbose) {
         echo 'Fetching feeds';
     }
     $command = $this;
     $channels = $this->channelRepository->findAll();
     foreach ($channels as $channel) {
         if ($verbose) {
             echo 'Fetching items for ' . $channel->getFeedUrl() . '...' . PHP_EOL;
         }
         $this->channelService->fetchItems($channel, function (Item $item, $message, $severity = LOG_INFO) use($channel, $command, $verbose) {
             if ($verbose) {
                 echo $message . PHP_EOL;
             }
             $command->feedLogger->log($channel->getName() . ': ' . $item->getLink() . ' - ' . $message, $severity);
         });
         if ($verbose) {
             echo "Done fetching items." . PHP_EOL;
         }
     }
 }