X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FAnnotationBundle%2FController%2FAnnotationControllerTest.php;h=3c94382cef6ce6acee0cc655ac4f0045c7ff4bca;hb=873f6b8e03079d11fab541aa5b0bc6f8fe2d645e;hp=cee0b8473dae5c6a766b33ed3e0bd8127493bfc6;hpb=64a8781e453c40ff144d03405abe2dc1ccfacbe0;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php index cee0b847..3c94382c 100644 --- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php +++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php @@ -11,7 +11,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase /** * This data provider allow to tests annotation from the : * - API POV (when user use the api to manage annotations) - * - and User POV (when user use the web interface - using javascript - to manage annotations) + * - and User POV (when user use the web interface - using javascript - to manage annotations). */ public function dataForEachAnnotations() { @@ -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. *