From b8b4dfb4969e1baf84a14fb65a5dc153b0f5fae4 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 9 May 2013 12:57:35 +0200 Subject: 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 --- tests/unit/controller/ItemControllerTest.php | 38 +++++++++++++--------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'tests/unit/controller/ItemControllerTest.php') diff --git a/tests/unit/controller/ItemControllerTest.php b/tests/unit/controller/ItemControllerTest.php index 16df210e0..e0e90af1e 100644 --- a/tests/unit/controller/ItemControllerTest.php +++ b/tests/unit/controller/ItemControllerTest.php @@ -62,7 +62,7 @@ class ItemControllerTest extends ControllerTestUtility { ->getMock(); $this->request = new Request(); $this->controller = new ItemController($this->api, $this->request, - $this->itemBusinessLayer, $this->feedBusinessLayer); + $this->feedBusinessLayer, $this->itemBusinessLayer); $this->user = 'jackob'; $this->newestItemId = 12312; } @@ -74,8 +74,8 @@ class ItemControllerTest extends ControllerTestUtility { ); $request = $this->getRequest($post); - return new ItemController($this->api, $request, $this->itemBusinessLayer, - $this->feedBusinessLayer); + return new ItemController($this->api, $request, + $this->feedBusinessLayer, $this->itemBusinessLayer); } @@ -108,9 +108,8 @@ class ItemControllerTest extends ControllerTestUtility { $this->assertItemControllerAnnotations('unread'); } - - public function testReadFeedAnnotations(){ - $this->assertItemControllerAnnotations('readFeed'); + public function testReadAllAnnotations(){ + $this->assertItemControllerAnnotations('readAll'); } @@ -293,37 +292,34 @@ class ItemControllerTest extends ControllerTestUtility { } - public function testReadFeed(){ - $url = array( - 'feedId' => 4 - ); + public function testReadAll(){ + $feed = new Feed(); $post = array( 'highestItemId' => 5 ); - $this->controller = $this->getPostController($post, $url); + $this->controller = $this->getPostController($post); $expected = array( - 'feeds' => array( - array( - 'id' => 4, - 'unreadCount' => 0 - ) - ) + 'feeds' => array($feed) ); $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); + ->method('readAll') + ->with($this->equalTo($post['highestItemId']), + $this->equalTo($this->user)); + $this->feedBusinessLayer->expects($this->once()) + ->method('findAll') + ->with($this->equalTo($this->user)) + ->will($this->returnValue(array($feed))); - $response = $this->controller->readFeed(); + $response = $this->controller->readAll(); $this->assertTrue($response instanceof JSONResponse); $this->assertEquals($expected, $response->getParams()); } - private function itemsApiExpects($id, $type){ $this->api->expects($this->once()) ->method('getUserValue') -- cgit v1.2.3