X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FAnnotationBundle%2FController%2FAnnotationControllerTest.php;h=8f87ccf3f40b9a23b2ab467db05391e570f64794;hb=2c3e148b0029a094431622feac79fafcd0d43fc8;hp=81f9e9ec5cfc313e53a71551631750caf503ca06;hpb=20da238413d1c6cc360d58a13df33eb199fa5f05;p=github%2Fwallabag%2Fwallabag.git 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 $content = json_encode([ 'text' => 'my annotation', 'quote' => 'my quote', - 'ranges' => ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31], + 'ranges' => [ + ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31] + ], ]); $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content); @@ -106,6 +108,36 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase $this->assertEquals('my annotation', $annotation->getText()); } + /** + * @dataProvider dataForEachAnnotations + */ + public function testSetAnnotationWithQuoteTooLong($prefixUrl) + { + $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->assertEquals(400, $this->client->getResponse()->getStatusCode()); + } + /** * Test editing an existing annotation. *