aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2017-06-23 08:30:23 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-06-23 08:30:23 +0200
commit18696f77fdc76f7055d84460d459051a6bb7253a (patch)
tree445651b0962e18b842b86244a9c0ba26462785b9 /tests
parent29714661b1df78871ceaf0e079f11041a8641d4b (diff)
downloadwallabag-18696f77fdc76f7055d84460d459051a6bb7253a.tar.gz
wallabag-18696f77fdc76f7055d84460d459051a6bb7253a.tar.zst
wallabag-18696f77fdc76f7055d84460d459051a6bb7253a.zip
Avoid BC on exists endpoint
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php41
1 files changed, 37 insertions, 4 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 067aed2c..dc21bd32 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -759,21 +759,54 @@ class EntryRestControllerTest extends WallabagApiTestCase
759 $this->assertEquals(true, $content['is_starred']); 759 $this->assertEquals(true, $content['is_starred']);
760 } 760 }
761 761
762 public function testGetEntriesExists() 762 public function dataForEntriesExistWithUrl()
763 { 763 {
764 $this->client->request('GET', '/api/entries/exists?url=http://0.0.0.0/entry2'); 764 return [
765 'with_id' => [
766 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2&return_id=1',
767 'expectedValue' => 2,
768 ],
769 'without_id' => [
770 'url' => '/api/entries/exists?url=http://0.0.0.0/entry2',
771 'expectedValue' => true,
772 ],
773 ];
774 }
775
776 /**
777 * @dataProvider dataForEntriesExistWithUrl
778 */
779 public function testGetEntriesExists($url, $expectedValue)
780 {
781 $this->client->request('GET', $url);
765 782
766 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 783 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
767 784
768 $content = json_decode($this->client->getResponse()->getContent(), true); 785 $content = json_decode($this->client->getResponse()->getContent(), true);
769 786
770 $this->assertEquals(2, $content['exists']); 787 $this->assertSame($expectedValue, $content['exists']);
771 } 788 }
772 789
773 public function testGetEntriesExistsWithManyUrls() 790 public function testGetEntriesExistsWithManyUrls()
774 { 791 {
775 $url1 = 'http://0.0.0.0/entry2'; 792 $url1 = 'http://0.0.0.0/entry2';
776 $url2 = 'http://0.0.0.0/entry10'; 793 $url2 = 'http://0.0.0.0/entry10';
794 $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2.'&return_id=1');
795
796 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
797
798 $content = json_decode($this->client->getResponse()->getContent(), true);
799
800 $this->assertArrayHasKey($url1, $content);
801 $this->assertArrayHasKey($url2, $content);
802 $this->assertSame(2, $content[$url1]);
803 $this->assertSame(false, $content[$url2]);
804 }
805
806 public function testGetEntriesExistsWithManyUrlsReturnBool()
807 {
808 $url1 = 'http://0.0.0.0/entry2';
809 $url2 = 'http://0.0.0.0/entry10';
777 $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2); 810 $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2);
778 811
779 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 812 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@@ -782,7 +815,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
782 815
783 $this->assertArrayHasKey($url1, $content); 816 $this->assertArrayHasKey($url1, $content);
784 $this->assertArrayHasKey($url2, $content); 817 $this->assertArrayHasKey($url2, $content);
785 $this->assertEquals(2, $content[$url1]); 818 $this->assertEquals(true, $content[$url1]);
786 $this->assertEquals(false, $content[$url2]); 819 $this->assertEquals(false, $content[$url2]);
787 } 820 }
788 821