aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2019-02-17 15:30:42 +0100
committerKevin Decherf <kevin@kdecherf.com>2019-02-20 15:57:50 +0100
commit508302042f96ce771a36f0114acb0b3a89c18880 (patch)
treef599aafa60d81b1dbf473fc7d586abc84a18d1cf /tests/Wallabag
parent4e0ed3368d2bdc2fa0d330e58902e792a896be06 (diff)
downloadwallabag-508302042f96ce771a36f0114acb0b3a89c18880.tar.gz
wallabag-508302042f96ce771a36f0114acb0b3a89c18880.tar.zst
wallabag-508302042f96ce771a36f0114acb0b3a89c18880.zip
EntryRestController: add support of expect parameter to delete action
The expect parameter enables an application to request the whole entry or only the id when requesting its deletion. `expects` defaults to `entry` to prevent any API breakage. Fixes #3711 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index ddeca4c0..1489a472 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -431,18 +431,29 @@ class EntryRestControllerTest extends WallabagApiTestCase
431 $this->assertSame(404, $this->client->getResponse()->getStatusCode()); 431 $this->assertSame(404, $this->client->getResponse()->getStatusCode());
432 } 432 }
433 433
434 $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json'); 434 public function testDeleteEntryExpectId()
435 {
436 $em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
437 $entry = new Entry($em->getReference(User::class, 1));
438 $entry->setUrl('http://0.0.0.0/test-delete-entry-id');
439 $em->persist($entry);
440 $em->flush();
441
442 $em->clear();
443
444 $id = $entry->getId();
445
446 $this->client->request('DELETE', '/api/entries/' . $id . '.json?expect=id');
435 447
436 $this->assertSame(200, $this->client->getResponse()->getStatusCode()); 448 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
437 449
438 $content = json_decode($this->client->getResponse()->getContent(), true); 450 $content = json_decode($this->client->getResponse()->getContent(), true);
439 451
440 $this->assertSame($entry->getTitle(), $content['title']); 452 $this->assertSame($id, $content['id']);
441 $this->assertSame($entry->getUrl(), $content['url']); 453 $this->assertArrayNotHasKey('url', $content);
442 $this->assertSame($entry->getId(), $content['id']);
443 454
444 // We'll try to delete this entry again 455 // We'll try to delete this entry again
445 $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json'); 456 $this->client->request('DELETE', '/api/entries/' . $id . '.json');
446 457
447 $this->assertSame(404, $this->client->getResponse()->getStatusCode()); 458 $this->assertSame(404, $this->client->getResponse()->getStatusCode());
448 } 459 }