예제 #1
0
 public function testGetAllArticles()
 {
     $item1 = new Item();
     $item1->setFeedId(3);
     $item2 = new Item();
     $item2->setFeedId(5);
     $feed1 = new Feed();
     $feed1->setId(3);
     $feed1->setLink('http://goo');
     $feed2 = new Feed();
     $feed2->setId(5);
     $feed2->setLink('http://gee');
     $feeds = array($feed1, $feed2);
     $articles = array($item1, $item2);
     $this->feedBusinessLayer->expects($this->once())->method('findAll')->with($this->equalTo($this->user))->will($this->returnValue($feeds));
     $this->itemBusinessLayer->expects($this->once())->method('getUnreadOrStarred')->with($this->equalTo($this->user))->will($this->returnValue($articles));
     $return = $this->controller->articles();
     $headers = $return->getHeaders();
     $this->assertEquals('attachment; filename="articles.json"', $headers['Content-Disposition']);
     $this->assertEquals('[{"guid":null,"url":null,"title":null,' . '"author":null,"pubDate":null,"body":null,"enclosureMime":null,' . '"enclosureLink":null,"unread":false,"starred":false,' . '"feedLink":"http:\\/\\/goo"},{"guid":null,"url":null,"title":null,' . '"author":null,"pubDate":null,"body":null,"enclosureMime":null,' . '"enclosureLink":null,"unread":false,"starred":false,' . '"feedLink":"http:\\/\\/gee"}]', $return->render());
 }
예제 #2
0
 public function testPurgeDeletedWithoutInterval()
 {
     $feed1 = new Feed();
     $feed1->setId(3);
     $feed2 = new Feed();
     $feed2->setId(5);
     $feeds = [$feed1, $feed2];
     $this->feedMapper->expects($this->once())->method('getToDelete')->with($this->equalTo(null), $this->equalTo($this->user))->will($this->returnValue($feeds));
     $this->feedMapper->expects($this->at(1))->method('delete')->with($this->equalTo($feed1));
     $this->feedMapper->expects($this->at(2))->method('delete')->with($this->equalTo($feed2));
     $this->feedService->purgeDeleted($this->user, false);
 }
예제 #3
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);
 }
예제 #4
0
 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());
 }
예제 #5
0
 public function testfromAllUsers()
 {
     $feed = new Feed();
     $feed->setUrl(3);
     $feed->setId(1);
     $feed->setUserId('john');
     $feeds = [$feed];
     $this->feedService->expects($this->once())->method('findAllFromAllUsers')->will($this->returnValue($feeds));
     $response = json_encode($this->feedAPI->fromAllUsers());
     $this->assertEquals('{"feeds":[{"id":1,"userId":"john"}]}', $response);
 }
예제 #6
0
 public function testfromAllUsers()
 {
     $feed = new Feed();
     $feed->setUrl(3);
     $feed->setId(1);
     $feed->setUserId('john');
     $feeds = array($feed);
     $this->feedBusinessLayer->expects($this->once())->method('findAllFromAllUsers')->will($this->returnValue($feeds));
     $response = $this->feedAPI->fromAllUsers();
     $this->assertEquals('{"feeds":[{"id":1,"userId":"john"}]}', $response->render());
 }