+ $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
+
+ if ('annotations' === $prefixUrl) {
+ $this->logInAs('admin');
+ }
+
+ /** @var Entry $entry */
+ $entry = $em
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByUsernameAndNotArchived('admin');
+
+ $longQuote = str_repeat('a', 10001);
+ $headers = ['CONTENT_TYPE' => 'application/json'];
+ $content = json_encode([
+ 'text' => 'my annotation',
+ 'quote' => $longQuote,
+ 'ranges' => [
+ ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
+ ],
+ ]);
+ $this->client->request('POST', $prefixUrl . '/' . $entry->getId() . '.json', [], [], $headers, $content);
+
+ $this->assertSame(400, $this->client->getResponse()->getStatusCode());
+ }
+
+ /**
+ * Test editing an existing annotation.
+ *
+ * @dataProvider dataForEachAnnotations
+ */
+ public function testEditAnnotation($prefixUrl)
+ {
+ $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
+
+ $user = $em
+ ->getRepository('WallabagUserBundle:User')
+ ->findOneByUserName('admin');
+ $entry = $em
+ ->getRepository('WallabagCoreBundle:Entry')
+ ->findOneByUsernameAndNotArchived('admin');
+
+ $annotation = new Annotation($user);
+ $annotation->setEntry($entry);
+ $annotation->setText('This is my annotation /o/');
+ $annotation->setQuote('my quote');