diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-03-20 20:00:29 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2015-03-21 13:36:50 +0100 |
commit | 4dfafc5910baec90c9bc58aa61c1103dd41f13fe (patch) | |
tree | 34f9ffbcf2a8a8cbd792d5cb38ef4bb4ded39bbc /tests/unit/controller | |
parent | c0dda27f2078de4c3adcf345383ba423c233fe9f (diff) |
add a search parameter to the find all queries
Diffstat (limited to 'tests/unit/controller')
-rw-r--r-- | tests/unit/controller/ItemControllerTest.php | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/tests/unit/controller/ItemControllerTest.php b/tests/unit/controller/ItemControllerTest.php index 88e49c690..a58a907df 100644 --- a/tests/unit/controller/ItemControllerTest.php +++ b/tests/unit/controller/ItemControllerTest.php @@ -226,7 +226,8 @@ class ItemControllerTest extends \PHPUnit_Framework_TestCase { $this->equalTo(0), $this->equalTo(true), $this->equalTo(false), - $this->equalTo($this->user)) + $this->equalTo($this->user), + $this->equalTo([])) ->will($this->returnValue($result['items'])); $response = $this->controller->index(FeedType::FEED, 2, 3); @@ -234,6 +235,51 @@ class ItemControllerTest extends \PHPUnit_Framework_TestCase { } + public function testIndexSearch(){ + $feeds = [new Feed()]; + $result = [ + 'items' => [new Item()], + 'feeds' => $feeds, + 'newestItemId' => $this->newestItemId, + 'starred' => 3111 + ]; + + $this->itemsApiExpects(2, FeedType::FEED, '0'); + + $this->feedService->expects($this->once()) + ->method('findAll') + ->with($this->equalTo($this->user)) + ->will($this->returnValue($feeds)); + + $this->itemService->expects($this->once()) + ->method('getNewestItemId') + ->with($this->equalTo($this->user)) + ->will($this->returnValue($this->newestItemId)); + + $this->itemService->expects($this->once()) + ->method('starredCount') + ->with($this->equalTo($this->user)) + ->will($this->returnValue(3111)); + + $this->itemService->expects($this->once()) + ->method('findAll') + ->with( + $this->equalTo(2), + $this->equalTo(FeedType::FEED), + $this->equalTo(3), + $this->equalTo(0), + $this->equalTo(true), + $this->equalTo(false), + $this->equalTo($this->user), + $this->equalTo(['test', 'search'])) + ->will($this->returnValue($result['items'])); + + $response = $this->controller->index(FeedType::FEED, 2, 3, + 0, null, null, 'test%20search'); + $this->assertEquals($result, $response); + } + + public function testItemsOffsetNotZero(){ $result = ['items' => [new Item()]]; |