diff options
author | adev <adev2000@gmail.com> | 2017-05-15 20:47:59 +0200 |
---|---|---|
committer | adev <adev2000@gmail.com> | 2017-05-31 16:03:54 +0200 |
commit | 7ab5eb9508921d84b4b4ec84a59135d536da748e (patch) | |
tree | 725d9fae04d07a2c0aec2d2f5a19e1b43ec7a5d1 /tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |
parent | 4423b88c5b2c2d530b0a83a822f521a61ca4d4b8 (diff) | |
download | wallabag-7ab5eb9508921d84b4b4ec84a59135d536da748e.tar.gz wallabag-7ab5eb9508921d84b4b4ec84a59135d536da748e.tar.zst wallabag-7ab5eb9508921d84b4b4ec84a59135d536da748e.zip |
Isolated tests
Use https://github.com/dmaicher/doctrine-test-bundle to have test isolation.
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 bf7d373a..1ecd03fb 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 | { |
@@ -801,22 +803,28 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
801 | 803 | ||
802 | public function testDeleteEntriesTagsListAction() | 804 | public function testDeleteEntriesTagsListAction() |
803 | { | 805 | { |
804 | $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') | 806 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
805 | ->getRepository('WallabagCoreBundle:Entry') | 807 | $entry = new Entry($em->getReference(User::class, 1)); |
806 | ->findByUrlAndUserId('http://0.0.0.0/entry4', 1); | 808 | $entry->setUrl('http://0.0.0.0/test-entry'); |
809 | $entry->addTag((new Tag())->setLabel('foo-tag')); | ||
810 | $entry->addTag((new Tag())->setLabel('bar-tag')); | ||
811 | $em->persist($entry); | ||
812 | $em->flush(); | ||
807 | 813 | ||
808 | $tags = $entry->getTags(); | 814 | $em->clear(); |
809 | |||
810 | $this->assertCount(4, $tags); | ||
811 | 815 | ||
812 | $list = [ | 816 | $list = [ |
813 | [ | 817 | [ |
814 | 'url' => 'http://0.0.0.0/entry4', | 818 | 'url' => 'http://0.0.0.0/test-entry', |
815 | 'tags' => 'new tag 1, new tag 2', | 819 | 'tags' => 'foo-tag, bar-tag', |
816 | ], | 820 | ], |
817 | ]; | 821 | ]; |
818 | 822 | ||
819 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); | 823 | $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); |
824 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
825 | |||
826 | $entry = $em->getRepository('WallabagCoreBundle:Entry')->find($entry->getId()); | ||
827 | $this->assertCount(0, $entry->getTags()); | ||
820 | } | 828 | } |
821 | 829 | ||
822 | public function testPostEntriesListAction() | 830 | public function testPostEntriesListAction() |
@@ -841,9 +849,14 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
841 | 849 | ||
842 | public function testDeleteEntriesListAction() | 850 | public function testDeleteEntriesListAction() |
843 | { | 851 | { |
852 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
853 | $em->persist((new Entry($em->getReference(User::class, 1)))->setUrl('http://0.0.0.0/test-entry1')); | ||
854 | |||
855 | $em->flush(); | ||
856 | $em->clear(); | ||
844 | $list = [ | 857 | $list = [ |
845 | 'http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', | 858 | 'http://0.0.0.0/test-entry1', |
846 | 'http://0.0.0.0/entry3', | 859 | 'http://0.0.0.0/test-entry-not-exist', |
847 | ]; | 860 | ]; |
848 | 861 | ||
849 | $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); | 862 | $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); |
@@ -853,10 +866,10 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
853 | $content = json_decode($this->client->getResponse()->getContent(), true); | 866 | $content = json_decode($this->client->getResponse()->getContent(), true); |
854 | 867 | ||
855 | $this->assertTrue($content[0]['entry']); | 868 | $this->assertTrue($content[0]['entry']); |
856 | $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']); | 869 | $this->assertEquals('http://0.0.0.0/test-entry1', $content[0]['url']); |
857 | 870 | ||
858 | $this->assertFalse($content[1]['entry']); | 871 | $this->assertFalse($content[1]['entry']); |
859 | $this->assertEquals('http://0.0.0.0/entry3', $content[1]['url']); | 872 | $this->assertEquals('http://0.0.0.0/test-entry-not-exist', $content[1]['url']); |
860 | } | 873 | } |
861 | 874 | ||
862 | public function testLimitBulkAction() | 875 | public function testLimitBulkAction() |