X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FAnnotationBundle%2FController%2FAnnotationControllerTest.php;fp=tests%2FWallabag%2FAnnotationBundle%2FController%2FAnnotationControllerTest.php;h=74e9ba8fdf1aef00aec0c221bdf7819c937452b6;hb=8197f08266256f55767666b90be47f585c7a6d28;hp=2c46e0a1deff5f7c1b870af3a76a792674d684c8;hpb=a4064347015e169b309153f214e2bb5ec17fde21;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php index 2c46e0a1..74e9ba8f 100644 --- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php +++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php @@ -107,6 +107,36 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase $this->assertSame('my annotation', $annotation->getText()); } + public function testCouldNotSetAnnotationWithoutQuote() + { + $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); + + /** @var Entry $entry */ + $entry = $em + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUsernameAndNotArchived('admin'); + + $headers = ['CONTENT_TYPE' => 'application/json']; + $content = json_encode([ + 'text' => 'my annotation', + 'quote' => null, + 'ranges' => [ + ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31], + ], + ]); + $this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content); + + $this->assertSame(400, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertCount( + 1, + $content['errors']['children']['quote']['errors'], + 'The quote field should contains an error' + ); + } + /** * @dataProvider dataForEachAnnotations */