]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
fix cs and phpdoc
authorThomas Citharel <tcit@tcit.fr>
Sun, 9 Oct 2016 12:01:28 +0000 (14:01 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 22 Oct 2016 07:06:07 +0000 (09:06 +0200)
src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
src/Wallabag/ApiBundle/Controller/WallabagRestController.php
tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php

index 519fd2f58a5e34add926376253a07fb648f27a3a..c13a034ffe58f27c2f7fab0a388ef0e686fed4b6 100644 (file)
@@ -27,7 +27,7 @@ class WallabagAnnotationController extends FOSRestController
             ->getRepository('WallabagAnnotationBundle:Annotation')
             ->findAnnotationsByPageId($entry->getId(), $this->getUser()->getId());
         $total = count($annotationRows);
-        $annotations = array('total' => $total, 'rows' => $annotationRows);
+        $annotations = ['total' => $total, 'rows' => $annotationRows];
 
         $json = $this->get('serializer')->serialize($annotations, 'json');
 
index b30ab267564740f2d6fe59cffdc27f458abb5b83..0c709ca099dfb964715338ce96ab413ef4310900 100644 (file)
@@ -536,12 +536,9 @@ class WallabagRestController extends FOSRestController
     {
         $this->validateAuthentication();
 
-        $response = $this->forward('WallabagApiBundle:WallabagRest:getAnnotations',
-            [
-                'entry' => $entry,
-            ]);
-
-        return $response;
+        return $this->forward('WallabagApiBundle:WallabagRest:getAnnotations', [
+            'entry' => $entry,
+        ]);
     }
 
     /**
@@ -563,13 +560,10 @@ class WallabagRestController extends FOSRestController
     {
         $this->validateAuthentication();
 
-        $response = $this->forward('WallabagApiBundle:WallabagRest:postAnnotation',
-            [
+        return $this->forward('WallabagApiBundle:WallabagRest:postAnnotation', [
                 'request' => $request,
                 'entry' => $entry,
             ]);
-
-        return $response;
     }
 
     /**
@@ -592,13 +586,10 @@ class WallabagRestController extends FOSRestController
     {
         $this->validateAuthentication();
 
-        $response = $this->forward('WallabagApiBundle:WallabagRest:putAnnotation',
-            [
+        return $this->forward('WallabagApiBundle:WallabagRest:putAnnotation', [
                 'annotation' => $annotation,
                 'request' => $request,
             ]);
-
-        return $response;
     }
 
     /**
@@ -620,12 +611,9 @@ class WallabagRestController extends FOSRestController
     {
         $this->validateAuthentication();
 
-        $response = $this->forward('WallabagApiBundle:WallabagRest:deleteAnnotation',
-            [
+        return $this->forward('WallabagApiBundle:WallabagRest:deleteAnnotation', [
                 'annotation' => $annotation,
             ]);
-
-        return $response;
     }
 
     /**
index 70849f74129000ca787a0a414396feb478516f81..9b2a6f8dd513b97cb88ddaed56353af7c16f5b41 100644 (file)
@@ -3,11 +3,17 @@
 namespace Tests\AnnotationBundle\Controller;
 
 use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase;
+use Wallabag\AnnotationBundle\Entity\Annotation;
+use Wallabag\CoreBundle\Entity\Entry;
 
 class AnnotationControllerTest extends WallabagAnnotationTestCase
 {
+    /**
+     * Test fetching annotations for an entry
+     */
     public function testGetAnnotations()
     {
+        /** @var Annotation $annotation */
         $annotation = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -18,7 +24,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
         }
 
         $this->logInAs('admin');
-        $crawler = $this->client->request('GET', 'annotations/'.$annotation->getEntry()->getId().'.json');
+        $this->client->request('GET', 'annotations/'.$annotation->getEntry()->getId().'.json');
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
@@ -26,10 +32,14 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
         $this->assertEquals($annotation->getText(), $content['rows'][0]['text']);
     }
 
+    /**
+     * Test creating an annotation for an entry
+     */
     public function testSetAnnotation()
     {
         $this->logInAs('admin');
 
+        /** @var Entry $entry */
         $entry = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
@@ -41,7 +51,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
             'quote' => 'my quote',
             'ranges' => ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
         ]);
-        $crawler = $this->client->request('POST', 'annotations/'.$entry->getId().'.json', [], [], $headers, $content);
+        $this->client->request('POST', 'annotations/'.$entry->getId().'.json', [], [], $headers, $content);
 
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
@@ -52,6 +62,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
         $this->assertEquals('my annotation', $content['text']);
         $this->assertEquals('my quote', $content['quote']);
 
+        /** @var Annotation $annotation */
         $annotation = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -60,8 +71,12 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
         $this->assertEquals('my annotation', $annotation->getText());
     }
 
+    /**
+     * Test editing an existing annotation
+     */
     public function testEditAnnotation()
     {
+        /** @var Annotation $annotation */
         $annotation = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -73,7 +88,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
         $content = json_encode([
             'text' => 'a modified annotation',
         ]);
-        $crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
+        $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
@@ -83,6 +98,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
         $this->assertEquals('a modified annotation', $content['text']);
         $this->assertEquals('my quote', $content['quote']);
 
+        /** @var Annotation $annotationUpdated */
         $annotationUpdated = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -90,8 +106,12 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
         $this->assertEquals('a modified annotation', $annotationUpdated->getText());
     }
 
+    /**
+     * Test deleting an annotation
+     */
     public function testDeleteAnnotation()
     {
+        /** @var Annotation $annotation */
         $annotation = $this->client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -103,7 +123,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
         $content = json_encode([
             'text' => 'a modified annotation',
         ]);
-        $crawler = $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
+        $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
 
         $content = json_decode($this->client->getResponse()->getContent(), true);
index 82790a5c43c350d7bca672d3a19380b85b525421..ef3f1324eb3937fe2f76c0e370dc976844543232 100644 (file)
@@ -8,7 +8,7 @@ use Symfony\Component\BrowserKit\Cookie;
 abstract class WallabagAnnotationTestCase extends WebTestCase
 {
     /**
-     * @var Client
+     * @var \Symfony\Bundle\FrameworkBundle\Client
      */
     protected $client = null;
 
@@ -35,7 +35,7 @@ abstract class WallabagAnnotationTestCase extends WebTestCase
     }
 
     /**
-     * @return Client
+     * @return \Symfony\Bundle\FrameworkBundle\Client
      */
     protected function createAuthorizedClient()
     {
@@ -49,7 +49,7 @@ abstract class WallabagAnnotationTestCase extends WebTestCase
         $firewallName = $container->getParameter('fos_user.firewall_name');
 
         $this->user = $userManager->findUserBy(['username' => 'admin']);
-        $loginManager->loginUser($firewallName, $this->user);
+        $loginManager->logInUser($firewallName, $this->user);
 
         // save the login token into the session and put it in a cookie
         $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));