aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/AnnotationBundle/Controller
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-10-09 14:01:28 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-22 09:06:07 +0200
commit0c271b9eb0813162b82c6b3bc38604716398ddd1 (patch)
tree0739a26c4e2a973013d4d38bcd2e8075f19d6093 /tests/Wallabag/AnnotationBundle/Controller
parentb1e92f8c14d3d506f2bfab628ba8ed95de0e8b51 (diff)
downloadwallabag-0c271b9eb0813162b82c6b3bc38604716398ddd1.tar.gz
wallabag-0c271b9eb0813162b82c6b3bc38604716398ddd1.tar.zst
wallabag-0c271b9eb0813162b82c6b3bc38604716398ddd1.zip
fix cs and phpdoc
Diffstat (limited to 'tests/Wallabag/AnnotationBundle/Controller')
-rw-r--r--tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php28
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
index 70849f74..9b2a6f8d 100644
--- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
+++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
@@ -3,11 +3,17 @@
3namespace Tests\AnnotationBundle\Controller; 3namespace Tests\AnnotationBundle\Controller;
4 4
5use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase; 5use Tests\Wallabag\AnnotationBundle\WallabagAnnotationTestCase;
6use Wallabag\AnnotationBundle\Entity\Annotation;
7use Wallabag\CoreBundle\Entity\Entry;
6 8
7class AnnotationControllerTest extends WallabagAnnotationTestCase 9class AnnotationControllerTest extends WallabagAnnotationTestCase
8{ 10{
11 /**
12 * Test fetching annotations for an entry
13 */
9 public function testGetAnnotations() 14 public function testGetAnnotations()
10 { 15 {
16 /** @var Annotation $annotation */
11 $annotation = $this->client->getContainer() 17 $annotation = $this->client->getContainer()
12 ->get('doctrine.orm.entity_manager') 18 ->get('doctrine.orm.entity_manager')
13 ->getRepository('WallabagAnnotationBundle:Annotation') 19 ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -18,7 +24,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
18 } 24 }
19 25
20 $this->logInAs('admin'); 26 $this->logInAs('admin');
21 $crawler = $this->client->request('GET', 'annotations/'.$annotation->getEntry()->getId().'.json'); 27 $this->client->request('GET', 'annotations/'.$annotation->getEntry()->getId().'.json');
22 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 28 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
23 29
24 $content = json_decode($this->client->getResponse()->getContent(), true); 30 $content = json_decode($this->client->getResponse()->getContent(), true);
@@ -26,10 +32,14 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
26 $this->assertEquals($annotation->getText(), $content['rows'][0]['text']); 32 $this->assertEquals($annotation->getText(), $content['rows'][0]['text']);
27 } 33 }
28 34
35 /**
36 * Test creating an annotation for an entry
37 */
29 public function testSetAnnotation() 38 public function testSetAnnotation()
30 { 39 {
31 $this->logInAs('admin'); 40 $this->logInAs('admin');
32 41
42 /** @var Entry $entry */
33 $entry = $this->client->getContainer() 43 $entry = $this->client->getContainer()
34 ->get('doctrine.orm.entity_manager') 44 ->get('doctrine.orm.entity_manager')
35 ->getRepository('WallabagCoreBundle:Entry') 45 ->getRepository('WallabagCoreBundle:Entry')
@@ -41,7 +51,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
41 'quote' => 'my quote', 51 'quote' => 'my quote',
42 'ranges' => ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31], 52 'ranges' => ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
43 ]); 53 ]);
44 $crawler = $this->client->request('POST', 'annotations/'.$entry->getId().'.json', [], [], $headers, $content); 54 $this->client->request('POST', 'annotations/'.$entry->getId().'.json', [], [], $headers, $content);
45 55
46 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 56 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
47 57
@@ -52,6 +62,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
52 $this->assertEquals('my annotation', $content['text']); 62 $this->assertEquals('my annotation', $content['text']);
53 $this->assertEquals('my quote', $content['quote']); 63 $this->assertEquals('my quote', $content['quote']);
54 64
65 /** @var Annotation $annotation */
55 $annotation = $this->client->getContainer() 66 $annotation = $this->client->getContainer()
56 ->get('doctrine.orm.entity_manager') 67 ->get('doctrine.orm.entity_manager')
57 ->getRepository('WallabagAnnotationBundle:Annotation') 68 ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -60,8 +71,12 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
60 $this->assertEquals('my annotation', $annotation->getText()); 71 $this->assertEquals('my annotation', $annotation->getText());
61 } 72 }
62 73
74 /**
75 * Test editing an existing annotation
76 */
63 public function testEditAnnotation() 77 public function testEditAnnotation()
64 { 78 {
79 /** @var Annotation $annotation */
65 $annotation = $this->client->getContainer() 80 $annotation = $this->client->getContainer()
66 ->get('doctrine.orm.entity_manager') 81 ->get('doctrine.orm.entity_manager')
67 ->getRepository('WallabagAnnotationBundle:Annotation') 82 ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -73,7 +88,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
73 $content = json_encode([ 88 $content = json_encode([
74 'text' => 'a modified annotation', 89 'text' => 'a modified annotation',
75 ]); 90 ]);
76 $crawler = $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content); 91 $this->client->request('PUT', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
77 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 92 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
78 93
79 $content = json_decode($this->client->getResponse()->getContent(), true); 94 $content = json_decode($this->client->getResponse()->getContent(), true);
@@ -83,6 +98,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
83 $this->assertEquals('a modified annotation', $content['text']); 98 $this->assertEquals('a modified annotation', $content['text']);
84 $this->assertEquals('my quote', $content['quote']); 99 $this->assertEquals('my quote', $content['quote']);
85 100
101 /** @var Annotation $annotationUpdated */
86 $annotationUpdated = $this->client->getContainer() 102 $annotationUpdated = $this->client->getContainer()
87 ->get('doctrine.orm.entity_manager') 103 ->get('doctrine.orm.entity_manager')
88 ->getRepository('WallabagAnnotationBundle:Annotation') 104 ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -90,8 +106,12 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
90 $this->assertEquals('a modified annotation', $annotationUpdated->getText()); 106 $this->assertEquals('a modified annotation', $annotationUpdated->getText());
91 } 107 }
92 108
109 /**
110 * Test deleting an annotation
111 */
93 public function testDeleteAnnotation() 112 public function testDeleteAnnotation()
94 { 113 {
114 /** @var Annotation $annotation */
95 $annotation = $this->client->getContainer() 115 $annotation = $this->client->getContainer()
96 ->get('doctrine.orm.entity_manager') 116 ->get('doctrine.orm.entity_manager')
97 ->getRepository('WallabagAnnotationBundle:Annotation') 117 ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -103,7 +123,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
103 $content = json_encode([ 123 $content = json_encode([
104 'text' => 'a modified annotation', 124 'text' => 'a modified annotation',
105 ]); 125 ]);
106 $crawler = $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content); 126 $this->client->request('DELETE', 'annotations/'.$annotation->getId().'.json', [], [], $headers, $content);
107 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 127 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
108 128
109 $content = json_decode($this->client->getResponse()->getContent(), true); 129 $content = json_decode($this->client->getResponse()->getContent(), true);