1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

API return an error with empty quote

Fix #4137
This commit is contained in:
adev 2019-10-27 18:51:32 +01:00 committed by Jeremy Benoist
parent a406434701
commit 8197f08266
No known key found for this signature in database
GPG key ID: 84290C294324D304
4 changed files with 33 additions and 1 deletions

View file

@ -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
*/