From ca9a83ee511a1e9c54d375b76509de699bd2164a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 24 Feb 2017 11:31:31 +0100 Subject: return id of article instead of true if entry exists --- src/Wallabag/ApiBundle/Controller/EntryRestController.php | 4 ++-- tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 4 ++-- 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 ->getRepository('WallabagCoreBundle:Entry') ->findByUrlAndUserId($url, $this->getUser()->getId()); - $results[$url] = false === $res ? false : true; + $results[$url] = $res instanceof Entry ? $res->getId() : false; } $json = $this->get('serializer')->serialize($results, 'json'); @@ -60,7 +60,7 @@ class EntryRestController extends WallabagRestController ->getRepository('WallabagCoreBundle:Entry') ->findByUrlAndUserId($url, $this->getUser()->getId()); - $exists = false === $res ? false : true; + $exists = $res instanceof Entry ? $res->getId() : false; $json = $this->get('serializer')->serialize(['exists' => $exists], 'json'); 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 $content = json_decode($this->client->getResponse()->getContent(), true); - $this->assertEquals(true, $content['exists']); + $this->assertEquals(2, $content['exists']); } public function testGetEntriesExistsWithManyUrls() @@ -657,7 +657,7 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertArrayHasKey($url1, $content); $this->assertArrayHasKey($url2, $content); - $this->assertEquals(true, $content[$url1]); + $this->assertEquals(2, $content[$url1]); $this->assertEquals(false, $content[$url2]); } -- cgit v1.2.3