aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-02-28 21:12:30 +0100
committerGitHub <noreply@github.com>2017-02-28 21:12:30 +0100
commite1cc8fd79921fdff9999087ba896c88b14ffc0cd (patch)
treecc337f2cafc054a323ee98f17651eff42851d80e
parentabba55cdd653a1915147e8303b873cc0d1e63adc (diff)
parentca9a83ee511a1e9c54d375b76509de699bd2164a (diff)
downloadwallabag-e1cc8fd79921fdff9999087ba896c88b14ffc0cd.tar.gz
wallabag-e1cc8fd79921fdff9999087ba896c88b14ffc0cd.tar.zst
wallabag-e1cc8fd79921fdff9999087ba896c88b14ffc0cd.zip
Merge pull request #2919 from wallabag/api-exists-returns-id
Api exists returns
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php4
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index 2c2ec0c1..af5f7603 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -41,7 +41,7 @@ class EntryRestController extends WallabagRestController
41 ->getRepository('WallabagCoreBundle:Entry') 41 ->getRepository('WallabagCoreBundle:Entry')
42 ->findByUrlAndUserId($url, $this->getUser()->getId()); 42 ->findByUrlAndUserId($url, $this->getUser()->getId());
43 43
44 $results[$url] = false === $res ? false : true; 44 $results[$url] = $res instanceof Entry ? $res->getId() : false;
45 } 45 }
46 46
47 $json = $this->get('serializer')->serialize($results, 'json'); 47 $json = $this->get('serializer')->serialize($results, 'json');
@@ -60,7 +60,7 @@ class EntryRestController extends WallabagRestController
60 ->getRepository('WallabagCoreBundle:Entry') 60 ->getRepository('WallabagCoreBundle:Entry')
61 ->findByUrlAndUserId($url, $this->getUser()->getId()); 61 ->findByUrlAndUserId($url, $this->getUser()->getId());
62 62
63 $exists = false === $res ? false : true; 63 $exists = $res instanceof Entry ? $res->getId() : false;
64 64
65 $json = $this->get('serializer')->serialize(['exists' => $exists], 'json'); 65 $json = $this->get('serializer')->serialize(['exists' => $exists], 'json');
66 66
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index 409a8291..dc5160c7 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -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