]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
Don't redirect to the content page after deletion
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Tests / Controller / EntryControllerTest.php
index af62aee8d85f80fd2d1018a858cc14677583bf5e..9f585d85d722ecf13c89a5d6a287cccd9c0acbca 100644 (file)
@@ -3,6 +3,7 @@
 namespace Wallabag\CoreBundle\Tests\Controller;
 
 use Wallabag\CoreBundle\Tests\WallabagCoreTestCase;
+use Wallabag\CoreBundle\Entity\Entry;
 
 class EntryControllerTest extends WallabagCoreTestCase
 {
@@ -290,6 +291,51 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertEquals(404, $client->getResponse()->getStatusCode());
     }
 
+    /**
+     * It will create a new entry.
+     * Browse to it.
+     * Then remove it.
+     *
+     * And it'll check that user won't be redirected to the view page of the content when it had been removed
+     */
+    public function testViewAndDelete()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        // add a new content to be removed later
+        $user = $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagUserBundle:User')
+            ->findOneByUserName('admin');
+
+        $content = new Entry($user);
+        $content->setUrl('http://1.1.1.1/entry');
+        $content->setReadingTime(12);
+        $content->setDomainName('domain.io');
+        $content->setMimetype('text/html');
+        $content->setTitle('test title entry');
+        $content->setContent('This is my content /o/');
+        $content->setArchived(true);
+        $content->setLanguage('fr');
+
+        $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->persist($content);
+        $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->flush();
+
+        $client->request('GET', '/view/'.$content->getId());
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+        $client->request('GET', '/delete/'.$content->getId());
+        $this->assertEquals(302, $client->getResponse()->getStatusCode());
+
+        $client->followRedirect();
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+    }
+
     public function testViewOtherUserEntry()
     {
         $this->logInAs('admin');