+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ }
+
+ public function testGetEntriesPublicOnly()
+ {
+ $entry = $this->client->getContainer()
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByUser(1);
+
+ if (!$entry) {
+ $this->markTestSkipped('No content found in db.');
+ }
+
+ // generate at least one public entry
+ $entry->generateUid();
+
+ $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
+ $em->persist($entry);
+ $em->flush();
+
+ $this->client->request('GET', '/api/entries', [
+ 'public' => 1,
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertGreaterThanOrEqual(1, count($content));
+ $this->assertArrayHasKey('items', $content['_embedded']);
+ $this->assertGreaterThanOrEqual(1, $content['total']);
+ $this->assertSame(1, $content['page']);
+ $this->assertSame(30, $content['limit']);
+ $this->assertGreaterThanOrEqual(1, $content['pages']);
+
+ $this->assertArrayHasKey('_links', $content);
+ $this->assertArrayHasKey('self', $content['_links']);
+ $this->assertArrayHasKey('first', $content['_links']);
+ $this->assertArrayHasKey('last', $content['_links']);
+
+ foreach (['self', 'first', 'last'] as $link) {
+ $this->assertArrayHasKey('href', $content['_links'][$link]);
+ $this->assertContains('public=1', $content['_links'][$link]['href']);
+ }
+
+ $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
+ }
+
+ public function testGetEntriesOnPageTwo()
+ {
+ $this->client->request('GET', '/api/entries', [
+ 'page' => 2,
+ 'perPage' => 2,
+ ]);
+
+ $this->assertSame(200, $this->client->getResponse()->getStatusCode());
+
+ $content = json_decode($this->client->getResponse()->getContent(), true);
+
+ $this->assertGreaterThanOrEqual(0, $content['total']);
+ $this->assertSame(2, $content['page']);
+ $this->assertSame(2, $content['limit']);