1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Retrieve tag / tags value from query or request

It allows to request to delete a tag using query string instead of body parameter (which seems to be the standard).
Instead of breaking the previous behavior, I used a generic way to retrieve parameter (which looks into request attributes, query parameters and request parameters)
This commit is contained in:
Jeremy Benoist 2017-05-09 23:15:25 +02:00
parent 0eb8220204
commit 1594a79fc5
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
2 changed files with 28 additions and 6 deletions

View file

@ -54,7 +54,18 @@ class TagRestControllerTest extends WallabagApiTestCase
$this->assertNull($tag, $tagName.' was removed because it begun an orphan tag');
}
public function testDeleteTagByLabel()
public function dataForDeletingTagByLabel()
{
return [
'by_query' => [true],
'by_body' => [false],
];
}
/**
* @dataProvider dataForDeletingTagByLabel
*/
public function testDeleteTagByLabel($useQueryString)
{
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
$entry = $this->client->getContainer()
@ -73,7 +84,11 @@ class TagRestControllerTest extends WallabagApiTestCase
$em->persist($entry);
$em->flush();
$this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]);
if ($useQueryString) {
$this->client->request('DELETE', '/api/tag/label.json?tag='.$tag->getLabel());
} else {
$this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]);
}
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -98,7 +113,10 @@ class TagRestControllerTest extends WallabagApiTestCase
$this->assertEquals(404, $this->client->getResponse()->getStatusCode());
}
public function testDeleteTagsByLabel()
/**
* @dataProvider dataForDeletingTagByLabel
*/
public function testDeleteTagsByLabel($useQueryString)
{
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
$entry = $this->client->getContainer()
@ -122,7 +140,11 @@ class TagRestControllerTest extends WallabagApiTestCase
$em->persist($entry);
$em->flush();
$this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]);
if ($useQueryString) {
$this->client->request('DELETE', '/api/tags/label.json?tags='.$tag->getLabel().','.$tag2->getLabel());
} else {
$this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]);
}
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());