mirror of
https://github.com/wallabag/wallabag.git
synced 2025-04-25 19:34:07 +00:00
Merge pull request #3103 from wallabag/api-delete-tag-query
Retrieve tag / tags value from query or request
This commit is contained in:
commit
e538c85ba7
2 changed files with 28 additions and 6 deletions
|
@ -44,7 +44,7 @@ class TagRestController extends WallabagRestController
|
||||||
public function deleteTagLabelAction(Request $request)
|
public function deleteTagLabelAction(Request $request)
|
||||||
{
|
{
|
||||||
$this->validateAuthentication();
|
$this->validateAuthentication();
|
||||||
$label = $request->request->get('tag', '');
|
$label = $request->get('tag', '');
|
||||||
|
|
||||||
$tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label);
|
$tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class TagRestController extends WallabagRestController
|
||||||
{
|
{
|
||||||
$this->validateAuthentication();
|
$this->validateAuthentication();
|
||||||
|
|
||||||
$tagsLabels = $request->request->get('tags', '');
|
$tagsLabels = $request->get('tags', '');
|
||||||
|
|
||||||
$tags = [];
|
$tags = [];
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,18 @@ class TagRestControllerTest extends WallabagApiTestCase
|
||||||
$this->assertNull($tag, $tagName.' was removed because it begun an orphan tag');
|
$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');
|
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
$entry = $this->client->getContainer()
|
$entry = $this->client->getContainer()
|
||||||
|
@ -73,7 +84,11 @@ class TagRestControllerTest extends WallabagApiTestCase
|
||||||
$em->persist($entry);
|
$em->persist($entry);
|
||||||
$em->flush();
|
$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());
|
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
@ -98,7 +113,10 @@ class TagRestControllerTest extends WallabagApiTestCase
|
||||||
$this->assertEquals(404, $this->client->getResponse()->getStatusCode());
|
$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');
|
$em = $this->client->getContainer()->get('doctrine.orm.entity_manager');
|
||||||
$entry = $this->client->getContainer()
|
$entry = $this->client->getContainer()
|
||||||
|
@ -122,7 +140,11 @@ class TagRestControllerTest extends WallabagApiTestCase
|
||||||
$em->persist($entry);
|
$em->persist($entry);
|
||||||
$em->flush();
|
$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());
|
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue