diff options
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 76 |
1 files changed, 70 insertions, 6 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index e6ffd664..4f49f040 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -156,6 +156,22 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
156 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); | 156 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
157 | } | 157 | } |
158 | 158 | ||
159 | public function testGetEntriesOnPageTwo() | ||
160 | { | ||
161 | $this->client->request('GET', '/api/entries', [ | ||
162 | 'page' => 2, | ||
163 | 'perPage' => 2, | ||
164 | ]); | ||
165 | |||
166 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
167 | |||
168 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
169 | |||
170 | $this->assertGreaterThanOrEqual(0, $content['total']); | ||
171 | $this->assertEquals(2, $content['page']); | ||
172 | $this->assertEquals(2, $content['limit']); | ||
173 | } | ||
174 | |||
159 | public function testGetStarredEntries() | 175 | public function testGetStarredEntries() |
160 | { | 176 | { |
161 | $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); | 177 | $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); |
@@ -767,19 +783,67 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
767 | ]; | 783 | ]; |
768 | 784 | ||
769 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); | 785 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); |
786 | } | ||
787 | |||
788 | public function testPostEntriesListAction() | ||
789 | { | ||
790 | $list = [ | ||
791 | 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | ||
792 | 'http://0.0.0.0/entry2', | ||
793 | ]; | ||
794 | |||
795 | $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list)); | ||
770 | 796 | ||
771 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 797 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
772 | 798 | ||
773 | $content = json_decode($this->client->getResponse()->getContent(), true); | 799 | $content = json_decode($this->client->getResponse()->getContent(), true); |
774 | 800 | ||
775 | $this->assertInternalType('int', $content[0]['entry']); | 801 | $this->assertInternalType('int', $content[0]['entry']); |
776 | $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); | 802 | $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 | 803 | ||
778 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | 804 | $this->assertInternalType('int', $content[1]['entry']); |
779 | ->getRepository('WallabagCoreBundle:Entry') | 805 | $this->assertEquals('http://0.0.0.0/entry2', $content[1]['url']); |
780 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | 806 | } |
781 | 807 | ||
782 | $tags = $entry->getTags(); | 808 | public function testDeleteEntriesListAction() |
783 | $this->assertCount(2, $tags); | 809 | { |
810 | $list = [ | ||
811 | 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | ||
812 | 'http://0.0.0.0/entry3', | ||
813 | ]; | ||
814 | |||
815 | $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); | ||
816 | |||
817 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
818 | |||
819 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
820 | |||
821 | $this->assertTrue($content[0]['entry']); | ||
822 | $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']); | ||
823 | |||
824 | $this->assertFalse($content[1]['entry']); | ||
825 | $this->assertEquals('http://0.0.0.0/entry3', $content[1]['url']); | ||
826 | } | ||
827 | |||
828 | public function testLimitBulkAction() | ||
829 | { | ||
830 | $list = [ | ||
831 | 'http://0.0.0.0/entry1', | ||
832 | 'http://0.0.0.0/entry1', | ||
833 | 'http://0.0.0.0/entry1', | ||
834 | 'http://0.0.0.0/entry1', | ||
835 | 'http://0.0.0.0/entry1', | ||
836 | 'http://0.0.0.0/entry1', | ||
837 | 'http://0.0.0.0/entry1', | ||
838 | 'http://0.0.0.0/entry1', | ||
839 | 'http://0.0.0.0/entry1', | ||
840 | 'http://0.0.0.0/entry1', | ||
841 | 'http://0.0.0.0/entry1', | ||
842 | ]; | ||
843 | |||
844 | $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list)); | ||
845 | |||
846 | $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); | ||
847 | $this->assertContains('API limit reached', $this->client->getResponse()->getContent()); | ||
784 | } | 848 | } |
785 | } | 849 | } |