diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-09 12:57:35 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-09 12:57:35 +0200 |
commit | b8b4dfb4969e1baf84a14fb65a5dc153b0f5fae4 (patch) | |
tree | 27e211e26f442efd72a7f34903953ad57b1a9b76 /tests/unit/controller/FeedControllerTest.php | |
parent | fe0de2ab84a88cb4c742f4f10fd43716934b7282 (diff) |
only make one request for mark all read and mark folder read, fix #171, fix a bug that prevented readding of feeds when its folder was deleted, fix a bug that would not allow mark read for feeds when the app was started for the first time
Diffstat (limited to 'tests/unit/controller/FeedControllerTest.php')
-rw-r--r-- | tests/unit/controller/FeedControllerTest.php | 81 |
1 files changed, 78 insertions, 3 deletions
diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php index 403d9c3c8..c89d432d6 100644 --- a/tests/unit/controller/FeedControllerTest.php +++ b/tests/unit/controller/FeedControllerTest.php @@ -65,7 +65,8 @@ class FeedControllerTest extends ControllerTestUtility { ->getMock(); $this->request = new Request(); $this->controller = new FeedController($this->api, $this->request, - $this->feedBusinessLayer, $this->folderBusinessLayer, + $this->folderBusinessLayer, + $this->feedBusinessLayer, $this->itemBusinessLayer); $this->user = 'jack'; } @@ -83,8 +84,10 @@ class FeedControllerTest extends ControllerTestUtility { ); $request = $this->getRequest($post); - return new FeedController($this->api, $request, $this->feedBusinessLayer, - $this->folderBusinessLayer, $this->itemBusinessLayer); + return new FeedController($this->api, $request, + $this->folderBusinessLayer, + $this->feedBusinessLayer, + $this->itemBusinessLayer); } @@ -122,6 +125,10 @@ class FeedControllerTest extends ControllerTestUtility { $this->assertFeedControllerAnnotations('importGoogleReader'); } + public function testReadAnnotations(){ + $this->assertFeedControllerAnnotations('read'); + } + public function testFeeds(){ $result = array( 'feeds' => array( @@ -287,6 +294,40 @@ class FeedControllerTest extends ControllerTestUtility { public function testCreate(){ $result = array( + 'feeds' => array(new Feed()), + 'newestItemId' => 3 + ); + + $post = array( + 'url' => 'hi', + 'parentFolderId' => 4 + ); + $this->controller = $this->getPostController($post); + + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + + $this->itemBusinessLayer->expects($this->once()) + ->method('getNewestItemId') + ->will($this->returnValue($result['newestItemId'])); + + $this->feedBusinessLayer->expects($this->once()) + ->method('create') + ->with($this->equalTo($post['url']), + $this->equalTo($post['parentFolderId']), + $this->equalTo($this->user)) + ->will($this->returnValue($result['feeds'][0])); + + $response = $this->controller->create(); + + $this->assertEquals($result, $response->getParams()); + $this->assertTrue($response instanceof JSONResponse); + } + + + public function testCreateNoItems(){ + $result = array( 'feeds' => array(new Feed()) ); @@ -300,6 +341,10 @@ class FeedControllerTest extends ControllerTestUtility { ->method('getUserId') ->will($this->returnValue($this->user)); + $this->itemBusinessLayer->expects($this->once()) + ->method('getNewestItemId') + ->will($this->throwException(new BusinessLayerException(''))); + $this->feedBusinessLayer->expects($this->once()) ->method('create') ->with($this->equalTo($post['url']), @@ -508,4 +553,34 @@ class FeedControllerTest extends ControllerTestUtility { $this->assertTrue($response instanceof JSONResponse); } + + public function testReadFeed(){ + $url = array( + 'feedId' => 4 + ); + $post = array( + 'highestItemId' => 5 + ); + $this->controller = $this->getPostController($post, $url); + $expected = array( + 'feeds' => array( + array( + 'id' => 4, + 'unreadCount' => 0 + ) + ) + ); + + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + $this->itemBusinessLayer->expects($this->once()) + ->method('readFeed') + ->with($url['feedId'], $post['highestItemId'], $this->user); + + $response = $this->controller->read(); + $this->assertTrue($response instanceof JSONResponse); + $this->assertEquals($expected, $response->getParams()); + } + }
\ No newline at end of file |