diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index d9acacfc..e6ffd664 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.'); |
@@ -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 | } |