diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-23 01:23:47 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-03-23 01:23:47 +0100 |
commit | 29571aff347e7cd8ab9a755d6211fed575d4f129 (patch) | |
tree | 37ddedfff203eb84d2a2e9fdf3ac6a7268710caa /tests | |
parent | a2d264b4d4d7d71c719c0665c40f55e411bdd4f4 (diff) |
finished itemcontroller
Diffstat (limited to 'tests')
-rw-r--r-- | tests/controller/ItemControllerTest.php | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/tests/controller/ItemControllerTest.php b/tests/controller/ItemControllerTest.php index 4f7fe564a..2b389adad 100644 --- a/tests/controller/ItemControllerTest.php +++ b/tests/controller/ItemControllerTest.php @@ -32,7 +32,7 @@ use \OCA\AppFramework\Db\DoesNotExistException; use \OCA\AppFramework\Db\MultipleObjectsReturnedException; use \OCA\News\Db\Item; - +use \OCA\News\Db\FeedType; require_once(__DIR__ . "/../classloader.php"); @@ -213,4 +213,58 @@ class ItemControllerTest extends ControllerTestUtility { $this->assertTrue($response instanceof JSONResponse); } + + + public function testItems(){ + $result = array( + 'items' => array(new Item()) + ); + $post = array( + 'limit' => 3, + 'type' => FeedType::FEED, + 'id' => 2, + 'offset' => 0 + ); + $this->controller = $this->getPostController($post); + + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + $this->bl->expects($this->once()) + ->method('findAll') + ->with($post['id'], $post['type'], $post['limit'], + $post['offset'], $this->user) + ->will($this->returnValue($result['items'])); + + $response = $this->controller->items(); + $this->assertEquals($result, $response->getParams()); + $this->assertTrue($response instanceof JSONResponse); + } + + + public function testItemsNew(){ + $result = array( + 'items' => array(new Item()) + ); + $post = array( + 'type' => FeedType::FEED, + 'id' => 2, + 'updatedSince' => 3333 + ); + $this->controller = $this->getPostController($post); + + $this->api->expects($this->once()) + ->method('getUserId') + ->will($this->returnValue($this->user)); + $this->bl->expects($this->once()) + ->method('findAllNew') + ->with($post['id'], $post['type'], $post['updatedSince'], + $this->user) + ->will($this->returnValue($result['items'])); + + $response = $this->controller->items(); + $this->assertEquals($result, $response->getParams()); + $this->assertTrue($response instanceof JSONResponse); + } + }
\ No newline at end of file |