diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index 6bc7afa6..ccb72d23 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php | |||
@@ -203,6 +203,24 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
203 | $this->assertEquals(1, $content['user_id']); | 203 | $this->assertEquals(1, $content['user_id']); |
204 | } | 204 | } |
205 | 205 | ||
206 | public function testPostArchivedAndStarredEntryWithoutQuotes() | ||
207 | { | ||
208 | $this->client->request('POST', '/api/entries.json', array( | ||
209 | 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', | ||
210 | 'archive' => 0, | ||
211 | 'starred' => 1, | ||
212 | )); | ||
213 | |||
214 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
215 | |||
216 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
217 | |||
218 | $this->assertGreaterThan(0, $content['id']); | ||
219 | $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']); | ||
220 | $this->assertEquals(false, $content['is_archived']); | ||
221 | $this->assertEquals(true, $content['is_starred']); | ||
222 | } | ||
223 | |||
206 | public function testPatchEntry() | 224 | public function testPatchEntry() |
207 | { | 225 | { |
208 | $entry = $this->client->getContainer() | 226 | $entry = $this->client->getContainer() |
@@ -235,6 +253,37 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
235 | $this->assertEquals(1, $content['user_id']); | 253 | $this->assertEquals(1, $content['user_id']); |
236 | } | 254 | } |
237 | 255 | ||
256 | public function testPatchEntryWithoutQuotes() | ||
257 | { | ||
258 | $entry = $this->client->getContainer() | ||
259 | ->get('doctrine.orm.entity_manager') | ||
260 | ->getRepository('WallabagCoreBundle:Entry') | ||
261 | ->findOneByUser(1); | ||
262 | |||
263 | if (!$entry) { | ||
264 | $this->markTestSkipped('No content found in db.'); | ||
265 | } | ||
266 | |||
267 | // hydrate the tags relations | ||
268 | $nbTags = count($entry->getTags()); | ||
269 | |||
270 | $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array( | ||
271 | 'title' => 'New awesome title', | ||
272 | 'tags' => 'new tag '.uniqid(), | ||
273 | 'starred' => 1, | ||
274 | 'archive' => 0, | ||
275 | )); | ||
276 | |||
277 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
278 | |||
279 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
280 | |||
281 | $this->assertEquals($entry->getId(), $content['id']); | ||
282 | $this->assertEquals($entry->getUrl(), $content['url']); | ||
283 | $this->assertEquals('New awesome title', $content['title']); | ||
284 | $this->assertGreaterThan($nbTags, count($content['tags'])); | ||
285 | } | ||
286 | |||
238 | public function testGetTagsEntry() | 287 | public function testGetTagsEntry() |
239 | { | 288 | { |
240 | $entry = $this->client->getContainer() | 289 | $entry = $this->client->getContainer() |