3 namespace Tests\Wallabag\ApiBundle\Controller
;
5 use Tests\Wallabag\ApiBundle\WallabagApiTestCase
;
6 use Wallabag\CoreBundle\Entity\Tag
;
8 class WallabagRestControllerTest
extends WallabagApiTestCase
10 protected static $salt;
12 public function testGetOneEntry()
14 $entry = $this->client
->getContainer()
15 ->get('doctrine.orm.entity_manager')
16 ->getRepository('WallabagCoreBundle:Entry')
17 ->findOneBy(['user' => 1, 'isArchived' => false]);
20 $this->markTestSkipped('No content found in db.');
23 $this->client
->request('GET', '/api/entries/'.$entry->getId().'.json');
24 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
26 $content = json_decode($this->client
->getResponse()->getContent(), true);
28 $this->assertEquals($entry->getTitle(), $content['title']);
29 $this->assertEquals($entry->getUrl(), $content['url']);
30 $this->assertCount(count($entry->getTags()), $content['tags']);
31 $this->assertEquals($entry->getUserName(), $content['user_name']);
32 $this->assertEquals($entry->getUserEmail(), $content['user_email']);
33 $this->assertEquals($entry->getUserId(), $content['user_id']);
36 $this->client
->getResponse()->headers
->contains(
43 public function testGetOneEntryWrongUser()
45 $entry = $this->client
->getContainer()
46 ->get('doctrine.orm.entity_manager')
47 ->getRepository('WallabagCoreBundle:Entry')
48 ->findOneBy(['user' => 2, 'isArchived' => false]);
51 $this->markTestSkipped('No content found in db.');
54 $this->client
->request('GET', '/api/entries/'.$entry->getId().'.json');
56 $this->assertEquals(403, $this->client
->getResponse()->getStatusCode());
59 public function testGetEntries()
61 $this->client
->request('GET', '/api/entries');
63 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
65 $content = json_decode($this->client
->getResponse()->getContent(), true);
67 $this->assertGreaterThanOrEqual(1, count($content));
68 $this->assertNotEmpty($content['_embedded']['items']);
69 $this->assertGreaterThanOrEqual(1, $content['total']);
70 $this->assertEquals(1, $content['page']);
71 $this->assertGreaterThanOrEqual(1, $content['pages']);
74 $this->client
->getResponse()->headers
->contains(
81 public function testGetEntriesWithFullOptions()
83 $this->client
->request('GET', '/api/entries', [
91 'since' => 1443274283,
94 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
96 $content = json_decode($this->client
->getResponse()->getContent(), true);
98 $this->assertGreaterThanOrEqual(1, count($content));
99 $this->assertArrayHasKey('items', $content['_embedded']);
100 $this->assertGreaterThanOrEqual(0, $content['total']);
101 $this->assertEquals(1, $content['page']);
102 $this->assertEquals(2, $content['limit']);
103 $this->assertGreaterThanOrEqual(1, $content['pages']);
105 $this->assertArrayHasKey('_links', $content);
106 $this->assertArrayHasKey('self', $content['_links']);
107 $this->assertArrayHasKey('first', $content['_links']);
108 $this->assertArrayHasKey('last', $content['_links']);
110 foreach (['self', 'first', 'last'] as $link) {
111 $this->assertArrayHasKey('href', $content['_links'][$link]);
112 $this->assertContains('archive=1', $content['_links'][$link]['href']);
113 $this->assertContains('starred=1', $content['_links'][$link]['href']);
114 $this->assertContains('sort=updated', $content['_links'][$link]['href']);
115 $this->assertContains('order=asc', $content['_links'][$link]['href']);
116 $this->assertContains('tags=foo', $content['_links'][$link]['href']);
117 $this->assertContains('since=1443274283', $content['_links'][$link]['href']);
121 $this->client
->getResponse()->headers
->contains(
128 public function testGetStarredEntries()
130 $this->client
->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']);
132 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
134 $content = json_decode($this->client
->getResponse()->getContent(), true);
136 $this->assertGreaterThanOrEqual(1, count($content));
137 $this->assertNotEmpty($content['_embedded']['items']);
138 $this->assertGreaterThanOrEqual(1, $content['total']);
139 $this->assertEquals(1, $content['page']);
140 $this->assertGreaterThanOrEqual(1, $content['pages']);
142 $this->assertArrayHasKey('_links', $content);
143 $this->assertArrayHasKey('self', $content['_links']);
144 $this->assertArrayHasKey('first', $content['_links']);
145 $this->assertArrayHasKey('last', $content['_links']);
147 foreach (['self', 'first', 'last'] as $link) {
148 $this->assertArrayHasKey('href', $content['_links'][$link]);
149 $this->assertContains('starred=1', $content['_links'][$link]['href']);
150 $this->assertContains('sort=updated', $content['_links'][$link]['href']);
154 $this->client
->getResponse()->headers
->contains(
161 public function testGetArchiveEntries()
163 $this->client
->request('GET', '/api/entries', ['archive' => 1]);
165 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
167 $content = json_decode($this->client
->getResponse()->getContent(), true);
169 $this->assertGreaterThanOrEqual(1, count($content));
170 $this->assertNotEmpty($content['_embedded']['items']);
171 $this->assertGreaterThanOrEqual(1, $content['total']);
172 $this->assertEquals(1, $content['page']);
173 $this->assertGreaterThanOrEqual(1, $content['pages']);
175 $this->assertArrayHasKey('_links', $content);
176 $this->assertArrayHasKey('self', $content['_links']);
177 $this->assertArrayHasKey('first', $content['_links']);
178 $this->assertArrayHasKey('last', $content['_links']);
180 foreach (['self', 'first', 'last'] as $link) {
181 $this->assertArrayHasKey('href', $content['_links'][$link]);
182 $this->assertContains('archive=1', $content['_links'][$link]['href']);
186 $this->client
->getResponse()->headers
->contains(
193 public function testGetTaggedEntries()
195 $this->client
->request('GET', '/api/entries', ['tags' => 'foo,bar']);
197 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
199 $content = json_decode($this->client
->getResponse()->getContent(), true);
201 $this->assertGreaterThanOrEqual(1, count($content));
202 $this->assertNotEmpty($content['_embedded']['items']);
203 $this->assertGreaterThanOrEqual(1, $content['total']);
204 $this->assertEquals(1, $content['page']);
205 $this->assertGreaterThanOrEqual(1, $content['pages']);
207 $this->assertArrayHasKey('_links', $content);
208 $this->assertArrayHasKey('self', $content['_links']);
209 $this->assertArrayHasKey('first', $content['_links']);
210 $this->assertArrayHasKey('last', $content['_links']);
212 foreach (['self', 'first', 'last'] as $link) {
213 $this->assertArrayHasKey('href', $content['_links'][$link]);
214 $this->assertContains('tags='.urlencode('foo,bar'), $content['_links'][$link]['href']);
218 $this->client
->getResponse()->headers
->contains(
225 public function testGetDatedEntries()
227 $this->client
->request('GET', '/api/entries', ['since' => 1443274283]);
229 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
231 $content = json_decode($this->client
->getResponse()->getContent(), true);
233 $this->assertGreaterThanOrEqual(1, count($content));
234 $this->assertNotEmpty($content['_embedded']['items']);
235 $this->assertGreaterThanOrEqual(1, $content['total']);
236 $this->assertEquals(1, $content['page']);
237 $this->assertGreaterThanOrEqual(1, $content['pages']);
239 $this->assertArrayHasKey('_links', $content);
240 $this->assertArrayHasKey('self', $content['_links']);
241 $this->assertArrayHasKey('first', $content['_links']);
242 $this->assertArrayHasKey('last', $content['_links']);
244 foreach (['self', 'first', 'last'] as $link) {
245 $this->assertArrayHasKey('href', $content['_links'][$link]);
246 $this->assertContains('since=1443274283', $content['_links'][$link]['href']);
250 $this->client
->getResponse()->headers
->contains(
257 public function testGetDatedSupEntries()
259 $future = new \
DateTime(date('Y-m-d H:i:s'));
260 $this->client
->request('GET', '/api/entries', ['since' => $future->getTimestamp() +
1000]);
262 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
264 $content = json_decode($this->client
->getResponse()->getContent(), true);
266 $this->assertGreaterThanOrEqual(1, count($content));
267 $this->assertEmpty($content['_embedded']['items']);
268 $this->assertEquals(0, $content['total']);
269 $this->assertEquals(1, $content['page']);
270 $this->assertEquals(1, $content['pages']);
272 $this->assertArrayHasKey('_links', $content);
273 $this->assertArrayHasKey('self', $content['_links']);
274 $this->assertArrayHasKey('first', $content['_links']);
275 $this->assertArrayHasKey('last', $content['_links']);
277 foreach (['self', 'first', 'last'] as $link) {
278 $this->assertArrayHasKey('href', $content['_links'][$link]);
279 $this->assertContains('since='.($future->getTimestamp() +
1000), $content['_links'][$link]['href']);
283 $this->client
->getResponse()->headers
->contains(
290 public function testDeleteEntry()
292 $entry = $this->client
->getContainer()
293 ->get('doctrine.orm.entity_manager')
294 ->getRepository('WallabagCoreBundle:Entry')
298 $this->markTestSkipped('No content found in db.');
301 $this->client
->request('DELETE', '/api/entries/'.$entry->getId().'.json');
303 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
305 $content = json_decode($this->client
->getResponse()->getContent(), true);
307 $this->assertEquals($entry->getTitle(), $content['title']);
308 $this->assertEquals($entry->getUrl(), $content['url']);
310 // We'll try to delete this entry again
311 $this->client
->request('DELETE', '/api/entries/'.$entry->getId().'.json');
313 $this->assertEquals(404, $this->client
->getResponse()->getStatusCode());
316 public function testPostEntry()
318 $this->client
->request('POST', '/api/entries.json', [
319 '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',
321 'title' => 'New title for my article',
324 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
326 $content = json_decode($this->client
->getResponse()->getContent(), true);
328 $this->assertGreaterThan(0, $content['id']);
329 $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']);
330 $this->assertEquals(false, $content['is_archived']);
331 $this->assertEquals(false, $content['is_starred']);
332 $this->assertEquals('New title for my article', $content['title']);
333 $this->assertEquals(1, $content['user_id']);
334 $this->assertCount(1, $content['tags']);
337 public function testPostSameEntry()
339 $this->client
->request('POST', '/api/entries.json', [
340 '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',
342 'tags' => 'google, apple',
345 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
347 $content = json_decode($this->client
->getResponse()->getContent(), true);
349 $this->assertGreaterThan(0, $content['id']);
350 $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']);
351 $this->assertEquals(true, $content['is_archived']);
352 $this->assertEquals(false, $content['is_starred']);
353 $this->assertCount(2, $content['tags']);
356 public function testPostArchivedAndStarredEntry()
358 $this->client
->request('POST', '/api/entries.json', [
359 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
364 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
366 $content = json_decode($this->client
->getResponse()->getContent(), true);
368 $this->assertGreaterThan(0, $content['id']);
369 $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']);
370 $this->assertEquals(true, $content['is_archived']);
371 $this->assertEquals(true, $content['is_starred']);
372 $this->assertEquals(1, $content['user_id']);
375 public function testPostArchivedAndStarredEntryWithoutQuotes()
377 $this->client
->request('POST', '/api/entries.json', [
378 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html',
383 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
385 $content = json_decode($this->client
->getResponse()->getContent(), true);
387 $this->assertGreaterThan(0, $content['id']);
388 $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']);
389 $this->assertEquals(false, $content['is_archived']);
390 $this->assertEquals(true, $content['is_starred']);
393 public function testPatchEntry()
395 $entry = $this->client
->getContainer()
396 ->get('doctrine.orm.entity_manager')
397 ->getRepository('WallabagCoreBundle:Entry')
401 $this->markTestSkipped('No content found in db.');
404 // hydrate the tags relations
405 $nbTags = count($entry->getTags());
407 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
408 'title' => 'New awesome title',
409 'tags' => 'new tag '.uniqid(),
414 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
416 $content = json_decode($this->client
->getResponse()->getContent(), true);
418 $this->assertEquals($entry->getId(), $content['id']);
419 $this->assertEquals($entry->getUrl(), $content['url']);
420 $this->assertEquals('New awesome title', $content['title']);
421 $this->assertGreaterThan($nbTags, count($content['tags']));
422 $this->assertEquals(1, $content['user_id']);
425 public function testPatchEntryWithoutQuotes()
427 $entry = $this->client
->getContainer()
428 ->get('doctrine.orm.entity_manager')
429 ->getRepository('WallabagCoreBundle:Entry')
433 $this->markTestSkipped('No content found in db.');
436 // hydrate the tags relations
437 $nbTags = count($entry->getTags());
439 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
440 'title' => 'New awesome title',
441 'tags' => 'new tag '.uniqid(),
446 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
448 $content = json_decode($this->client
->getResponse()->getContent(), true);
450 $this->assertEquals($entry->getId(), $content['id']);
451 $this->assertEquals($entry->getUrl(), $content['url']);
452 $this->assertEquals('New awesome title', $content['title']);
453 $this->assertGreaterThan($nbTags, count($content['tags']));
456 public function testGetTagsEntry()
458 $entry = $this->client
->getContainer()
459 ->get('doctrine.orm.entity_manager')
460 ->getRepository('WallabagCoreBundle:Entry')
461 ->findOneWithTags($this->user
->getId());
466 $this->markTestSkipped('No content found in db.');
470 foreach ($entry->getTags() as $tag) {
471 $tags[] = ['id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug()];
474 $this->client
->request('GET', '/api/entries/'.$entry->getId().'/tags');
476 $this->assertEquals(json_encode($tags, JSON_HEX_QUOT
), $this->client
->getResponse()->getContent());
479 public function testPostTagsOnEntry()
481 $entry = $this->client
->getContainer()
482 ->get('doctrine.orm.entity_manager')
483 ->getRepository('WallabagCoreBundle:Entry')
487 $this->markTestSkipped('No content found in db.');
490 $nbTags = count($entry->getTags());
492 $newTags = 'tag1,tag2,tag3';
494 $this->client
->request('POST', '/api/entries/'.$entry->getId().'/tags', ['tags' => $newTags]);
496 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
498 $content = json_decode($this->client
->getResponse()->getContent(), true);
500 $this->assertArrayHasKey('tags', $content);
501 $this->assertEquals($nbTags +
3, count($content['tags']));
503 $entryDB = $this->client
->getContainer()
504 ->get('doctrine.orm.entity_manager')
505 ->getRepository('WallabagCoreBundle:Entry')
506 ->find($entry->getId());
509 foreach ($entryDB->getTags()->toArray() as $tag) {
510 $tagsInDB[$tag->getId()] = $tag->getLabel();
513 foreach (explode(',', $newTags) as $tag) {
514 $this->assertContains($tag, $tagsInDB);
518 public function testDeleteOneTagEntry()
520 $entry = $this->client
->getContainer()
521 ->get('doctrine.orm.entity_manager')
522 ->getRepository('WallabagCoreBundle:Entry')
523 ->findOneWithTags($this->user
->getId());
527 $this->markTestSkipped('No content found in db.');
530 // hydrate the tags relations
531 $nbTags = count($entry->getTags());
532 $tag = $entry->getTags()[0];
534 $this->client
->request('DELETE', '/api/entries/'.$entry->getId().'/tags/'.$tag->getId().'.json');
536 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
538 $content = json_decode($this->client
->getResponse()->getContent(), true);
540 $this->assertArrayHasKey('tags', $content);
541 $this->assertEquals($nbTags - 1, count($content['tags']));
544 public function testGetUserTags()
546 $this->client
->request('GET', '/api/tags.json');
548 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
550 $content = json_decode($this->client
->getResponse()->getContent(), true);
552 $this->assertGreaterThan(0, $content);
553 $this->assertArrayHasKey('id', $content[0]);
554 $this->assertArrayHasKey('label', $content[0]);
556 return end($content);
560 * @depends testGetUserTags
562 public function testDeleteUserTag($tag)
564 $tagName = $tag['label'];
566 $this->client
->request('DELETE', '/api/tags/'.$tag['id'].'.json');
568 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
570 $content = json_decode($this->client
->getResponse()->getContent(), true);
572 $this->assertArrayHasKey('label', $content);
573 $this->assertEquals($tag['label'], $content['label']);
574 $this->assertEquals($tag['slug'], $content['slug']);
576 $entries = $this->client
->getContainer()
577 ->get('doctrine.orm.entity_manager')
578 ->getRepository('WallabagCoreBundle:Entry')
579 ->findAllByTagId($this->user
->getId(), $tag['id']);
581 $this->assertCount(0, $entries);
583 $tag = $this->client
->getContainer()
584 ->get('doctrine.orm.entity_manager')
585 ->getRepository('WallabagCoreBundle:Tag')
586 ->findOneByLabel($tagName);
588 $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag');
591 public function testDeleteTagByLabel()
593 $em = $this->client
->getContainer()->get('doctrine.orm.entity_manager');
594 $entry = $this->client
->getContainer()
595 ->get('doctrine.orm.entity_manager')
596 ->getRepository('WallabagCoreBundle:Entry')
597 ->findOneWithTags($this->user
->getId());
602 $tag->setLabel('Awesome tag for test');
605 $entry->addTag($tag);
607 $em->persist($entry);
610 $this->client
->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]);
612 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
614 $content = json_decode($this->client
->getResponse()->getContent(), true);
616 $this->assertArrayHasKey('label', $content);
617 $this->assertEquals($tag->getLabel(), $content['label']);
618 $this->assertEquals($tag->getSlug(), $content['slug']);
620 $entries = $this->client
->getContainer()
621 ->get('doctrine.orm.entity_manager')
622 ->getRepository('WallabagCoreBundle:Entry')
623 ->findAllByTagId($this->user
->getId(), $tag->getId());
625 $this->assertCount(0, $entries);
628 public function testDeleteTagByLabelNotFound()
630 $this->client
->request('DELETE', '/api/tag/label.json', ['tag' => 'does not exist']);
632 $this->assertEquals(404, $this->client
->getResponse()->getStatusCode());
635 public function testDeleteTagsByLabel()
637 $em = $this->client
->getContainer()->get('doctrine.orm.entity_manager');
638 $entry = $this->client
->getContainer()
639 ->get('doctrine.orm.entity_manager')
640 ->getRepository('WallabagCoreBundle:Entry')
641 ->findOneWithTags($this->user
->getId());
646 $tag->setLabel('Awesome tag for tagsLabel');
650 $tag2->setLabel('Awesome tag for tagsLabel 2');
653 $entry->addTag($tag);
654 $entry->addTag($tag2);
656 $em->persist($entry);
659 $this->client
->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]);
661 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
663 $content = json_decode($this->client
->getResponse()->getContent(), true);
665 $this->assertCount(2, $content);
667 $this->assertArrayHasKey('label', $content[0]);
668 $this->assertEquals($tag->getLabel(), $content[0]['label']);
669 $this->assertEquals($tag->getSlug(), $content[0]['slug']);
671 $this->assertArrayHasKey('label', $content[1]);
672 $this->assertEquals($tag2->getLabel(), $content[1]['label']);
673 $this->assertEquals($tag2->getSlug(), $content[1]['slug']);
675 $entries = $this->client
->getContainer()
676 ->get('doctrine.orm.entity_manager')
677 ->getRepository('WallabagCoreBundle:Entry')
678 ->findAllByTagId($this->user
->getId(), $tag->getId());
680 $this->assertCount(0, $entries);
682 $entries = $this->client
->getContainer()
683 ->get('doctrine.orm.entity_manager')
684 ->getRepository('WallabagCoreBundle:Entry')
685 ->findAllByTagId($this->user
->getId(), $tag2->getId());
687 $this->assertCount(0, $entries);
690 public function testDeleteTagsByLabelNotFound()
692 $this->client
->request('DELETE', '/api/tags/label.json', ['tags' => 'does not exist']);
694 $this->assertEquals(404, $this->client
->getResponse()->getStatusCode());
697 public function testGetVersion()
699 $this->client
->request('GET', '/api/version');
701 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
703 $content = json_decode($this->client
->getResponse()->getContent(), true);
705 $this->assertEquals($this->client
->getContainer()->getParameter('wallabag_core.version'), $content);
708 public function testSaveIsArchivedAfterPost()
710 $entry = $this->client
->getContainer()
711 ->get('doctrine.orm.entity_manager')
712 ->getRepository('WallabagCoreBundle:Entry')
713 ->findOneBy(['user' => 1, 'isArchived' => true]);
716 $this->markTestSkipped('No content found in db.');
719 $this->client
->request('POST', '/api/entries.json', [
720 'url' => $entry->getUrl(),
723 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
725 $content = json_decode($this->client
->getResponse()->getContent(), true);
727 $this->assertEquals(true, $content['is_archived']);
730 public function testSaveIsStarredAfterPost()
732 $entry = $this->client
->getContainer()
733 ->get('doctrine.orm.entity_manager')
734 ->getRepository('WallabagCoreBundle:Entry')
735 ->findOneBy(['user' => 1, 'isStarred' => true]);
738 $this->markTestSkipped('No content found in db.');
741 $this->client
->request('POST', '/api/entries.json', [
742 'url' => $entry->getUrl(),
745 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
747 $content = json_decode($this->client
->getResponse()->getContent(), true);
749 $this->assertEquals(true, $content['is_starred']);
752 public function testSaveIsArchivedAfterPatch()
754 $entry = $this->client
->getContainer()
755 ->get('doctrine.orm.entity_manager')
756 ->getRepository('WallabagCoreBundle:Entry')
757 ->findOneBy(['user' => 1, 'isArchived' => true]);
760 $this->markTestSkipped('No content found in db.');
763 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
764 'title' => $entry->getTitle().'++',
767 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
769 $content = json_decode($this->client
->getResponse()->getContent(), true);
771 $this->assertEquals(true, $content['is_archived']);
774 public function testSaveIsStarredAfterPatch()
776 $entry = $this->client
->getContainer()
777 ->get('doctrine.orm.entity_manager')
778 ->getRepository('WallabagCoreBundle:Entry')
779 ->findOneBy(['user' => 1, 'isStarred' => true]);
782 $this->markTestSkipped('No content found in db.');
784 $this->client
->request('PATCH', '/api/entries/'.$entry->getId().'.json', [
785 'title' => $entry->getTitle().'++',
788 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
790 $content = json_decode($this->client
->getResponse()->getContent(), true);
792 $this->assertEquals(true, $content['is_starred']);
795 public function testGetEntriesExists()
797 $this->client
->request('GET', '/api/entries/exists?url=http://0.0.0.0/entry2');
799 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
801 $content = json_decode($this->client
->getResponse()->getContent(), true);
803 $this->assertEquals(true, $content['exists']);
806 public function testGetEntriesExistsWhichDoesNotExists()
808 $this->client
->request('GET', '/api/entries/exists?url=http://google.com/entry2');
810 $this->assertEquals(200, $this->client
->getResponse()->getStatusCode());
812 $content = json_decode($this->client
->getResponse()->getContent(), true);
814 $this->assertEquals(false, $content['exists']);
817 public function testGetEntriesExistsWithNoUrl()
819 $this->client
->request('GET', '/api/entries/exists?url=');
821 $this->assertEquals(403, $this->client
->getResponse()->getStatusCode());