diff options
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/EntryRestController.php | 3 | ||||
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 2c2ec0c1..c544815e 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php | |||
@@ -98,12 +98,13 @@ class EntryRestController extends WallabagRestController | |||
98 | $tags = $request->query->get('tags', ''); | 98 | $tags = $request->query->get('tags', ''); |
99 | $since = $request->query->get('since', 0); | 99 | $since = $request->query->get('since', 0); |
100 | 100 | ||
101 | /** @var \Pagerfanta\Pagerfanta $pager */ | ||
101 | $pager = $this->getDoctrine() | 102 | $pager = $this->getDoctrine() |
102 | ->getRepository('WallabagCoreBundle:Entry') | 103 | ->getRepository('WallabagCoreBundle:Entry') |
103 | ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order, $since, $tags); | 104 | ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order, $since, $tags); |
104 | 105 | ||
105 | $pager->setCurrentPage($page); | ||
106 | $pager->setMaxPerPage($perPage); | 106 | $pager->setMaxPerPage($perPage); |
107 | $pager->setCurrentPage($page); | ||
107 | 108 | ||
108 | $pagerfantaFactory = new PagerfantaFactory('page', 'perPage'); | 109 | $pagerfantaFactory = new PagerfantaFactory('page', 'perPage'); |
109 | $paginatedCollection = $pagerfantaFactory->createRepresentation( | 110 | $paginatedCollection = $pagerfantaFactory->createRepresentation( |
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 409a8291..63d70bd9 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -156,6 +156,22 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
156 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); | 156 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
157 | } | 157 | } |
158 | 158 | ||
159 | public function testGetEntriesOnPageTwo() | ||
160 | { | ||
161 | $this->client->request('GET', '/api/entries', [ | ||
162 | 'page' => 2, | ||
163 | 'perPage' => 2, | ||
164 | ]); | ||
165 | |||
166 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
167 | |||
168 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
169 | |||
170 | $this->assertGreaterThanOrEqual(0, $content['total']); | ||
171 | $this->assertEquals(2, $content['page']); | ||
172 | $this->assertEquals(2, $content['limit']); | ||
173 | } | ||
174 | |||
159 | public function testGetStarredEntries() | 175 | public function testGetStarredEntries() |
160 | { | 176 | { |
161 | $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); | 177 | $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); |