aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ApiBundle')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
index fd72b8f2..5dcb3e00 100644
--- a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
@@ -561,6 +561,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase
561 */ 561 */
562 public function testDeleteUserTag($tag) 562 public function testDeleteUserTag($tag)
563 { 563 {
564 $tagName = $tag['label'];
565
564 $this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json'); 566 $this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json');
565 567
566 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 568 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -577,6 +579,13 @@ class WallabagRestControllerTest extends WallabagApiTestCase
577 ->findAllByTagId($this->user->getId(), $tag['id']); 579 ->findAllByTagId($this->user->getId(), $tag['id']);
578 580
579 $this->assertCount(0, $entries); 581 $this->assertCount(0, $entries);
582
583 $tag = $this->client->getContainer()
584 ->get('doctrine.orm.entity_manager')
585 ->getRepository('WallabagCoreBundle:Tag')
586 ->findOneByLabel($tagName);
587
588 $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag');
580 } 589 }
581 590
582 public function testDeleteTagByLabel() 591 public function testDeleteTagByLabel()
@@ -794,6 +803,22 @@ class WallabagRestControllerTest extends WallabagApiTestCase
794 $this->assertEquals(true, $content['exists']); 803 $this->assertEquals(true, $content['exists']);
795 } 804 }
796 805
806 public function testGetEntriesExistsWithManyUrls()
807 {
808 $url1 = 'http://0.0.0.0/entry2';
809 $url2 = 'http://0.0.0.0/entry10';
810 $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2);
811
812 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
813
814 $content = json_decode($this->client->getResponse()->getContent(), true);
815
816 $this->assertArrayHasKey($url1, $content);
817 $this->assertArrayHasKey($url2, $content);
818 $this->assertEquals(true, $content[$url1]);
819 $this->assertEquals(false, $content[$url2]);
820 }
821
797 public function testGetEntriesExistsWhichDoesNotExists() 822 public function testGetEntriesExistsWhichDoesNotExists()
798 { 823 {
799 $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2'); 824 $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2');
@@ -804,4 +829,11 @@ class WallabagRestControllerTest extends WallabagApiTestCase
804 829
805 $this->assertEquals(false, $content['exists']); 830 $this->assertEquals(false, $content['exists']);
806 } 831 }
832
833 public function testGetEntriesExistsWithNoUrl()
834 {
835 $this->client->request('GET', '/api/entries/exists?url=');
836
837 $this->assertEquals(403, $this->client->getResponse()->getStatusCode());
838 }
807} 839}