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.php74
1 files changed, 71 insertions, 3 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 409a8291..19fb5170 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -298,7 +298,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
298 $entry = $this->client->getContainer() 298 $entry = $this->client->getContainer()
299 ->get('doctrine.orm.entity_manager') 299 ->get('doctrine.orm.entity_manager')
300 ->getRepository('WallabagCoreBundle:Entry') 300 ->getRepository('WallabagCoreBundle:Entry')
301 ->findOneByUser(1); 301 ->findOneByUser(1, ['id' => 'asc']);
302 302
303 if (!$entry) { 303 if (!$entry) {
304 $this->markTestSkipped('No content found in db.'); 304 $this->markTestSkipped('No content found in db.');
@@ -642,7 +642,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
642 642
643 $content = json_decode($this->client->getResponse()->getContent(), true); 643 $content = json_decode($this->client->getResponse()->getContent(), true);
644 644
645 $this->assertEquals(true, $content['exists']); 645 $this->assertEquals(2, $content['exists']);
646 } 646 }
647 647
648 public function testGetEntriesExistsWithManyUrls() 648 public function testGetEntriesExistsWithManyUrls()
@@ -657,7 +657,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
657 657
658 $this->assertArrayHasKey($url1, $content); 658 $this->assertArrayHasKey($url1, $content);
659 $this->assertArrayHasKey($url2, $content); 659 $this->assertArrayHasKey($url2, $content);
660 $this->assertEquals(true, $content[$url1]); 660 $this->assertEquals(2, $content[$url1]);
661 $this->assertEquals(false, $content[$url2]); 661 $this->assertEquals(false, $content[$url2]);
662 } 662 }
663 663
@@ -714,4 +714,72 @@ class EntryRestControllerTest extends WallabagApiTestCase
714 714
715 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 715 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
716 } 716 }
717
718 public function testPostEntriesTagsListAction()
719 {
720 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
721 ->getRepository('WallabagCoreBundle:Entry')
722 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
723
724 $tags = $entry->getTags();
725
726 $this->assertCount(2, $tags);
727
728 $list = [
729 [
730 'url' => 'http://0.0.0.0/entry4',
731 'tags' => 'new tag 1, new tag 2',
732 ],
733 ];
734
735 $this->client->request('POST', '/api/entries/tags/lists?list='.json_encode($list));
736
737 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
738
739 $content = json_decode($this->client->getResponse()->getContent(), true);
740
741 $this->assertInternalType('int', $content[0]['entry']);
742 $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']);
743
744 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
745 ->getRepository('WallabagCoreBundle:Entry')
746 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
747
748 $tags = $entry->getTags();
749 $this->assertCount(4, $tags);
750 }
751
752 public function testDeleteEntriesTagsListAction()
753 {
754 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
755 ->getRepository('WallabagCoreBundle:Entry')
756 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
757
758 $tags = $entry->getTags();
759
760 $this->assertCount(4, $tags);
761
762 $list = [
763 [
764 'url' => 'http://0.0.0.0/entry4',
765 'tags' => 'new tag 1, new tag 2',
766 ],
767 ];
768
769 $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list));
770
771 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
772
773 $content = json_decode($this->client->getResponse()->getContent(), true);
774
775 $this->assertInternalType('int', $content[0]['entry']);
776 $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']);
777
778 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
779 ->getRepository('WallabagCoreBundle:Entry')
780 ->findByUrlAndUserId('http://0.0.0.0/entry4', 1);
781
782 $tags = $entry->getTags();
783 $this->assertCount(2, $tags);
784 }
717} 785}