aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php63
1 files changed, 56 insertions, 7 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index e6ffd664..f0173cef 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -766,20 +766,69 @@ 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
773 public function testPostEntriesListAction()
774 {
775 $list = [
776 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html',
777 'http://0.0.0.0/entry2',
778 ];
779
780 $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list));
770 781
771 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 782 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
772 783
773 $content = json_decode($this->client->getResponse()->getContent(), true); 784 $content = json_decode($this->client->getResponse()->getContent(), true);
774 785
775 $this->assertInternalType('int', $content[0]['entry']); 786 $this->assertInternalType('int', $content[0]['entry']);
776 $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); 787 $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[0]['url']);
777 788
778 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 789 $this->assertInternalType('int', $content[1]['entry']);
779 ->getRepository('WallabagCoreBundle:Entry') 790 $this->assertEquals('http://0.0.0.0/entry2', $content[1]['url']);
780 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); 791 }
781 792
782 $tags = $entry->getTags(); 793 public function testDeleteEntriesListAction()
783 $this->assertCount(2, $tags); 794 {
795 $list = [
796 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html',
797 'http://0.0.0.0/entry3',
798 ];
799
800 $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list));
801
802 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
803
804 $content = json_decode($this->client->getResponse()->getContent(), true);
805
806 $this->assertTrue($content[0]['entry']);
807 $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[0]['url']);
808
809 $this->assertFalse($content[1]['entry']);
810 $this->assertEquals('http://0.0.0.0/entry3', $content[1]['url']);
811 }
812
813 public function testLimitBulkAction()
814 {
815 $list = [
816 'http://0.0.0.0/entry1',
817 'http://0.0.0.0/entry1',
818 'http://0.0.0.0/entry1',
819 'http://0.0.0.0/entry1',
820 'http://0.0.0.0/entry1',
821 'http://0.0.0.0/entry1',
822 'http://0.0.0.0/entry1',
823 'http://0.0.0.0/entry1',
824 'http://0.0.0.0/entry1',
825 'http://0.0.0.0/entry1',
826 'http://0.0.0.0/entry1',
827 ];
828
829 $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list));
830
831 $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
832 $this->assertContains('API limit reached', $this->client->getResponse()->getContent());
784 } 833 }
785} 834}