diff options
Diffstat (limited to 'tests/unit/external/FeedAPITest.php')
-rw-r--r-- | tests/unit/external/FeedAPITest.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/unit/external/FeedAPITest.php b/tests/unit/external/FeedAPITest.php index a42a1c8c9..6b133610e 100644 --- a/tests/unit/external/FeedAPITest.php +++ b/tests/unit/external/FeedAPITest.php @@ -115,6 +115,15 @@ class FeedAPITest extends ControllerTestUtility { } + public function testGetAllFromUsersAnnotations(){ + $this->assertDefaultAnnotations('getAllFromAllUsers'); + } + + + public function testUpdateAnnotations(){ + $this->assertDefaultAnnotations('update'); + } + public function testGetAll() { $feeds = array( new Feed() @@ -439,4 +448,57 @@ class FeedAPITest extends ControllerTestUtility { $this->assertEquals($this->msg, $data['message']); $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); } + + + public function testGetAllFromAllUsers(){ + $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->getAllFromAllUsers(); + $this->assertTrue($response instanceof JSONResponse); + $this->assertEquals('{"feeds":[{"id":1,"userId":"john"}]}', $response->render()); + } + + + public function testUpdate() { + $feedId = 3; + $userId = 'hi'; + $request = new Request(array('params' => array( + 'feedId' => $feedId, + 'userId' => $userId + ))); + $this->feedAPI = new FeedAPI( + $this->api, + $request, + $this->folderBusinessLayer, + $this->feedBusinessLayer, + $this->itemBusinessLayer + ); + $this->feedBusinessLayer->expects($this->once()) + ->method('update') + ->with($this->equalTo($feedId), $this->equalTo($userId)); + + $this->feedAPI->update(); + } + + + public function testUpdateNotFound() { + $this->feedBusinessLayer->expects($this->once()) + ->method('update') + ->will($this->throwException(new BusinessLayerException($this->msg))); + + $response = $this->feedAPI->update(); + + $data = $response->getData(); + $this->assertEquals($this->msg, $data['message']); + $this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); + + } + + } |