aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle/Controller
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-05-01 09:04:41 +0200
committerGitHub <noreply@github.com>2017-05-01 09:04:41 +0200
commit3cbb0cc3ef89873a06bda6583747a2660b989fb8 (patch)
tree9395ac30e1555c6f473d5c612a8effc406e00bf3 /tests/Wallabag/ApiBundle/Controller
parentc5e04b0109655ebffff855670935496f49c1aebf (diff)
parentdcbebc17aaa50ea16eb0b7e379c14ebbcf0a645a (diff)
downloadwallabag-3cbb0cc3ef89873a06bda6583747a2660b989fb8.tar.gz
wallabag-3cbb0cc3ef89873a06bda6583747a2660b989fb8.tar.zst
wallabag-3cbb0cc3ef89873a06bda6583747a2660b989fb8.zip
Merge pull request #3055 from wallabag/api-bulk-add-tags
Added API endpoint to handle a list of URL and to add/delete tags
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php70
1 files changed, 69 insertions, 1 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index dc5160c7..19fb5170 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -298,7 +298,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
298 $entry = $this->client->getContainer() 298 $entry = $this->client->getContainer()
299 ->get('doctrine.orm.entity_manager') 299 ->get('doctrine.orm.entity_manager')
300 ->getRepository('WallabagCoreBundle:Entry') 300 ->getRepository('WallabagCoreBundle:Entry')
301 ->findOneByUser(1); 301 ->findOneByUser(1, ['id' => 'asc']);
302 302
303 if (!$entry) { 303 if (!$entry) {
304 $this->markTestSkipped('No content found in db.'); 304 $this->markTestSkipped('No content found in db.');
@@ -714,4 +714,72 @@ class EntryRestControllerTest extends WallabagApiTestCase
714 714
715 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 715 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
716 } 716 }
717
718 public function testPostEntriesTagsListAction()
719 {
720 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
721 ->getRepository('WallabagCoreBundle:Entry')
722 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
723
724 $tags = $entry->getTags();
725
726 $this->assertCount(2, $tags);
727
728 $list = [
729 [
730 'url' => 'http://0.0.0.0/entry4',
731 'tags' => 'new tag 1, new tag 2',
732 ],
733 ];
734
735 $this->client->request('POST', '/api/entries/tags/lists?list='.json_encode($list));
736
737 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
738
739 $content = json_decode($this->client->getResponse()->getContent(), true);
740
741 $this->assertInternalType('int', $content[0]['entry']);
742 $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']);
743
744 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
745 ->getRepository('WallabagCoreBundle:Entry')
746 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
747
748 $tags = $entry->getTags();
749 $this->assertCount(4, $tags);
750 }
751
752 public function testDeleteEntriesTagsListAction()
753 {
754 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
755 ->getRepository('WallabagCoreBundle:Entry')
756 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
757
758 $tags = $entry->getTags();
759
760 $this->assertCount(4, $tags);
761
762 $list = [
763 [
764 'url' => 'http://0.0.0.0/entry4',
765 'tags' => 'new tag 1, new tag 2',
766 ],
767 ];
768
769 $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list));
770
771 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
772
773 $content = json_decode($this->client->getResponse()->getContent(), true);
774
775 $this->assertInternalType('int', $content[0]['entry']);
776 $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']);
777
778 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
779 ->getRepository('WallabagCoreBundle:Entry')
780 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
781
782 $tags = $entry->getTags();
783 $this->assertCount(2, $tags);
784 }
717} 785}