diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2017-04-24 10:22:57 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2017-05-01 09:25:34 +0200 |
commit | 1eca7831a69b9470b92dcc72e1ce51b42b291338 (patch) | |
tree | a8627c4bc1457729f92096ab4b36ece95b1a8857 /tests/Wallabag | |
parent | 3cbb0cc3ef89873a06bda6583747a2660b989fb8 (diff) | |
download | wallabag-1eca7831a69b9470b92dcc72e1ce51b42b291338.tar.gz wallabag-1eca7831a69b9470b92dcc72e1ce51b42b291338.tar.zst wallabag-1eca7831a69b9470b92dcc72e1ce51b42b291338.zip |
Added API endpoint to handle a list of URL
By passing an array, you can add / delete URL in mass (bulk request)
Diffstat (limited to 'tests/Wallabag')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 19fb5170..c37d08cb 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -766,20 +766,50 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
766 | ], | 766 | ], |
767 | ]; | 767 | ]; |
768 | 768 | ||
769 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); | 769 | $this->client->request('DELETE', '/api/entries/tags/list?list=' . json_encode($list)); |
770 | } | ||
771 | |||
772 | public function testPostMassEntriesAction() | ||
773 | { | ||
774 | $list = [ | ||
775 | [ | ||
776 | 'url' => 'http://0.0.0.0/entry2', | ||
777 | 'action' => 'delete', | ||
778 | ], | ||
779 | [ | ||
780 | 'url' => 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | ||
781 | 'action' => 'add', | ||
782 | ], | ||
783 | [ | ||
784 | 'url' => 'http://0.0.0.0/entry3', | ||
785 | 'action' => 'delete', | ||
786 | ], | ||
787 | [ | ||
788 | 'url' => 'http://0.0.0.0/entry6', | ||
789 | 'action' => 'add', | ||
790 | ], | ||
791 | ]; | ||
792 | |||
793 | $this->client->request('POST', '/api/entries/lists?list='.json_encode($list)); | ||
770 | 794 | ||
771 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 795 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
772 | 796 | ||
773 | $content = json_decode($this->client->getResponse()->getContent(), true); | 797 | $content = json_decode($this->client->getResponse()->getContent(), true); |
774 | 798 | ||
775 | $this->assertInternalType('int', $content[0]['entry']); | 799 | $this->assertTrue($content[0]['entry']); |
776 | $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); | 800 | $this->assertEquals('http://0.0.0.0/entry2', $content[0]['url']); |
801 | $this->assertEquals('delete', $content[0]['action']); | ||
777 | 802 | ||
778 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | 803 | $this->assertInternalType('int', $content[1]['entry']); |
779 | ->getRepository('WallabagCoreBundle:Entry') | 804 | $this->assertEquals('http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', $content[1]['url']); |
780 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | 805 | $this->assertEquals('add', $content[1]['action']); |
781 | 806 | ||
782 | $tags = $entry->getTags(); | 807 | $this->assertFalse($content[2]['entry']); |
783 | $this->assertCount(2, $tags); | 808 | $this->assertEquals('http://0.0.0.0/entry3', $content[2]['url']); |
809 | $this->assertEquals('delete', $content[2]['action']); | ||
810 | |||
811 | $this->assertInternalType('int', $content[3]['entry']); | ||
812 | $this->assertEquals('http://0.0.0.0/entry6', $content[3]['url']); | ||
813 | $this->assertEquals('add', $content[3]['action']); | ||
784 | } | 814 | } |
785 | } | 815 | } |