diff options
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index e9ba4634..0968cfaf 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -3,8 +3,10 @@ | |||
3 | namespace Tests\Wallabag\ApiBundle\Controller; | 3 | namespace Tests\Wallabag\ApiBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\ApiBundle\WallabagApiTestCase; | 5 | use Tests\Wallabag\ApiBundle\WallabagApiTestCase; |
6 | use Wallabag\CoreBundle\Entity\Entry; | ||
6 | use Wallabag\CoreBundle\Entity\Tag; | 7 | use Wallabag\CoreBundle\Entity\Tag; |
7 | use Wallabag\CoreBundle\Helper\ContentProxy; | 8 | use Wallabag\CoreBundle\Helper\ContentProxy; |
9 | use Wallabag\UserBundle\Entity\User; | ||
8 | 10 | ||
9 | class EntryRestControllerTest extends WallabagApiTestCase | 11 | class EntryRestControllerTest extends WallabagApiTestCase |
10 | { | 12 | { |
@@ -811,22 +813,28 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
811 | 813 | ||
812 | public function testDeleteEntriesTagsListAction() | 814 | public function testDeleteEntriesTagsListAction() |
813 | { | 815 | { |
814 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | 816 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
815 | ->getRepository('WallabagCoreBundle:Entry') | 817 | $entry = new Entry($em->getReference(User::class, 1)); |
816 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | 818 | $entry->setUrl('http://0.0.0.0/test-entry'); |
819 | $entry->addTag((new Tag())->setLabel('foo-tag')); | ||
820 | $entry->addTag((new Tag())->setLabel('bar-tag')); | ||
821 | $em->persist($entry); | ||
822 | $em->flush(); | ||
817 | 823 | ||
818 | $tags = $entry->getTags(); | 824 | $em->clear(); |
819 | |||
820 | $this->assertCount(4, $tags); | ||
821 | 825 | ||
822 | $list = [ | 826 | $list = [ |
823 | [ | 827 | [ |
824 | 'url' => 'http://0.0.0.0/entry4', | 828 | 'url' => 'http://0.0.0.0/test-entry', |
825 | 'tags' => 'new tag 1, new tag 2', | 829 | 'tags' => 'foo-tag, bar-tag', |
826 | ], | 830 | ], |
827 | ]; | 831 | ]; |
828 | 832 | ||
829 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); | 833 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); |
834 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
835 | |||
836 | $entry = $em->getRepository('WallabagCoreBundle:Entry')->find($entry->getId()); | ||
837 | $this->assertCount(0, $entry->getTags()); | ||
830 | } | 838 | } |
831 | 839 | ||
832 | public function testPostEntriesListAction() | 840 | public function testPostEntriesListAction() |
@@ -851,9 +859,14 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
851 | 859 | ||
852 | public function testDeleteEntriesListAction() | 860 | public function testDeleteEntriesListAction() |
853 | { | 861 | { |
862 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
863 | $em->persist((new Entry($em->getReference(User::class, 1)))->setUrl('http://0.0.0.0/test-entry1')); | ||
864 | |||
865 | $em->flush(); | ||
866 | $em->clear(); | ||
854 | $list = [ | 867 | $list = [ |
855 | 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | 868 | 'http://0.0.0.0/test-entry1', |
856 | 'http://0.0.0.0/entry3', | 869 | 'http://0.0.0.0/test-entry-not-exist', |
857 | ]; | 870 | ]; |
858 | 871 | ||
859 | $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); | 872 | $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); |
@@ -863,10 +876,10 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
863 | $content = json_decode($this->client->getResponse()->getContent(), true); | 876 | $content = json_decode($this->client->getResponse()->getContent(), true); |
864 | 877 | ||
865 | $this->assertTrue($content[0]['entry']); | 878 | $this->assertTrue($content[0]['entry']); |
866 | $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']); | 879 | $this->assertEquals('http://0.0.0.0/test-entry1', $content[0]['url']); |
867 | 880 | ||
868 | $this->assertFalse($content[1]['entry']); | 881 | $this->assertFalse($content[1]['entry']); |
869 | $this->assertEquals('http://0.0.0.0/entry3', $content[1]['url']); | 882 | $this->assertEquals('http://0.0.0.0/test-entry-not-exist', $content[1]['url']); |
870 | } | 883 | } |
871 | 884 | ||
872 | public function testLimitBulkAction() | 885 | public function testLimitBulkAction() |