public function testStar() { $itemId = 3; $feedId = 5; $guidHash = md5('hihi'); $item = new Item(); $item->setStatus(128); $item->setId($itemId); $item->setUnstarred(); $expectedItem = new Item(); $expectedItem->setStatus(128); $expectedItem->setStarred(); $expectedItem->setId($itemId); $expectedItem->setLastModified($this->time); $this->mapper->expects($this->once())->method('findByGuidHash')->with($this->equalTo($guidHash), $this->equalTo($feedId), $this->equalTo($this->user))->will($this->returnValue($item)); $this->mapper->expects($this->once())->method('update')->with($this->equalTo($expectedItem)); $this->itemBusinessLayer->star($feedId, $guidHash, true, $this->user); $this->assertTrue($item->isStarred()); }
public function testImportArticlesCreatesOwnFeedWhenNotFound() { $url = 'http://owncloud/args'; $feed = new Feed(); $feed->setId(3); $feed->setUserId($this->user); $feed->setUrl($url); $feed->setLink($url); $feed->setTitle('Articles without feed'); $feed->setAdded($this->time); $feed->setFolderId(0); $feed->setPreventUpdate(true); $feeds = [$feed]; $item = new Item(); $item->setFeedId(3); $item->setAuthor('john'); $item->setGuid('s'); $item->setGuidHash('s'); $item->setTitle('hey'); $item->setPubDate(333); $item->setBody('come over'); $item->setEnclosureMime('mime'); $item->setEnclosureLink('lin'); $item->setUnread(); $item->setUnstarred(); $item->setLastModified($this->time); $json = $item->toExport(['feed3' => $feed]); $json2 = $json; // believe it or not this copies stuff :D $json2['feedLink'] = 'http://test.com'; $items = [$json, $json2]; $insertFeed = new Feed(); $insertFeed->setLink('http://owncloud/nofeed'); $insertFeed->setUrl('http://owncloud/nofeed'); $insertFeed->setUserId($this->user); $insertFeed->setTitle('Articles without feed'); $insertFeed->setAdded($this->time); $insertFeed->setPreventUpdate(true); $insertFeed->setFolderId(0); $this->l10n->expects($this->once())->method('t')->will($this->returnValue('Articles without feed')); $this->feedMapper->expects($this->once())->method('findAllFromUser')->with($this->equalTo($this->user))->will($this->returnValue($feeds)); $this->feedMapper->expects($this->once())->method('insert')->with($this->equalTo($insertFeed))->will($this->returnValue($insertFeed)); $this->itemMapper->expects($this->at(0))->method('findByGuidHash')->will($this->throwException(new DoesNotExistException('yo'))); $this->purifier->expects($this->once())->method('purify')->with($this->equalTo($item->getBody()))->will($this->returnValue($item->getBody())); $this->itemMapper->expects($this->at(1))->method('insert')->with($this->equalTo($item)); $this->itemMapper->expects($this->at(2))->method('findByGuidHash')->will($this->returnValue($item)); $this->itemMapper->expects($this->at(3))->method('update')->with($this->equalTo($item)); $this->feedMapper->expects($this->once())->method('findByUrlHash')->will($this->returnValue($feed)); $result = $this->feedService->importArticles($items, $this->user); $this->assertEquals($feed, $result); }