3 namespace Tests\Wallabag\ApiBundle\Controller
;
5 use Tests\Wallabag\ApiBundle\WallabagApiTestCase
;
6 use Wallabag\CoreBundle\Entity\Tag
;
8 class EntryRestControllerTest
extends WallabagApiTestCase
10 public function testGetOneEntry()
12 $entry = $this->client
->getContainer()
13 ->get('doctrine.orm.entity_manager')
14 ->getRepository('WallabagCoreBundle:Entry')
15 ->findOneBy(['user' => 1, 'isArchived' => false]);
18 $this->markTestSkipped('No content found in db.');
21 $this->client
->request('GET', '/api/entries/'.$entry->getId().'.json');
22 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
24 $content = json_decode($this->client
->getResponse()->getContent(), true);
26 $this->assertEquals($entry->getTitle(), $content['title']);
27 $this->assertEquals($entry->getUrl(), $content['url']);
28 $this->assertCount(count($entry->getTags()), $content['tags']);
29 $this->assertEquals($entry->getUserName(), $content['user_name']);
30 $this->assertEquals($entry->getUserEmail(), $content['user_email']);
31 $this->assertEquals($entry->getUserId(), $content['user_id']);
33 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));
36 public function testExportEntry()
38 $entry = $this->client
->getContainer()
39 ->get('doctrine.orm.entity_manager')
40 ->getRepository('WallabagCoreBundle:Entry')
41 ->findOneBy(['user' => 1, 'isArchived' => false]);
44 $this->markTestSkipped('No content found in db.');
47 $this->client
->request('GET', '/api/entries/'.$entry->getId().'/export.epub');
48 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
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'));
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());
59 $this->assertEquals('application/x-mobipocket-ebook', $client->getResponse()->headers
->get('Content-Type'));
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());
66 $this->assertContains('PDF-', $client->getResponse()->getContent());
67 $this->assertEquals('application/pdf', $client->getResponse()->headers
->get('Content-Type'));
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());
74 $this->assertContains('text/plain', $client->getResponse()->headers
->get('Content-Type'));
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());
81 $this->assertContains('application/csv', $client->getResponse()->headers
->get('Content-Type'));
84 public function testGetOneEntryWrongUser()
86 $entry = $this->client
->getContainer()
87 ->get('doctrine.orm.entity_manager')
88 ->getRepository('WallabagCoreBundle:Entry')
89 ->findOneBy(['user' => 2, 'isArchived' => false]);
92 $this->markTestSkipped('No content found in db.');
95 $this->client
->request('GET', '/api/entries/'.$entry->getId().'.json');
97 $this->assertEquals(403, $this->client
->getResponse()->getStatusCode());
100 public function testGetEntries()
102 $this->client
->request('GET', '/api/entries');
104 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
106 $content = json_decode($this->client
->getResponse()->getContent(), true);
108 $this->assertGreaterThanOrEqual(1, count($content));
109 $this->assertNotEmpty($content['_embedded']['items']);
110 $this->assertGreaterThanOrEqual(1, $content['total']);
111 $this->assertEquals(1, $content['page']);
112 $this->assertGreaterThanOrEqual(1, $content['pages']);
114 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));
117 public function testGetEntriesWithFullOptions()
119 $this->client
->request('GET', '/api/entries', [
127 'since' => 1443274283,
130 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
132 $content = json_decode($this->client
->getResponse()->getContent(), true);
134 $this->assertGreaterThanOrEqual(1, count($content));
135 $this->assertArrayHasKey('items', $content['_embedded']);
136 $this->assertGreaterThanOrEqual(0, $content['total']);
137 $this->assertEquals(1, $content['page']);
138 $this->assertEquals(2, $content['limit']);
139 $this->assertGreaterThanOrEqual(1, $content['pages']);
141 $this->assertArrayHasKey('_links', $content);
142 $this->assertArrayHasKey('self', $content['_links']);
143 $this->assertArrayHasKey('first', $content['_links']);
144 $this->assertArrayHasKey('last', $content['_links']);
146 foreach (['self', 'first', 'last'] as $link) {
147 $this->assertArrayHasKey('href', $content['_links'][$link]);
148 $this->assertContains('archive=1', $content['_links'][$link]['href']);
149 $this->assertContains('starred=1', $content['_links'][$link]['href']);
150 $this->assertContains('sort=updated', $content['_links'][$link]['href']);
151 $this->assertContains('order=asc', $content['_links'][$link]['href']);
152 $this->assertContains('tags=foo', $content['_links'][$link]['href']);
153 $this->assertContains('since=1443274283', $content['_links'][$link]['href']);
156 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));
159 public function testGetStarredEntries()
161 $this->client
->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']);
163 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
165 $content = json_decode($this->client
->getResponse()->getContent(), true);
167 $this->assertGreaterThanOrEqual(1, count($content));
168 $this->assertNotEmpty($content['_embedded']['items']);
169 $this->assertGreaterThanOrEqual(1, $content['total']);
170 $this->assertEquals(1, $content['page']);
171 $this->assertGreaterThanOrEqual(1, $content['pages']);
173 $this->assertArrayHasKey('_links', $content);
174 $this->assertArrayHasKey('self', $content['_links']);
175 $this->assertArrayHasKey('first', $content['_links']);
176 $this->assertArrayHasKey('last', $content['_links']);
178 foreach (['self', 'first', 'last'] as $link) {
179 $this->assertArrayHasKey('href', $content['_links'][$link]);
180 $this->assertContains('starred=1', $content['_links'][$link]['href']);
181 $this->assertContains('sort=updated', $content['_links'][$link]['href']);
184 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));
187 public function testGetArchiveEntries()
189 $this->client
->request('GET', '/api/entries', ['archive' => 1]);
191 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
193 $content = json_decode($this->client
->getResponse()->getContent(), true);
195 $this->assertGreaterThanOrEqual(1, count($content));
196 $this->assertNotEmpty($content['_embedded']['items']);
197 $this->assertGreaterThanOrEqual(1, $content['total']);
198 $this->assertEquals(1, $content['page']);
199 $this->assertGreaterThanOrEqual(1, $content['pages']);
201 $this->assertArrayHasKey('_links', $content);
202 $this->assertArrayHasKey('self', $content['_links']);
203 $this->assertArrayHasKey('first', $content['_links']);
204 $this->assertArrayHasKey('last', $content['_links']);
206 foreach (['self', 'first', 'last'] as $link) {
207 $this->assertArrayHasKey('href', $content['_links'][$link]);
208 $this->assertContains('archive=1', $content['_links'][$link]['href']);
211 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));
214 public function testGetTaggedEntries()
216 $this->client
->request('GET', '/api/entries', ['tags' => 'foo,bar']);
218 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
220 $content = json_decode($this->client
->getResponse()->getContent(), true);
222 $this->assertGreaterThanOrEqual(1, count($content));
223 $this->assertNotEmpty($content['_embedded']['items']);
224 $this->assertGreaterThanOrEqual(1, $content['total']);
225 $this->assertEquals(1, $content['page']);
226 $this->assertGreaterThanOrEqual(1, $content['pages']);
228 $this->assertArrayHasKey('_links', $content);
229 $this->assertArrayHasKey('self', $content['_links']);
230 $this->assertArrayHasKey('first', $content['_links']);
231 $this->assertArrayHasKey('last', $content['_links']);
233 foreach (['self', 'first', 'last'] as $link) {
234 $this->assertArrayHasKey('href', $content['_links'][$link]);
235 $this->assertContains('tags='.urlencode('foo,bar'), $content['_links'][$link]['href']);
238 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));
241 public function testGetDatedEntries()
243 $this->client
->request('GET', '/api/entries', ['since' => 1443274283]);
245 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
247 $content = json_decode($this->client
->getResponse()->getContent(), true);
249 $this->assertGreaterThanOrEqual(1, count($content));
250 $this->assertNotEmpty($content['_embedded']['items']);
251 $this->assertGreaterThanOrEqual(1, $content['total']);
252 $this->assertEquals(1, $content['page']);
253 $this->assertGreaterThanOrEqual(1, $content['pages']);
255 $this->assertArrayHasKey('_links', $content);
256 $this->assertArrayHasKey('self', $content['_links']);
257 $this->assertArrayHasKey('first', $content['_links']);
258 $this->assertArrayHasKey('last', $content['_links']);
260 foreach (['self', 'first', 'last'] as $link) {
261 $this->assertArrayHasKey('href', $content['_links'][$link]);
262 $this->assertContains('since=1443274283', $content['_links'][$link]['href']);
265 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));
268 public function testGetDatedSupEntries()
270 $future = new \
DateTime(date('Y-m-d H:i:s'));
271 $this->client
->request('GET', '/api/entries', ['since' => $future->getTimestamp() +
1000]);
273 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
275 $content = json_decode($this->client
->getResponse()->getContent(), true);
277 $this->assertGreaterThanOrEqual(1, count($content));
278 $this->assertEmpty($content['_embedded']['items']);
279 $this->assertEquals(0, $content['total']);
280 $this->assertEquals(1, $content['page']);
281 $this->assertEquals(1, $content['pages']);
283 $this->assertArrayHasKey('_links', $content);
284 $this->assertArrayHasKey('self', $content['_links']);
285 $this->assertArrayHasKey('first', $content['_links']);
286 $this->assertArrayHasKey('last', $content['_links']);
288 foreach (['self', 'first', 'last'] as $link) {
289 $this->assertArrayHasKey('href', $content['_links'][$link]);
290 $this->assertContains('since='.($future->getTimestamp() +
1000), $content['_links'][$link]['href']);
293 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));
296 public function testDeleteEntry()
298 $entry = $this->client
->getContainer()
299 ->get('doctrine.orm.entity_manager')
300 ->getRepository('WallabagCoreBundle:Entry')
304 $this->markTestSkipped('No content found in db.');
307 $this->client
->request('DELETE', '/api/entries/'.$entry->getId().'.json');
309 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
311 $content = json_decode($this->client
->getResponse()->getContent(), true);
313 $this->assertEquals($entry->getTitle(), $content['title']);
314 $this->assertEquals($entry->getUrl(), $content['url']);
316 // We'll try to delete this entry again
317 $this->client
->request('DELETE', '/api/entries/'.$entry->getId().'.json');
319 $this->assertEquals(404, $this->client
->getResponse()->getStatusCode());
322 public function testPostEntry()
324 $this->client
->request('POST', '/api/entries.json', [
325 'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
327 'title' => 'New title for my article',
330 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
332 $content = json_decode($this->client
->getResponse()->getContent(), true);
334 $this->assertGreaterThan(0, $content['id']);
335 $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
336 $this->assertEquals(false, $content['is_archived']);
337 $this->assertEquals(false, $content['is_starred']);
338 $this->assertEquals('New title for my article', $content['title']);
339 $this->assertEquals(1, $content['user_id']);
340 $this->assertCount(1, $content['tags']);
343 public function testPostSameEntry()
345 $this->client
->request('POST', '/api/entries.json', [
346 'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
348 'tags' => 'google, apple',
351 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
353 $content = json_decode($this->client
->getResponse()->getContent(), true);
355 $this->assertGreaterThan(0, $content['id']);
356 $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
357 $this->assertEquals(true, $content['is_archived']);
358 $this->assertEquals(false, $content['is_starred']);
359 $this->assertCount(2, $content['tags']);
362 public function testPostArchivedAndStarredEntry()
364 $this->client
->request('POST', '/api/entries.json', [
365 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
370 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
372 $content = json_decode($this->client
->getResponse()->getContent(), true);
374 $this->assertGreaterThan(0, $content['id']);
375 $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
376 $this->assertEquals(true, $content['is_archived']);
377 $this->assertEquals(true, $content['is_starred']);
378 $this->assertEquals(1, $content['user_id']);
381 public function testPostArchivedAndStarredEntryWithoutQuotes()
383 $this->client
->request('POST', '/api/entries.json', [
384 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
389 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
391 $content = json_decode($this->client
->getResponse()->getContent(), true);
393 $this->assertGreaterThan(0, $content['id']);
394 $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
395 $this->assertEquals(false, $content['is_archived']);
396 $this->assertEquals(true, $content['is_starred']);
399 public function testPatchEntry()
401 $entry = $this->client
->getContainer()
402 ->get('doctrine.orm.entity_manager')
403 ->getRepository('WallabagCoreBundle:Entry')
407 $this->markTestSkipped('No content found in db.');
410 // hydrate the tags relations
411 $nbTags = count($entry->getTags());
413 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
414 'title' => 'New awesome title',
415 'tags' => 'new tag '.uniqid(),
420 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
422 $content = json_decode($this->client
->getResponse()->getContent(), true);
424 $this->assertEquals($entry->getId(), $content['id']);
425 $this->assertEquals($entry->getUrl(), $content['url']);
426 $this->assertEquals('New awesome title', $content['title']);
427 $this->assertGreaterThan($nbTags, count($content['tags']));
428 $this->assertEquals(1, $content['user_id']);
431 public function testPatchEntryWithoutQuotes()
433 $entry = $this->client
->getContainer()
434 ->get('doctrine.orm.entity_manager')
435 ->getRepository('WallabagCoreBundle:Entry')
439 $this->markTestSkipped('No content found in db.');
442 // hydrate the tags relations
443 $nbTags = count($entry->getTags());
445 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
446 'title' => 'New awesome title',
447 'tags' => 'new tag '.uniqid(),
452 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
454 $content = json_decode($this->client
->getResponse()->getContent(), true);
456 $this->assertEquals($entry->getId(), $content['id']);
457 $this->assertEquals($entry->getUrl(), $content['url']);
458 $this->assertEquals('New awesome title', $content['title']);
459 $this->assertGreaterThan($nbTags, count($content['tags']));
462 public function testGetTagsEntry()
464 $entry = $this->client
->getContainer()
465 ->get('doctrine.orm.entity_manager')
466 ->getRepository('WallabagCoreBundle:Entry')
467 ->findOneWithTags($this->user
->getId());
472 $this->markTestSkipped('No content found in db.');
476 foreach ($entry->getTags() as $tag) {
477 $tags[] = ['id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug()];
480 $this->client
->request('GET', '/api/entries/'.$entry->getId().'/tags');
482 $this->assertEquals(json_encode($tags, JSON_HEX_QUOT
), $this->client
->getResponse()->getContent());
485 public function testPostTagsOnEntry()
487 $entry = $this->client
->getContainer()
488 ->get('doctrine.orm.entity_manager')
489 ->getRepository('WallabagCoreBundle:Entry')
493 $this->markTestSkipped('No content found in db.');
496 $nbTags = count($entry->getTags());
498 $newTags = 'tag1,tag2,tag3';
500 $this->client
->request('POST', '/api/entries/'.$entry->getId().'/tags', ['tags' => $newTags]);
502 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
504 $content = json_decode($this->client
->getResponse()->getContent(), true);
506 $this->assertArrayHasKey('tags', $content);
507 $this->assertEquals($nbTags +
3, count($content['tags']));
509 $entryDB = $this->client
->getContainer()
510 ->get('doctrine.orm.entity_manager')
511 ->getRepository('WallabagCoreBundle:Entry')
512 ->find($entry->getId());
515 foreach ($entryDB->getTags()->toArray() as $tag) {
516 $tagsInDB[$tag->getId()] = $tag->getLabel();
519 foreach (explode(',', $newTags) as $tag) {
520 $this->assertContains($tag, $tagsInDB);
524 public function testDeleteOneTagEntry()
526 $entry = $this->client
->getContainer()
527 ->get('doctrine.orm.entity_manager')
528 ->getRepository('WallabagCoreBundle:Entry')
529 ->findOneWithTags($this->user
->getId());
533 $this->markTestSkipped('No content found in db.');
536 // hydrate the tags relations
537 $nbTags = count($entry->getTags());
538 $tag = $entry->getTags()[0];
540 $this->client
->request('DELETE', '/api/entries/'.$entry->getId().'/tags/'.$tag->getId().'.json');
542 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
544 $content = json_decode($this->client
->getResponse()->getContent(), true);
546 $this->assertArrayHasKey('tags', $content);
547 $this->assertEquals($nbTags - 1, count($content['tags']));
550 public function testSaveIsArchivedAfterPost()
552 $entry = $this->client
->getContainer()
553 ->get('doctrine.orm.entity_manager')
554 ->getRepository('WallabagCoreBundle:Entry')
555 ->findOneBy(['user' => 1, 'isArchived' => true]);
558 $this->markTestSkipped('No content found in db.');
561 $this->client
->request('POST', '/api/entries.json', [
562 'url' => $entry->getUrl(),
565 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
567 $content = json_decode($this->client
->getResponse()->getContent(), true);
569 $this->assertEquals(true, $content['is_archived']);
572 public function testSaveIsStarredAfterPost()
574 $entry = $this->client
->getContainer()
575 ->get('doctrine.orm.entity_manager')
576 ->getRepository('WallabagCoreBundle:Entry')
577 ->findOneBy(['user' => 1, 'isStarred' => true]);
580 $this->markTestSkipped('No content found in db.');
583 $this->client
->request('POST', '/api/entries.json', [
584 'url' => $entry->getUrl(),
587 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
589 $content = json_decode($this->client
->getResponse()->getContent(), true);
591 $this->assertEquals(true, $content['is_starred']);
594 public function testSaveIsArchivedAfterPatch()
596 $entry = $this->client
->getContainer()
597 ->get('doctrine.orm.entity_manager')
598 ->getRepository('WallabagCoreBundle:Entry')
599 ->findOneBy(['user' => 1, 'isArchived' => true]);
602 $this->markTestSkipped('No content found in db.');
605 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
606 'title' => $entry->getTitle().'++',
609 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
611 $content = json_decode($this->client
->getResponse()->getContent(), true);
613 $this->assertEquals(true, $content['is_archived']);
616 public function testSaveIsStarredAfterPatch()
618 $entry = $this->client
->getContainer()
619 ->get('doctrine.orm.entity_manager')
620 ->getRepository('WallabagCoreBundle:Entry')
621 ->findOneBy(['user' => 1, 'isStarred' => true]);
624 $this->markTestSkipped('No content found in db.');
626 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
627 'title' => $entry->getTitle().'++',
630 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
632 $content = json_decode($this->client
->getResponse()->getContent(), true);
634 $this->assertEquals(true, $content['is_starred']);
637 public function testGetEntriesExists()
639 $this->client
->request('GET', '/api/entries/exists?url=http://0.0.0.0/entry2');
641 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
643 $content = json_decode($this->client
->getResponse()->getContent(), true);
645 $this->assertEquals(2, $content['exists']);
648 public function testGetEntriesExistsWithManyUrls()
650 $url1 = 'http://0.0.0.0/entry2';
651 $url2 = 'http://0.0.0.0/entry10';
652 $this->client
->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2);
654 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
656 $content = json_decode($this->client
->getResponse()->getContent(), true);
658 $this->assertArrayHasKey($url1, $content);
659 $this->assertArrayHasKey($url2, $content);
660 $this->assertEquals(2, $content[$url1]);
661 $this->assertEquals(false, $content[$url2]);
664 public function testGetEntriesExistsWhichDoesNotExists()
666 $this->client
->request('GET', '/api/entries/exists?url=http://google.com/entry2');
668 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
670 $content = json_decode($this->client
->getResponse()->getContent(), true);
672 $this->assertEquals(false, $content['exists']);
675 public function testGetEntriesExistsWithNoUrl()
677 $this->client
->request('GET', '/api/entries/exists?url=');
679 $this->assertEquals(403, $this->client
->getResponse()->getStatusCode());
682 public function testReloadEntryErrorWhileFetching()
684 $entry = $this->client
->getContainer()->get('doctrine.orm.entity_manager')
685 ->getRepository('WallabagCoreBundle:Entry')
686 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
689 $this->markTestSkipped('No content found in db.');
692 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json');
693 $this->assertEquals(304, $this->client
->getResponse()->getStatusCode());
696 public function testReloadEntry()
698 $this->client
->request('POST', '/api/entries.json', [
699 'url' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
701 'tags' => 'google, apple',
704 $json = json_decode($this->client
->getResponse()->getContent(), true);
708 $this->client
->request('PATCH', '/api/entries/'.$json['id'].'/reload.json');
709 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
711 $content = json_decode($this->client
->getResponse()->getContent(), true);
713 $this->assertNotEmpty($content['title']);
715 $this->assertEquals('application/json', $this->client
->getResponse()->headers
->get('Content-Type'));