Ensure orphan tag are remove in API

When the association between a tag and an entry is removed, if the tag doesn’t have other entries, we can remove it.

Also add more tests for that part and ensure TagControllerTest is isolated from the rest of the test suite (finally!)
This commit is contained in:
Jeremy Benoist
2016-10-07 23:31:53 +02:00
parent 3049afe190
commit ac8cf632bb
6 changed files with 78 additions and 27 deletions

View File

@ -561,6 +561,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase
*/
public function testDeleteUserTag($tag)
{
$tagName = $tag['label'];
$this->client->request('DELETE', '/api/tags/'.$tag['id'].'.json');
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
@ -577,6 +579,13 @@ class WallabagRestControllerTest extends WallabagApiTestCase
->findAllByTagId($this->user->getId(), $tag['id']);
$this->assertCount(0, $entries);
$tag = $this->client->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository('WallabagCoreBundle:Tag')
->findOneByLabel($tagName);
$this->assertNull($tag, $tagName.' was removed because it begun an orphan tag');
}
public function testDeleteTagByLabel()