]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
manage assets through npm
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Tests / Controller / EntryControllerTest.php
index df4c34cd8340481de88657d43ef6426d51635abe..5ce893c14fef9073b129d6e9b6da25931b3068ff 100644 (file)
@@ -163,7 +163,7 @@ class EntryControllerTest extends WallabagCoreTestCase
     /**
      * This test will require an internet connection.
      */
-    public function testPostNewThatWillBeTaggued()
+    public function testPostNewThatWillBeTagged()
     {
         $this->logInAs('admin');
         $client = $this->getClient();
@@ -181,8 +181,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $client->submit($form, $data);
 
         $this->assertEquals(302, $client->getResponse()->getStatusCode());
-
-        $client->followRedirect();
+        $this->assertContains('/', $client->getResponse()->getTargetUrl());
 
         $em = $client->getContainer()
             ->get('doctrine.orm.entity_manager');
@@ -196,6 +195,35 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $em->remove($entry);
         $em->flush();
+
+        // and now re-submit it to test the cascade persistence for tags after entry removal
+        // related https://github.com/wallabag/wallabag/issues/2121
+        $crawler = $client->request('GET', '/new');
+
+        $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+        $form = $crawler->filter('form[name=entry]')->form();
+
+        $data = [
+            'entry[url]' => $url = 'https://github.com/wallabag/wallabag/tree/master',
+        ];
+
+        $client->submit($form, $data);
+
+        $this->assertEquals(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('/', $client->getResponse()->getTargetUrl());
+
+        $entry = $em
+            ->getRepository('WallabagCoreBundle:Entry')
+            ->findOneByUrl($url);
+
+        $tags = $entry->getTags();
+
+        $this->assertCount(1, $tags);
+        $this->assertEquals('wallabag', $tags[0]->getLabel());
+
+        $em->remove($entry);
+        $em->flush();
     }
 
     public function testArchive()
@@ -471,6 +499,24 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertCount(1, $crawler->filter('div[class=entry]'));
     }
 
+    public function testFilterOnUnreadStatus()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/all/list');
+
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+
+        $data = [
+            'entry_filter[isUnread]' => true,
+        ];
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(4, $crawler->filter('div[class=entry]'));
+    }
+
     public function testFilterOnCreationDate()
     {
         $this->logInAs('admin');