aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php47
1 files changed, 35 insertions, 12 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index bf7d373a..0968cfaf 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -3,8 +3,10 @@
3namespace Tests\Wallabag\ApiBundle\Controller; 3namespace Tests\Wallabag\ApiBundle\Controller;
4 4
5use Tests\Wallabag\ApiBundle\WallabagApiTestCase; 5use Tests\Wallabag\ApiBundle\WallabagApiTestCase;
6use Wallabag\CoreBundle\Entity\Entry;
6use Wallabag\CoreBundle\Entity\Tag; 7use Wallabag\CoreBundle\Entity\Tag;
7use Wallabag\CoreBundle\Helper\ContentProxy; 8use Wallabag\CoreBundle\Helper\ContentProxy;
9use Wallabag\UserBundle\Entity\User;
8 10
9class EntryRestControllerTest extends WallabagApiTestCase 11class EntryRestControllerTest extends WallabagApiTestCase
10{ 12{
@@ -342,6 +344,10 @@ class EntryRestControllerTest extends WallabagApiTestCase
342 'url' => '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', 344 'url' => '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',
343 'tags' => 'google', 345 'tags' => 'google',
344 'title' => 'New title for my article', 346 'title' => 'New title for my article',
347 'content' => 'my content',
348 'language' => 'de_DE',
349 'published_at' => '2016-09-08T11:55:58+0200',
350 'authors' => 'bob,helen',
345 ]); 351 ]);
346 352
347 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 353 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -355,6 +361,12 @@ class EntryRestControllerTest extends WallabagApiTestCase
355 $this->assertEquals('New title for my article', $content['title']); 361 $this->assertEquals('New title for my article', $content['title']);
356 $this->assertEquals(1, $content['user_id']); 362 $this->assertEquals(1, $content['user_id']);
357 $this->assertCount(2, $content['tags']); 363 $this->assertCount(2, $content['tags']);
364 $this->assertSame('my content', $content['content']);
365 $this->assertSame('de_DE', $content['language']);
366 $this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']);
367 $this->assertCount(2, $content['published_by']);
368 $this->assertContains('bob', $content['published_by']);
369 $this->assertContains('helen', $content['published_by']);
358 } 370 }
359 371
360 public function testPostSameEntry() 372 public function testPostSameEntry()
@@ -801,22 +813,28 @@ class EntryRestControllerTest extends WallabagApiTestCase
801 813
802 public function testDeleteEntriesTagsListAction() 814 public function testDeleteEntriesTagsListAction()
803 { 815 {
804 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 816 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
805 ->getRepository('WallabagCoreBundle:Entry') 817 $entry = new Entry($em->getReference(User::class, 1));
806 ->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();
807 823
808 $tags = $entry->getTags(); 824 $em->clear();
809
810 $this->assertCount(4, $tags);
811 825
812 $list = [ 826 $list = [
813 [ 827 [
814 'url' => 'http://0.0.0.0/entry4', 828 'url' => 'http://0.0.0.0/test-entry',
815 'tags' => 'new tag 1, new tag 2', 829 'tags' => 'foo-tag, bar-tag',
816 ], 830 ],
817 ]; 831 ];
818 832
819 $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());
820 } 838 }
821 839
822 public function testPostEntriesListAction() 840 public function testPostEntriesListAction()
@@ -841,9 +859,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
841 859
842 public function testDeleteEntriesListAction() 860 public function testDeleteEntriesListAction()
843 { 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();
844 $list = [ 867 $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', 868 'http://0.0.0.0/test-entry1',
846 'http://0.0.0.0/entry3', 869 'http://0.0.0.0/test-entry-not-exist',
847 ]; 870 ];
848 871
849 $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); 872 $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list));
@@ -853,10 +876,10 @@ class EntryRestControllerTest extends WallabagApiTestCase
853 $content = json_decode($this->client->getResponse()->getContent(), true); 876 $content = json_decode($this->client->getResponse()->getContent(), true);
854 877
855 $this->assertTrue($content[0]['entry']); 878 $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']); 879 $this->assertEquals('http://0.0.0.0/test-entry1', $content[0]['url']);
857 880
858 $this->assertFalse($content[1]['entry']); 881 $this->assertFalse($content[1]['entry']);
859 $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']);
860 } 883 }
861 884
862 public function testLimitBulkAction() 885 public function testLimitBulkAction()