Example #1
0
 public function testRead()
 {
     $itemId = 3;
     $item = new Item();
     $item->setStatus(128);
     $item->setId($itemId);
     $item->setRead();
     $expectedItem = new Item();
     $expectedItem->setStatus(128);
     $expectedItem->setUnread();
     $expectedItem->setId($itemId);
     $expectedItem->setLastModified($this->time);
     $this->mapper->expects($this->once())->method('find')->with($this->equalTo($itemId), $this->equalTo($this->user))->will($this->returnValue($item));
     $this->mapper->expects($this->once())->method('update')->with($this->equalTo($expectedItem));
     $this->itemBusinessLayer->read($itemId, false, $this->user);
     $this->assertTrue($item->isUnread());
 }
Example #2
0
 public function testUpdateDoesNotFindUpdatedEntry()
 {
     $feed = new Feed();
     $feed->setId(3);
     $feed->setArticlesPerUpdate(1);
     $item = new Item();
     $item->setGuidHash(md5('hi'));
     $item->setPubDate(3333);
     $item->setId(4);
     $items = [$item];
     $item2 = new Item();
     $item2->setPubDate(111);
     $fetchReturn = [$feed, $items];
     $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->feedMapper->expects($this->at(1))->method('update')->with($this->equalTo($feed));
     $this->fetcher->expects($this->once())->method('fetch')->will($this->returnValue($fetchReturn));
     $this->itemMapper->expects($this->once())->method('findByGuidHash')->with($this->equalTo($item->getGuidHash()), $this->equalTo($feed->getId()), $this->equalTo($this->user))->will($this->returnValue($item2));
     $this->feedMapper->expects($this->at(2))->method('find')->with($this->equalTo($feed->getId()), $this->equalTo($this->user))->will($this->throwException($ex));
     $this->setExpectedException('\\OCA\\News\\Service\\ServiceNotFoundException');
     $this->feedService->update($feed->getId(), $this->user);
 }