aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authoradev <adev2000@gmail.com>2019-10-27 18:51:32 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-11-27 14:38:35 +0100
commit8197f08266256f55767666b90be47f585c7a6d28 (patch)
tree528d86ecd9fca0903c6747480474d251a19c817d /tests
parenta4064347015e169b309153f214e2bb5ec17fde21 (diff)
downloadwallabag-8197f08266256f55767666b90be47f585c7a6d28.tar.gz
wallabag-8197f08266256f55767666b90be47f585c7a6d28.tar.zst
wallabag-8197f08266256f55767666b90be47f585c7a6d28.zip
API return an error with empty quote
Fix #4137
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php30
1 files changed, 30 insertions, 0 deletions
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
107 $this->assertSame('my annotation', $annotation->getText()); 107 $this->assertSame('my annotation', $annotation->getText());
108 } 108 }
109 109
110 public function testCouldNotSetAnnotationWithoutQuote()
111 {
112 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
113
114 /** @var Entry $entry */
115 $entry = $em
116 ->getRepository('WallabagCoreBundle:Entry')
117 ->findOneByUsernameAndNotArchived('admin');
118
119 $headers = ['CONTENT_TYPE' => 'application/json'];
120 $content = json_encode([
121 'text' => 'my annotation',
122 'quote' => null,
123 'ranges' => [
124 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
125 ],
126 ]);
127 $this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content);
128
129 $this->assertSame(400, $this->client->getResponse()->getStatusCode());
130
131 $content = json_decode($this->client->getResponse()->getContent(), true);
132
133 $this->assertCount(
134 1,
135 $content['errors']['children']['quote']['errors'],
136 'The quote field should contains an error'
137 );
138 }
139
110 /** 140 /**
111 * @dataProvider dataForEachAnnotations 141 * @dataProvider dataForEachAnnotations
112 */ 142 */