diff options
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 104 |
1 files changed, 56 insertions, 48 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 825f8f7a..566e9493 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -30,12 +30,55 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
30 | $this->assertEquals($entry->getUserEmail(), $content['user_email']); | 30 | $this->assertEquals($entry->getUserEmail(), $content['user_email']); |
31 | $this->assertEquals($entry->getUserId(), $content['user_id']); | 31 | $this->assertEquals($entry->getUserId(), $content['user_id']); |
32 | 32 | ||
33 | $this->assertTrue( | 33 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
34 | $this->client->getResponse()->headers->contains( | 34 | } |
35 | 'Content-Type', | 35 | |
36 | 'application/json' | 36 | public function testExportEntry() |
37 | ) | 37 | { |
38 | ); | 38 | $entry = $this->client->getContainer() |
39 | ->get('doctrine.orm.entity_manager') | ||
40 | ->getRepository('WallabagCoreBundle:Entry') | ||
41 | ->findOneBy(['user' => 1, 'isArchived' => false]); | ||
42 | |||
43 | if (!$entry) { | ||
44 | $this->markTestSkipped('No content found in db.'); | ||
45 | } | ||
46 | |||
47 | $this->client->request('GET', '/api/entries/'.$entry->getId().'/export.epub'); | ||
48 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
49 | |||
50 | // epub format got the content type in the content | ||
51 | $this->assertContains('application/epub', $this->client->getResponse()->getContent()); | ||
52 | $this->assertEquals('application/epub+zip', $this->client->getResponse()->headers->get('Content-Type')); | ||
53 | |||
54 | // re-auth client for mobi | ||
55 | $client = $this->createAuthorizedClient(); | ||
56 | $client->request('GET', '/api/entries/'.$entry->getId().'/export.mobi'); | ||
57 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
58 | |||
59 | $this->assertEquals('application/x-mobipocket-ebook', $client->getResponse()->headers->get('Content-Type')); | ||
60 | |||
61 | // re-auth client for pdf | ||
62 | $client = $this->createAuthorizedClient(); | ||
63 | $client->request('GET', '/api/entries/'.$entry->getId().'/export.pdf'); | ||
64 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
65 | |||
66 | $this->assertContains('PDF-', $client->getResponse()->getContent()); | ||
67 | $this->assertEquals('application/pdf', $client->getResponse()->headers->get('Content-Type')); | ||
68 | |||
69 | // re-auth client for pdf | ||
70 | $client = $this->createAuthorizedClient(); | ||
71 | $client->request('GET', '/api/entries/'.$entry->getId().'/export.txt'); | ||
72 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
73 | |||
74 | $this->assertContains('text/plain', $client->getResponse()->headers->get('Content-Type')); | ||
75 | |||
76 | // re-auth client for pdf | ||
77 | $client = $this->createAuthorizedClient(); | ||
78 | $client->request('GET', '/api/entries/'.$entry->getId().'/export.csv'); | ||
79 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
80 | |||
81 | $this->assertContains('application/csv', $client->getResponse()->headers->get('Content-Type')); | ||
39 | } | 82 | } |
40 | 83 | ||
41 | public function testGetOneEntryWrongUser() | 84 | public function testGetOneEntryWrongUser() |
@@ -68,12 +111,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
68 | $this->assertEquals(1, $content['page']); | 111 | $this->assertEquals(1, $content['page']); |
69 | $this->assertGreaterThanOrEqual(1, $content['pages']); | 112 | $this->assertGreaterThanOrEqual(1, $content['pages']); |
70 | 113 | ||
71 | $this->assertTrue( | 114 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
72 | $this->client->getResponse()->headers->contains( | ||
73 | 'Content-Type', | ||
74 | 'application/json' | ||
75 | ) | ||
76 | ); | ||
77 | } | 115 | } |
78 | 116 | ||
79 | public function testGetEntriesWithFullOptions() | 117 | public function testGetEntriesWithFullOptions() |
@@ -115,12 +153,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
115 | $this->assertContains('since=1443274283', $content['_links'][$link]['href']); | 153 | $this->assertContains('since=1443274283', $content['_links'][$link]['href']); |
116 | } | 154 | } |
117 | 155 | ||
118 | $this->assertTrue( | 156 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
119 | $this->client->getResponse()->headers->contains( | ||
120 | 'Content-Type', | ||
121 | 'application/json' | ||
122 | ) | ||
123 | ); | ||
124 | } | 157 | } |
125 | 158 | ||
126 | public function testGetStarredEntries() | 159 | public function testGetStarredEntries() |
@@ -148,12 +181,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
148 | $this->assertContains('sort=updated', $content['_links'][$link]['href']); | 181 | $this->assertContains('sort=updated', $content['_links'][$link]['href']); |
149 | } | 182 | } |
150 | 183 | ||
151 | $this->assertTrue( | 184 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
152 | $this->client->getResponse()->headers->contains( | ||
153 | 'Content-Type', | ||
154 | 'application/json' | ||
155 | ) | ||
156 | ); | ||
157 | } | 185 | } |
158 | 186 | ||
159 | public function testGetArchiveEntries() | 187 | public function testGetArchiveEntries() |
@@ -180,12 +208,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
180 | $this->assertContains('archive=1', $content['_links'][$link]['href']); | 208 | $this->assertContains('archive=1', $content['_links'][$link]['href']); |
181 | } | 209 | } |
182 | 210 | ||
183 | $this->assertTrue( | 211 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
184 | $this->client->getResponse()->headers->contains( | ||
185 | 'Content-Type', | ||
186 | 'application/json' | ||
187 | ) | ||
188 | ); | ||
189 | } | 212 | } |
190 | 213 | ||
191 | public function testGetTaggedEntries() | 214 | public function testGetTaggedEntries() |
@@ -212,12 +235,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
212 | $this->assertContains('tags='.urlencode('foo,bar'), $content['_links'][$link]['href']); | 235 | $this->assertContains('tags='.urlencode('foo,bar'), $content['_links'][$link]['href']); |
213 | } | 236 | } |
214 | 237 | ||
215 | $this->assertTrue( | 238 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
216 | $this->client->getResponse()->headers->contains( | ||
217 | 'Content-Type', | ||
218 | 'application/json' | ||
219 | ) | ||
220 | ); | ||
221 | } | 239 | } |
222 | 240 | ||
223 | public function testGetDatedEntries() | 241 | public function testGetDatedEntries() |
@@ -244,12 +262,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
244 | $this->assertContains('since=1443274283', $content['_links'][$link]['href']); | 262 | $this->assertContains('since=1443274283', $content['_links'][$link]['href']); |
245 | } | 263 | } |
246 | 264 | ||
247 | $this->assertTrue( | 265 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
248 | $this->client->getResponse()->headers->contains( | ||
249 | 'Content-Type', | ||
250 | 'application/json' | ||
251 | ) | ||
252 | ); | ||
253 | } | 266 | } |
254 | 267 | ||
255 | public function testGetDatedSupEntries() | 268 | public function testGetDatedSupEntries() |
@@ -277,12 +290,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
277 | $this->assertContains('since='.($future->getTimestamp() + 1000), $content['_links'][$link]['href']); | 290 | $this->assertContains('since='.($future->getTimestamp() + 1000), $content['_links'][$link]['href']); |
278 | } | 291 | } |
279 | 292 | ||
280 | $this->assertTrue( | 293 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
281 | $this->client->getResponse()->headers->contains( | ||
282 | 'Content-Type', | ||
283 | 'application/json' | ||
284 | ) | ||
285 | ); | ||
286 | } | 294 | } |
287 | 295 | ||
288 | public function testDeleteEntry() | 296 | public function testDeleteEntry() |