aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-04-24 12:24:17 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2017-04-24 12:24:17 +0200
commit80299ed282d4f18ef92a79f29f9346b96acde468 (patch)
treeaeac62044b1d21f649ffd2a8f6a469d0491629ee /tests/Wallabag
parentd1fc590211b8dc7360bf5b7ee01c67ccff0577ea (diff)
downloadwallabag-80299ed282d4f18ef92a79f29f9346b96acde468.tar.gz
wallabag-80299ed282d4f18ef92a79f29f9346b96acde468.tar.zst
wallabag-80299ed282d4f18ef92a79f29f9346b96acde468.zip
Added endpoint to handle URL list to add/delete tags
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php59
1 files changed, 48 insertions, 11 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 1f5c7a4f..638e8bcd 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -717,32 +717,69 @@ class EntryRestControllerTest extends WallabagApiTestCase
717 717
718 public function testPostEntriesTagsListAction() 718 public function testPostEntriesTagsListAction()
719 { 719 {
720 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
721 ->getRepository('WallabagCoreBundle:Entry')
722 ->findByUrlAndUserId('http://0.0.0.0/entry2', 1);
723
724 $tags = $entry->getTags();
725
726 $this->assertCount(4, $tags);
727
720 $list = [ 728 $list = [
721 [ 729 [
722 'url' => 'http://0.0.0.0/entry1', 730 'url' => 'http://0.0.0.0/entry2',
723 'tags' => 'foo bar, baz', 731 'tags' => 'new tag 1, new tag 2',
724 'action' => 'delete',
725 ], 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/entry2', $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/entry2', 1);
747
748 $tags = $entry->getTags();
749 $this->assertCount(6, $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/entry2', 1);
757
758 $tags = $entry->getTags();
759
760 $this->assertCount(6, $tags);
761
762 $list = [
726 [ 763 [
727 'url' => 'http://0.0.0.0/entry2', 764 'url' => 'http://0.0.0.0/entry2',
728 'tags' => 'new tag 1, new tag 2', 765 'tags' => 'new tag 1, new tag 2',
729 'action' => 'add',
730 ], 766 ],
731 ]; 767 ];
732 768
733 $this->client->request('POST', '/api/entries/tags/lists?list='.json_encode($list)); 769 $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list));
734 770
735 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 771 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
736 772
737 $content = json_decode($this->client->getResponse()->getContent(), true); 773 $content = json_decode($this->client->getResponse()->getContent(), true);
738 774
775 $this->assertInternalType('int', $content[0]['entry']);
776 $this->assertEquals('http://0.0.0.0/entry2', $content[0]['url']);
739 777
740 $this->assertFalse($content[0]['entry']); 778 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
741 $this->assertEquals('http://0.0.0.0/entry1', $content[0]['url']); 779 ->getRepository('WallabagCoreBundle:Entry')
742 $this->assertEquals('delete', $content[0]['action']); 780 ->findByUrlAndUserId('http://0.0.0.0/entry2', 1);
743 781
744 $this->assertInternalType('int', $content[1]['entry']); 782 $tags = $entry->getTags();
745 $this->assertEquals('http://0.0.0.0/entry2', $content[1]['url']); 783 $this->assertCount(4, $tags);
746 $this->assertEquals('add', $content[1]['action']);
747 } 784 }
748} 785}