diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-14 02:22:36 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-14 02:22:44 +0200 |
commit | df8f6b5fee643c5b2af8e8d33a7865e898518485 (patch) | |
tree | 7100d25d814d5f4b4cf502c9e2b9e6dd5f562ab3 /tests/unit | |
parent | 67d7754c364147c274790a76dab7cbfedd352645 (diff) |
implement pull to refresh, fix #44
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/controller/ItemControllerTest.php | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/unit/controller/ItemControllerTest.php b/tests/unit/controller/ItemControllerTest.php index 5a1104137..9d104b8f0 100644 --- a/tests/unit/controller/ItemControllerTest.php +++ b/tests/unit/controller/ItemControllerTest.php @@ -84,11 +84,16 @@ class ItemControllerTest extends ControllerTestUtility { $this->assertAnnotations($this->controller, $methodName, $annotations); } + public function testItemsAnnotations(){ $this->assertItemControllerAnnotations('items'); } + public function testNewItemsAnnotations(){ + $this->assertItemControllerAnnotations('newItems'); + } + public function testStarAnnotations(){ $this->assertItemControllerAnnotations('star'); } @@ -446,5 +451,86 @@ class ItemControllerTest extends ControllerTestUtility { } + public function testNewItems(){ + $feeds = array(new Feed()); + $result = array( + 'items' => array(new Item()), + 'feeds' => $feeds, + 'newestItemId' => $this->newestItemId, + 'starred' => 3111 + ); + $post = array( + 'lastModified' => 3, + 'type' => FeedType::FEED, + 'id' => 2 + ); + $this->controller = $this->getPostController($post); + + $this->api->expects($this->once()) + ->method('getUserValue') + ->with($this->equalTo('showAll')) + ->will($this->returnValue('1')); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + + $this->feedBusinessLayer->expects($this->once()) + ->method('findAll') + ->with($this->equalTo($this->user)) + ->will($this->returnValue($feeds)); + + $this->itemBusinessLayer->expects($this->once()) + ->method('getNewestItemId') + ->with($this->equalTo($this->user)) + ->will($this->returnValue($this->newestItemId)); + + $this->itemBusinessLayer->expects($this->once()) + ->method('starredCount') + ->with($this->equalTo($this->user)) + ->will($this->returnValue(3111)); + + $this->itemBusinessLayer->expects($this->once()) + ->method('findAllNew') + ->with( + $this->equalTo($post['id']), + $this->equalTo($post['type']), + $this->equalTo($post['lastModified']), + $this->equalTo(true), + $this->equalTo($this->user)) + ->will($this->returnValue($result['items'])); + + $response = $this->controller->newItems(); + $this->assertEquals($result, $response->getParams()); + $this->assertTrue($response instanceof JSONResponse); + } + + + public function testGetNewItemsNoNewestItemsId(){ + $result = array(); + $post = array( + 'lastModified' => 3, + 'type' => FeedType::FEED, + 'id' => 2 + ); + $this->controller = $this->getPostController($post); + + $this->api->expects($this->once()) + ->method('getUserValue') + ->with($this->equalTo('showAll')) + ->will($this->returnValue('1')); + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + + $this->itemBusinessLayer->expects($this->once()) + ->method('getNewestItemId') + ->with($this->equalTo($this->user)) + ->will($this->throwException(new BusinessLayerException(''))); + + $response = $this->controller->newItems(); + $this->assertEquals($result, $response->getParams()); + $this->assertTrue($response instanceof JSONResponse); + } + }
\ No newline at end of file |