aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2019-05-12 00:00:00 +0200
committerKevin Decherf <kevin@kdecherf.com>2019-05-18 18:11:08 +0200
commit2c290747cb0d235392f6e5d22205a706c6474168 (patch)
treefdf67f203aca096e8b61bd245b387d05cc38e20b /tests
parentde1162b91a205a98a3f8ed01bd80285793b18380 (diff)
downloadwallabag-2c290747cb0d235392f6e5d22205a706c6474168.tar.gz
wallabag-2c290747cb0d235392f6e5d22205a706c6474168.tar.zst
wallabag-2c290747cb0d235392f6e5d22205a706c6474168.zip
api/entries: add parameter detail to exclude or include content in response
detail=metadata will nullify the content field of entries in order to make smaller responses. detail=full keeps the former behavior, it sends the content of entries. It's the default, for backward compatibility. Fixes #2817 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 8cc12ed3..8b7898ee 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -133,6 +133,27 @@ class EntryRestControllerTest extends WallabagApiTestCase
133 $this->assertSame(1, $content['page']); 133 $this->assertSame(1, $content['page']);
134 $this->assertGreaterThanOrEqual(1, $content['pages']); 134 $this->assertGreaterThanOrEqual(1, $content['pages']);
135 135
136 $this->assertNotNull($content['_embedded']['items'][0]['content']);
137
138 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
139 }
140
141 public function testGetEntriesDetailMetadata()
142 {
143 $this->client->request('GET', '/api/entries?detail=metadata');
144
145 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
146
147 $content = json_decode($this->client->getResponse()->getContent(), true);
148
149 $this->assertGreaterThanOrEqual(1, \count($content));
150 $this->assertNotEmpty($content['_embedded']['items']);
151 $this->assertGreaterThanOrEqual(1, $content['total']);
152 $this->assertSame(1, $content['page']);
153 $this->assertGreaterThanOrEqual(1, $content['pages']);
154
155 $this->assertNull($content['_embedded']['items'][0]['content']);
156
136 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type')); 157 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
137 } 158 }
138 159