aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-10-07 23:31:53 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-10-07 23:31:53 +0200
commitac8cf632bb3a225c1b69d16e714ff60a2e988c89 (patch)
tree6789145b0518564d943399fd1b37830089cc4376 /tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
parent3049afe190d125e4861059b6bbad7c6fbea6f1bb (diff)
downloadwallabag-ac8cf632bb3a225c1b69d16e714ff60a2e988c89.tar.gz
wallabag-ac8cf632bb3a225c1b69d16e714ff60a2e988c89.tar.zst
wallabag-ac8cf632bb3a225c1b69d16e714ff60a2e988c89.zip
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!)
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php27
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index d7bf03ba..9b03a519 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -341,22 +341,23 @@ class EntryControllerTest extends WallabagCoreTestCase
341 $this->logInAs('admin'); 341 $this->logInAs('admin');
342 $client = $this->getClient(); 342 $client = $this->getClient();
343 343
344 $content = $client->getContainer() 344 $em = $client->getContainer()
345 ->get('doctrine.orm.entity_manager') 345 ->get('doctrine.orm.entity_manager');
346
347 $content = $em
346 ->getRepository('WallabagCoreBundle:Entry') 348 ->getRepository('WallabagCoreBundle:Entry')
347 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); 349 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
348 350
349 // empty content 351 // empty content
350 $content->setContent(''); 352 $content->setContent('');
351 $client->getContainer()->get('doctrine.orm.entity_manager')->persist($content); 353 $em->persist($content);
352 $client->getContainer()->get('doctrine.orm.entity_manager')->flush(); 354 $em->flush();
353 355
354 $client->request('GET', '/reload/'.$content->getId()); 356 $client->request('GET', '/reload/'.$content->getId());
355 357
356 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 358 $this->assertEquals(302, $client->getResponse()->getStatusCode());
357 359
358 $content = $client->getContainer() 360 $content = $em
359 ->get('doctrine.orm.entity_manager')
360 ->getRepository('WallabagCoreBundle:Entry') 361 ->getRepository('WallabagCoreBundle:Entry')
361 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); 362 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
362 363
@@ -486,9 +487,11 @@ class EntryControllerTest extends WallabagCoreTestCase
486 $this->logInAs('admin'); 487 $this->logInAs('admin');
487 $client = $this->getClient(); 488 $client = $this->getClient();
488 489
490 $em = $client->getContainer()
491 ->get('doctrine.orm.entity_manager');
492
489 // add a new content to be removed later 493 // add a new content to be removed later
490 $user = $client->getContainer() 494 $user = $em
491 ->get('doctrine.orm.entity_manager')
492 ->getRepository('WallabagUserBundle:User') 495 ->getRepository('WallabagUserBundle:User')
493 ->findOneByUserName('admin'); 496 ->findOneByUserName('admin');
494 497
@@ -502,12 +505,8 @@ class EntryControllerTest extends WallabagCoreTestCase
502 $content->setArchived(true); 505 $content->setArchived(true);
503 $content->setLanguage('fr'); 506 $content->setLanguage('fr');
504 507
505 $client->getContainer() 508 $em->persist($content);
506 ->get('doctrine.orm.entity_manager') 509 $em->flush();
507 ->persist($content);
508 $client->getContainer()
509 ->get('doctrine.orm.entity_manager')
510 ->flush();
511 510
512 $client->request('GET', '/view/'.$content->getId()); 511 $client->request('GET', '/view/'.$content->getId());
513 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 512 $this->assertEquals(200, $client->getResponse()->getStatusCode());