mirror of
https://github.com/wallabag/wallabag.git
synced 2025-02-20 04:26:16 +00:00
Merge pull request #2919 from wallabag/api-exists-returns-id
Api exists returns
This commit is contained in:
commit
e1cc8fd799
2 changed files with 4 additions and 4 deletions
|
@ -41,7 +41,7 @@ class EntryRestController extends WallabagRestController
|
||||||
->getRepository('WallabagCoreBundle:Entry')
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
->findByUrlAndUserId($url, $this->getUser()->getId());
|
->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');
|
$json = $this->get('serializer')->serialize($results, 'json');
|
||||||
|
@ -60,7 +60,7 @@ class EntryRestController extends WallabagRestController
|
||||||
->getRepository('WallabagCoreBundle:Entry')
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
->findByUrlAndUserId($url, $this->getUser()->getId());
|
->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');
|
$json = $this->get('serializer')->serialize(['exists' => $exists], 'json');
|
||||||
|
|
||||||
|
|
|
@ -642,7 +642,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
||||||
|
|
||||||
$content = json_decode($this->client->getResponse()->getContent(), true);
|
$content = json_decode($this->client->getResponse()->getContent(), true);
|
||||||
|
|
||||||
$this->assertEquals(true, $content['exists']);
|
$this->assertEquals(2, $content['exists']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetEntriesExistsWithManyUrls()
|
public function testGetEntriesExistsWithManyUrls()
|
||||||
|
@ -657,7 +657,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
||||||
|
|
||||||
$this->assertArrayHasKey($url1, $content);
|
$this->assertArrayHasKey($url1, $content);
|
||||||
$this->assertArrayHasKey($url2, $content);
|
$this->assertArrayHasKey($url2, $content);
|
||||||
$this->assertEquals(true, $content[$url1]);
|
$this->assertEquals(2, $content[$url1]);
|
||||||
$this->assertEquals(false, $content[$url2]);
|
$this->assertEquals(false, $content[$url2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue