Exemplo n.º 1
0
 public function testGetCondensedList()
 {
     $feed = new Feed(self::$app->getContainer()['mongodb']);
     $list = $feed->getCondensedList();
     foreach ($list as $item) {
         $this->assertArrayHasKey('title', $item->feed);
         $this->assertArrayHasKey('publicId', $item->feed);
         $this->assertArrayHasKey('link', $item->feed);
     }
 }
Exemplo n.º 2
0
 public function actionUpdate()
 {
     $httpRequest = $this->context->getService('httpRequest');
     if ($this->option->get('cron') != $httpRequest->getQuery('cron')) {
         throw new \Nette\Application\BadRequestException("Invalid request");
     }
     $feeds = $this->feed->get_all();
     foreach ($feeds as $feed) {
         try {
             $articles = $this->feed->parse_articles($feed->id);
             $this->article->add_multiple($articles);
             // Debugger::dump($articles);
             // exit;
         } catch (\Exception $e) {
             $this->error->save($feed->id, $e);
         }
         libxml_clear_errors();
     }
     $this->terminate();
 }