diff options
Diffstat (limited to 'tests/Wallabag/ApiBundle')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 67 |
1 files changed, 58 insertions, 9 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 19fb5170..f0173cef 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -337,7 +337,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
337 | $this->assertEquals(false, $content['is_starred']); | 337 | $this->assertEquals(false, $content['is_starred']); |
338 | $this->assertEquals('New title for my article', $content['title']); | 338 | $this->assertEquals('New title for my article', $content['title']); |
339 | $this->assertEquals(1, $content['user_id']); | 339 | $this->assertEquals(1, $content['user_id']); |
340 | $this->assertCount(1, $content['tags']); | 340 | $this->assertCount(2, $content['tags']); |
341 | } | 341 | } |
342 | 342 | ||
343 | public function testPostSameEntry() | 343 | public function testPostSameEntry() |
@@ -356,7 +356,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
356 | $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); | 356 | $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); |
357 | $this->assertEquals(true, $content['is_archived']); | 357 | $this->assertEquals(true, $content['is_archived']); |
358 | $this->assertEquals(false, $content['is_starred']); | 358 | $this->assertEquals(false, $content['is_starred']); |
359 | $this->assertCount(2, $content['tags']); | 359 | $this->assertCount(3, $content['tags']); |
360 | } | 360 | } |
361 | 361 | ||
362 | public function testPostArchivedAndStarredEntry() | 362 | public function testPostArchivedAndStarredEntry() |
@@ -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 | } |