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