diff options
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 2a1d2e15..ddeca4c0 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -400,14 +400,36 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
400 | 400 | ||
401 | public function testDeleteEntry() | 401 | public function testDeleteEntry() |
402 | { | 402 | { |
403 | $entry = $this->client->getContainer() | 403 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
404 | ->get('doctrine.orm.entity_manager') | 404 | $entry = new Entry($em->getReference(User::class, 1)); |
405 | ->getRepository('WallabagCoreBundle:Entry') | 405 | $entry->setUrl('http://0.0.0.0/test-delete-entry'); |
406 | ->findOneByUser(1, ['id' => 'asc']); | 406 | $entry->setTitle('Test delete entry'); |
407 | $em->persist($entry); | ||
408 | $em->flush(); | ||
407 | 409 | ||
408 | if (!$entry) { | 410 | $em->clear(); |
409 | $this->markTestSkipped('No content found in db.'); | 411 | |
410 | } | 412 | $e = [ |
413 | 'title' => $entry->getTitle(), | ||
414 | 'url' => $entry->getUrl(), | ||
415 | 'id' => $entry->getId(), | ||
416 | ]; | ||
417 | |||
418 | $this->client->request('DELETE', '/api/entries/' . $e['id'] . '.json'); | ||
419 | |||
420 | $this->assertSame(200, $this->client->getResponse()->getStatusCode()); | ||
421 | |||
422 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
423 | |||
424 | $this->assertSame($e['title'], $content['title']); | ||
425 | $this->assertSame($e['url'], $content['url']); | ||
426 | $this->assertSame($e['id'], $content['id']); | ||
427 | |||
428 | // We'll try to delete this entry again | ||
429 | $this->client->request('DELETE', '/api/entries/' . $e['id'] . '.json'); | ||
430 | |||
431 | $this->assertSame(404, $this->client->getResponse()->getStatusCode()); | ||
432 | } | ||
411 | 433 | ||
412 | $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json'); | 434 | $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json'); |
413 | 435 | ||