Пример #1
0
 public function testUpdatePassesFullText()
 {
     $feed = new Feed();
     $feed->setId(3);
     $feed->setUrl('https://goo.com');
     $feed->setEtag('abc');
     $feed->setLastModified(123);
     $feed->setFullTextEnabled(true);
     $ex = new DoesNotExistException('');
     $this->feedMapper->expects($this->at(0))->method('find')->with($this->equalTo($feed->getId()), $this->equalTo($this->user))->will($this->returnValue($feed));
     $this->fetcher->expects($this->once())->method('fetch')->with($this->equalTo($feed->getUrl()), $this->equalTo(false), $this->equalTo($feed->getLastModified()), $this->equalTo($feed->getEtag()), $this->equalTo($feed->getFullTextEnabled()))->will($this->throwException($ex));
     $this->setExpectedException('OCP\\AppFramework\\Db\\DoesNotExistException');
     $this->feedService->update($feed->getId(), $this->user);
 }
Пример #2
0
 protected function buildFeed($parsedFeed, $url, $getFavicon, $modified, $etag, $location)
 {
     $feed = new Feed();
     $link = $parsedFeed->getSiteUrl();
     if (!$link) {
         $link = $location;
     }
     // unescape content because angularjs helps against XSS
     $title = strip_tags($this->decodeTwice($parsedFeed->getTitle()));
     $feed->setTitle($title);
     $feed->setUrl($url);
     // the url used to add the feed
     $feed->setLocation($location);
     // the url where the feed was found
     $feed->setLink($link);
     // <link> attribute in the feed
     $feed->setLastModified($modified);
     $feed->setEtag($etag);
     $feed->setAdded($this->time->getTime());
     if ($getFavicon) {
         $faviconFetcher = $this->faviconFactory->build();
         $favicon = $faviconFetcher->find($feed->getLink());
         $feed->setFaviconLink($favicon);
     }
     return $feed;
 }
Пример #3
0
 private function createFeed($feed)
 {
     $newFeed = new Feed();
     $newFeed->setUserId($this->userId);
     $newFeed->setFolderId($feed['folderId']);
     $newFeed->setTitle($feed['title']);
     $newFeed->setUrl($feed['url']);
     $newFeed->setLocation($feed['location']);
     $newFeed->setFaviconLink($feed['faviconLink']);
     $newFeed->setAdded($feed['added']);
     $newFeed->setLink($feed['link']);
     $newFeed->setPreventUpdate($feed['preventUpdate']);
     $newFeed->setDeletedAt($feed['deletedAt']);
     $newFeed->setArticlesPerUpdate($feed['articlesPerUpdate']);
     $newFeed->setLastModified($feed['lastModified']);
     $newFeed->setEtag($feed['etag']);
     return $this->feedMapper->insert($newFeed);
 }
Пример #4
0
 private function createFeed($hasFavicon = false)
 {
     $this->expectFeed('getTitle', $this->feedTitle);
     $this->expectFeed('getSiteUrl', $this->feedLink);
     $feed = new Feed();
     $feed->setTitle('&its a title');
     $feed->setUrl($this->url);
     $feed->setLink($this->feedLink);
     $feed->setAdded($this->time);
     $feed->setLastModified($this->modified);
     $feed->setEtag($this->etag);
     $feed->setLocation($this->location);
     if ($hasFavicon) {
         $this->faviconFactory->expects($this->once())->method('build')->will($this->returnValue($this->faviconFetcher));
         $this->faviconFetcher->expects($this->once())->method('find')->with($this->equalTo($this->feedLink))->will($this->returnValue($this->webFavicon));
         $feed->setFaviconLink($this->webFavicon);
     }
     return $feed;
 }
Пример #5
0
 public function testUpdateCreatesNewEntry()
 {
     $feed = new Feed();
     $feed->setId(3);
     $feed->setArticlesPerUpdate(1);
     $feed->setLink('http://test');
     $feed->setUrl('http://test');
     $feed->setUrlHash('yo');
     $feed->setLastModified(3);
     $feed->setEtag(4);
     $item = new Item();
     $item->setGuidHash(md5('hi'));
     $item->setFeedId(3);
     $items = [$item];
     $ex = new DoesNotExistException('hi');
     $fetchReturn = [$feed, $items];
     $this->feedMapper->expects($this->at(0))->method('find')->with($this->equalTo($feed->getId()), $this->equalTo($this->user))->will($this->returnValue($feed));
     $this->fetcher->expects($this->once())->method('fetch')->with($this->equalTo('http://test'), $this->equalTo(false), $this->equalTo(3), $this->equalTo(4))->will($this->returnValue($fetchReturn));
     $this->feedMapper->expects($this->at(1))->method('update')->with($this->equalTo($feed));
     $this->itemMapper->expects($this->once())->method('findByGuidHash')->with($this->equalTo($items[0]->getGuidHash()), $this->equalTo($items[0]->getFeedId()), $this->equalTo($this->user))->will($this->throwException($ex));
     $this->enhancer->expects($this->at(0))->method('enhance')->with($this->equalTo($items[0]), $this->equalTo($feed->getUrl()))->will($this->returnValue($items[0]));
     $this->purifier->expects($this->at(0))->method('purify')->with($this->equalTo($items[0]->getBody()))->will($this->returnValue($items[0]->getBody()));
     $this->itemMapper->expects($this->once())->method('insert')->with($this->equalTo($items[0]));
     $this->feedMapper->expects($this->at(2))->method('find')->with($feed->getId(), $this->user)->will($this->returnValue($feed));
     $return = $this->feedService->update($feed->getId(), $this->user);
     $this->assertEquals($return, $feed);
 }