]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
Merge pull request #3168 from wallabag/instapaper-tags-import
[github/wallabag/wallabag.git] / tests / Wallabag / CoreBundle / Controller / TagControllerTest.php
index fa1a3539f4960d5d4b23d00222d404058f2ed12a..80611a87c2010549a31d6672fce7aaf7b654df1c 100644 (file)
@@ -46,7 +46,7 @@ class TagControllerTest extends WallabagCoreTestCase
             ->getRepository('WallabagCoreBundle:Entry')
             ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
 
-        $this->assertEquals(3, count($entry->getTags()));
+        $this->assertEquals(4, count($entry->getTags()));
 
         // tag already exists and already assigned
         $client->submit($form, $data);
@@ -57,7 +57,7 @@ class TagControllerTest extends WallabagCoreTestCase
             ->getRepository('WallabagCoreBundle:Entry')
             ->find($entry->getId());
 
-        $this->assertEquals(3, count($newEntry->getTags()));
+        $this->assertEquals(4, count($newEntry->getTags()));
 
         // tag already exists but still not assigned to this entry
         $data = [
@@ -72,7 +72,7 @@ class TagControllerTest extends WallabagCoreTestCase
             ->getRepository('WallabagCoreBundle:Entry')
             ->find($entry->getId());
 
-        $this->assertEquals(3, count($newEntry->getTags()));
+        $this->assertEquals(4, count($newEntry->getTags()));
     }
 
     public function testAddMultipleTagToEntry()
@@ -126,9 +126,19 @@ class TagControllerTest extends WallabagCoreTestCase
             ->getRepository('WallabagCoreBundle:Tag')
             ->findOneByEntryAndTagLabel($entry, $this->tagName);
 
+        // We make a first request to set an history and test redirection after tag deletion
+        $client->request('GET', '/view/'.$entry->getId());
+        $entryUri = $client->getRequest()->getUri();
         $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
 
         $this->assertEquals(302, $client->getResponse()->getStatusCode());
+        $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl());
+
+        // re-retrieve the entry to be sure to get fresh data from database (mostly for tags)
+        $entry = $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagCoreBundle:Entry')
+            ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
 
         $this->assertNotContains($this->tagName, $entry->getTags());