]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Merge pull request #2097 from bmillemathias/issue_2045
authorNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 19 May 2016 07:19:01 +0000 (09:19 +0200)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 19 May 2016 07:19:01 +0000 (09:19 +0200)
Fix image path in 2-factor authentification email

src/Wallabag/ApiBundle/Controller/WallabagRestController.php
src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php

index 5202c524c68da16c0b2f0411e76ebbeeff1a7268..af24e4988650b33aa7b6b2ae6462f21204a42706 100644 (file)
@@ -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);
index 2f2d92ee83e524e1a2813b6b487451cb3408efbb..c50e4d027c0b386d49ea9a8e9ac841e0d80a3416 100644 (file)
@@ -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']);
+    }
 }