コード例 #1
0
 public function testUpdate()
 {
     $feed = new Feed();
     $feed->setId(3);
     $feed->setUnreadCount(44);
     $result = ['feeds' => [['id' => $feed->getId(), 'unreadCount' => $feed->getUnreadCount()]]];
     $this->feedService->expects($this->once())->method('update')->with($this->equalTo(4), $this->equalTo($this->user))->will($this->returnValue($feed));
     $response = $this->controller->update(4);
     $this->assertEquals($result, $response);
 }
コード例 #2
0
ファイル: FeedServiceTest.php プロジェクト: nrbrt/news
 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);
 }
コード例 #3
0
ファイル: FeedControllerTest.php プロジェクト: hroo772/news
 public function testUpdate()
 {
     $feed = new Feed();
     $feed->setId(3);
     $feed->setUnreadCount(44);
     $result = array('feeds' => array(array('id' => $feed->getId(), 'unreadCount' => $feed->getUnreadCount())));
     $url = array('feedId' => 4);
     $this->controller = $this->getPostController(array(), $url);
     $this->feedBusinessLayer->expects($this->once())->method('update')->with($this->equalTo($url['feedId']), $this->equalTo($this->user))->will($this->returnValue($feed));
     $response = $this->controller->update();
     $this->assertEquals($result, $response->getData());
 }