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

@ -341,22 +341,23 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->logInAs('admin');
$client = $this->getClient();
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
$em = $client->getContainer()
->get('doctrine.orm.entity_manager');
$content = $em
->getRepository('WallabagCoreBundle:Entry')
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
// empty content
$content->setContent('');
$client->getContainer()->get('doctrine.orm.entity_manager')->persist($content);
$client->getContainer()->get('doctrine.orm.entity_manager')->flush();
$em->persist($content);
$em->flush();
$client->request('GET', '/reload/'.$content->getId());
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$content = $client->getContainer()
->get('doctrine.orm.entity_manager')
$content = $em
->getRepository('WallabagCoreBundle:Entry')
->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
@ -486,9 +487,11 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->logInAs('admin');
$client = $this->getClient();
$em = $client->getContainer()
->get('doctrine.orm.entity_manager');
// add a new content to be removed later
$user = $client->getContainer()
->get('doctrine.orm.entity_manager')
$user = $em
->getRepository('WallabagUserBundle:User')
->findOneByUserName('admin');
@ -502,12 +505,8 @@ class EntryControllerTest extends WallabagCoreTestCase
$content->setArchived(true);
$content->setLanguage('fr');
$client->getContainer()
->get('doctrine.orm.entity_manager')
->persist($content);
$client->getContainer()
->get('doctrine.orm.entity_manager')
->flush();
$em->persist($content);
$em->flush();
$client->request('GET', '/view/'.$content->getId());
$this->assertEquals(200, $client->getResponse()->getStatusCode());