From: Nicolas LÅ“uillet Date: Thu, 19 May 2016 07:19:01 +0000 (+0200) Subject: Merge pull request #2097 from bmillemathias/issue_2045 X-Git-Tag: 2.0.5~7 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=9f95b14dec88cf083cefa38d5fbd84189e07acac;hp=2dcb1dbf05d2beae65a48dc2c92d28385d507f1f;p=github%2Fwallabag%2Fwallabag.git Merge pull request #2097 from bmillemathias/issue_2045 Fix image path in 2-factor authentification email --- diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 5202c524..af24e498 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -110,8 +110,8 @@ class WallabagRestController extends FOSRestController $url = $request->request->get('url'); $title = $request->request->get('title'); - $isArchived = (int) $request->request->get('archive'); - $isStarred = (int) $request->request->get('starred'); + $isArchived = $request->request->get('archive'); + $isStarred = $request->request->get('starred'); $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId()); @@ -172,8 +172,8 @@ class WallabagRestController extends FOSRestController $this->validateUserAccess($entry->getUser()->getId()); $title = $request->request->get('title'); - $isArchived = (int) $request->request->get('archive'); - $isStarred = (int) $request->request->get('starred'); + $isArchived = $request->request->get('archive'); + $isStarred = $request->request->get('starred'); if (!is_null($title)) { $entry->setTitle($title); diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index 2f2d92ee..c50e4d02 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -423,4 +423,91 @@ class WallabagRestControllerTest extends WallabagApiTestCase $this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'), $content); } + + public function testSaveIsArchivedAfterPost() + { + $entry = $this->client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneBy(['user' => 1, 'isArchived' => true]); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + $this->client->request('POST', '/api/entries.json', [ + 'url' => $entry->getUrl(), + ]); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertEquals(true, $content['is_archived']); + } + + public function testSaveIsStarredAfterPost() + { + $entry = $this->client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneBy(['user' => 1, 'isStarred' => true]); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + $this->client->request('POST', '/api/entries.json', [ + 'url' => $entry->getUrl(), + ]); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertEquals(true, $content['is_starred']); + } + + public function testSaveIsArchivedAfterPatch() + { + $entry = $this->client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneBy(['user' => 1, 'isArchived' => true]); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [ + 'title' => $entry->getTitle().'++', + ]); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertEquals(true, $content['is_archived']); + } + + public function testSaveIsStarredAfterPatch() + { + $entry = $this->client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneBy(['user' => 1, 'isStarred' => true]); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [ + 'title' => $entry->getTitle().'++', + ]); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertEquals(true, $content['is_starred']); + } }