aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-06-07 16:30:27 +0200
committerGitHub <noreply@github.com>2017-06-07 16:30:27 +0200
commit7bb3aa31776ffce2735a3b16f6ad80bb17946d4d (patch)
tree5dd6bae023e67731479a8f799f3e00780ac98c56 /tests/Wallabag
parentc0d756f67d1cc0fc6832d404a09729f9219f0595 (diff)
parentc406cef5b69b0d6c43adef33b5374b209347b637 (diff)
downloadwallabag-7bb3aa31776ffce2735a3b16f6ad80bb17946d4d.tar.gz
wallabag-7bb3aa31776ffce2735a3b16f6ad80bb17946d4d.tar.zst
wallabag-7bb3aa31776ffce2735a3b16f6ad80bb17946d4d.zip
Merge pull request #3093 from aaa2000/annotation-error-on-save
Displays an error with an annotation with a too long quote
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
index 81f9e9ec..8f87ccf3 100644
--- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
+++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
@@ -84,7 +84,9 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
84 $content = json_encode([ 84 $content = json_encode([
85 'text' => 'my annotation', 85 'text' => 'my annotation',
86 'quote' => 'my quote', 86 'quote' => 'my quote',
87 'ranges' => ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31], 87 'ranges' => [
88 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31]
89 ],
88 ]); 90 ]);
89 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content); 91 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content);
90 92
@@ -107,6 +109,36 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
107 } 109 }
108 110
109 /** 111 /**
112 * @dataProvider dataForEachAnnotations
113 */
114 public function testSetAnnotationWithQuoteTooLong($prefixUrl)
115 {
116 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
117
118 if ('annotations' === $prefixUrl) {
119 $this->logInAs('admin');
120 }
121
122 /** @var Entry $entry */
123 $entry = $em
124 ->getRepository('WallabagCoreBundle:Entry')
125 ->findOneByUsernameAndNotArchived('admin');
126
127 $longQuote = str_repeat('a', 10001);
128 $headers = ['CONTENT_TYPE' => 'application/json'];
129 $content = json_encode([
130 'text' => 'my annotation',
131 'quote' => $longQuote,
132 'ranges' => [
133 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31]
134 ],
135 ]);
136 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content);
137
138 $this->assertEquals(400, $this->client->getResponse()->getStatusCode());
139 }
140
141 /**
110 * Test editing an existing annotation. 142 * Test editing an existing annotation.
111 * 143 *
112 * @dataProvider dataForEachAnnotations 144 * @dataProvider dataForEachAnnotations