diff options
author | adev <adev2000@gmail.com> | 2017-05-07 17:21:30 +0200 |
---|---|---|
committer | adev <adev2000@gmail.com> | 2017-06-04 11:38:29 +0200 |
commit | 2c3e148b0029a094431622feac79fafcd0d43fc8 (patch) | |
tree | f59d3d2088af87f3898b4c4de28639b70efbe4b4 /tests/Wallabag | |
parent | a687c8d915276eee0c0494156700f7d0c0606735 (diff) | |
download | wallabag-2c3e148b0029a094431622feac79fafcd0d43fc8.tar.gz wallabag-2c3e148b0029a094431622feac79fafcd0d43fc8.tar.zst wallabag-2c3e148b0029a094431622feac79fafcd0d43fc8.zip |
Displays an error with an annotation with a too long quote
Fix #2762
Diffstat (limited to 'tests/Wallabag')
-rw-r--r-- | tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php | 34 |
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 |