diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2019-11-27 14:04:11 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2019-11-27 14:46:27 +0100 |
commit | 6a0d49ab7a8ac9e00f9df34b37b6d3e1ab40f2a9 (patch) | |
tree | 911b52bb36245c0b97674129410784379e33082e | |
parent | 86c1751186ab71a54e33092cd9fb83c33917f619 (diff) | |
download | wallabag-6a0d49ab7a8ac9e00f9df34b37b6d3e1ab40f2a9.tar.gz wallabag-6a0d49ab7a8ac9e00f9df34b37b6d3e1ab40f2a9.tar.zst wallabag-6a0d49ab7a8ac9e00f9df34b37b6d3e1ab40f2a9.zip |
Fix tests
-rw-r--r-- | tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php index 74e9ba8f..260edd77 100644 --- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php +++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php | |||
@@ -107,7 +107,7 @@ 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() | 110 | public function testAllowEmptyQuote() |
111 | { | 111 | { |
112 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | 112 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
113 | 113 | ||
@@ -126,15 +126,42 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase | |||
126 | ]); | 126 | ]); |
127 | $this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content); | 127 | $this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content); |
128 | 128 | ||
129 | $this->assertSame(400, $this->client->getResponse()->getStatusCode()); | 129 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); |
130 | |||
131 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
132 | |||
133 | $this->assertSame('Big boss', $content['user']); | ||
134 | $this->assertSame('v1.0', $content['annotator_schema_version']); | ||
135 | $this->assertSame('my annotation', $content['text']); | ||
136 | $this->assertSame('', $content['quote']); | ||
137 | } | ||
138 | |||
139 | public function testAllowOmmittedQuote() | ||
140 | { | ||
141 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | ||
142 | |||
143 | /** @var Entry $entry */ | ||
144 | $entry = $em | ||
145 | ->getRepository('WallabagCoreBundle:Entry') | ||
146 | ->findOneByUsernameAndNotArchived('admin'); | ||
147 | |||
148 | $headers = ['CONTENT_TYPE' => 'application/json']; | ||
149 | $content = json_encode([ | ||
150 | 'text' => 'my new annotation', | ||
151 | 'ranges' => [ | ||
152 | ['start' => '', 'startOffset' => 25, 'end' => '', 'endOffset' => 32], | ||
153 | ], | ||
154 | ]); | ||
155 | $this->client->request('POST', '/api/annotations/' . $entry->getId() . '.json', [], [], $headers, $content); | ||
156 | |||
157 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
130 | 158 | ||
131 | $content = json_decode($this->client->getResponse()->getContent(), true); | 159 | $content = json_decode($this->client->getResponse()->getContent(), true); |
132 | 160 | ||
133 | $this->assertCount( | 161 | $this->assertSame('Big boss', $content['user']); |
134 | 1, | 162 | $this->assertSame('v1.0', $content['annotator_schema_version']); |
135 | $content['errors']['children']['quote']['errors'], | 163 | $this->assertSame('my new annotation', $content['text']); |
136 | 'The quote field should contains an error' | 164 | $this->assertSame('', $content['quote']); |
137 | ); | ||
138 | } | 165 | } |
139 | 166 | ||
140 | /** | 167 | /** |