]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
Fixed unit tests
[github/wallabag/wallabag.git] / tests / Wallabag / CoreBundle / Controller / EntryControllerTest.php
index 4ac4548b2624b2f75035e525a4f4e0fb5ec577f9..b5655f71762a8dcefd46dab3caa9a962e592826a 100644 (file)
@@ -6,12 +6,14 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
 use Wallabag\CoreBundle\Entity\Config;
 use Wallabag\CoreBundle\Entity\Entry;
 use Wallabag\CoreBundle\Entity\SiteCredential;
+use Wallabag\CoreBundle\Entity\Tag;
+use Wallabag\CoreBundle\Helper\ContentProxy;
 
 class EntryControllerTest extends WallabagCoreTestCase
 {
-    const An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'http://www.lemonde.fr/judo/article/2017/11/11/judo-la-decima-de-teddy-riner_5213605_1556020.html';
+    const AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'https://www.lemonde.fr/judo/article/2017/11/11/judo-la-decima-de-teddy-riner_5213605_1556020.html';
     public $downloadImagesEnabled = false;
-    public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html';
+    public $url = 'https://www.lemonde.fr/pixels/article/2019/06/18/ce-qu-il-faut-savoir-sur-le-libra-la-cryptomonnaie-de-facebook_5477887_4408996.html';
 
     /**
      * @after
@@ -88,19 +90,18 @@ class EntryControllerTest extends WallabagCoreTestCase
     public function testPostNewViaBookmarklet()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $crawler = $client->request('GET', '/');
 
-        $this->assertCount(4, $crawler->filter('div[class=entry]'));
+        $this->assertCount(4, $crawler->filter('li.entry'));
 
         // Good URL
         $client->request('GET', '/bookmarklet', ['url' => $this->url]);
         $this->assertSame(302, $client->getResponse()->getStatusCode());
         $client->followRedirect();
         $crawler = $client->request('GET', '/');
-        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('li.entry'));
 
         $em = $client->getContainer()
             ->get('doctrine.orm.entity_manager');
@@ -162,17 +163,15 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
         $this->assertSame($this->url, $content->getUrl());
-        $this->assertContains('Google', $content->getTitle());
+        $this->assertContains('la cryptomonnaie de Facebook', $content->getTitle());
         $this->assertSame('fr', $content->getLanguage());
-        $this->assertSame('2015-03-28 11:43:19', $content->getPublishedAt()->format('Y-m-d H:i:s'));
-        $this->assertSame('Morgane Tual', $author[0]);
-        $this->assertArrayHasKey('x-varnish1', $content->getHeaders());
+        $this->assertArrayHasKey('x-frame-options', $content->getHeaders());
         $client->getContainer()->get('craue_config')->set('store_article_headers', 0);
     }
 
     public function testPostWithMultipleAuthors()
     {
-        $url = 'http://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768';
+        $url = 'https://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768';
         $this->logInAs('admin');
         $client = $this->getClient();
 
@@ -195,11 +194,12 @@ class EntryControllerTest extends WallabagCoreTestCase
             ->getRepository('WallabagCoreBundle:Entry')
             ->findByUrlAndUserId($url, $this->getLoggedInUserId());
 
+        $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
         $authors = $content->getPublishedBy();
         $this->assertSame('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
         $this->assertSame('fr', $content->getLanguage());
-        $this->assertSame('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
-        $this->assertSame('Frédéric Autran, correspondant à New York', $authors[1]);
+        $this->assertSame('Raphaël Balenieri', $authors[0]);
+        $this->assertSame('Frédéric Autran', $authors[1]);
     }
 
     public function testPostNewOkUrlExist()
@@ -234,7 +234,45 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->logInAs('admin');
         $client = $this->getClient();
 
-        $url = 'http://www.aritylabs.com/post/106091708292/des-contr%C3%B4leurs-optionnels-gr%C3%A2ce-%C3%A0-constmissing';
+        $url = 'https://www.aritylabs.com/post/106091708292/des-contr%C3%B4leurs-optionnels-gr%C3%A2ce-%C3%A0-constmissing';
+
+        $crawler = $client->request('GET', '/new');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $form = $crawler->filter('form[name=entry]')->form();
+
+        $data = [
+            'entry[url]' => $url,
+        ];
+
+        $client->submit($form, $data);
+
+        $crawler = $client->request('GET', '/new');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $form = $crawler->filter('form[name=entry]')->form();
+
+        $data = [
+            'entry[url]' => $url,
+        ];
+
+        $client->submit($form, $data);
+
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('/view/', $client->getResponse()->getTargetUrl());
+    }
+
+    /**
+     * This test will require an internet connection.
+     */
+    public function testPostNewOkUrlExistWithRedirection()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $url = 'https://wllbg.org/test-redirect/c51c';
 
         $crawler = $client->request('GET', '/new');
 
@@ -474,7 +512,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $this->assertSame(200, $client->getResponse()->getStatusCode());
 
-        $form = $crawler->filter('button[type=submit]')->form();
+        $form = $crawler->filter('button[id=entry_save]')->form();
 
         $data = [
             'entry[title]' => 'My updated title hehe :)',
@@ -489,7 +527,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
         $this->assertContains('My updated title hehe :)', $title[0]);
-        $this->assertGreaterThan(1, $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']));
+        $this->assertGreaterThan(1, $stats = $crawler->filter('div[class="tools grey-text"] ul[class=stats] li a[class="tool grey-text"]')->extract(['_text']));
         $this->assertContains('example.io', trim($stats[1]));
     }
 
@@ -507,7 +545,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $this->assertSame(200, $client->getResponse()->getStatusCode());
 
-        $form = $crawler->filter('button[type=submit]')->form();
+        $form = $crawler->filter('button[id=entry_save]')->form();
 
         $data = [
             'entry[title]' => 'My updated title hehe :)',
@@ -520,9 +558,12 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->followRedirect();
 
-        $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
+        $title = $crawler->filter('div[id=article] h1')->extract(['_text']);
+        $this->assertGreaterThan(1, $title);
         $this->assertContains('My updated title hehe :)', $title[0]);
-        $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])));
+
+        $stats = $crawler->filter('div[class="tools grey-text"] ul[class=stats] li a[class="tool grey-text"]')->extract(['_text']);
+        $this->assertCount(1, $stats);
         $this->assertNotContains('example.io', trim($stats[0]));
     }
 
@@ -618,7 +659,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content->setMimetype('text/html');
         $content->setTitle('test title entry');
         $content->setContent('This is my content /o/');
-        $content->setArchived(true);
+        $content->updateArchived(true);
         $content->setLanguage('fr');
 
         $em->persist($content);
@@ -652,7 +693,6 @@ class EntryControllerTest extends WallabagCoreTestCase
     public function testFilterOnReadingTime()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
         $entry = new Entry($this->getLoggedInUser());
         $entry->setUrl($this->url);
@@ -671,7 +711,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
     }
 
     public function testFilterOnReadingTimeWithNegativeValue()
@@ -691,17 +731,16 @@ class EntryControllerTest extends WallabagCoreTestCase
         $crawler = $client->submit($form, $data);
 
         // forcing negative value results in no entry displayed
-        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+        $this->assertCount(0, $crawler->filter('li.entry'));
     }
 
     public function testFilterOnReadingTimeOnlyUpper()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $crawler = $client->request('GET', '/all/list');
-        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('li.entry'));
 
         $entry = new Entry($this->getLoggedInUser());
         $entry->setUrl($this->url);
@@ -710,7 +749,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->getEntityManager()->flush();
 
         $crawler = $client->request('GET', '/all/list');
-        $this->assertCount(6, $crawler->filter('div[class=entry]'));
+        $this->assertCount(6, $crawler->filter('li.entry'));
 
         $form = $crawler->filter('button[id=submit-filter]')->form();
 
@@ -720,13 +759,12 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('li.entry'));
     }
 
     public function testFilterOnReadingTimeOnlyLower()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $crawler = $client->request('GET', '/unread/list');
@@ -739,7 +777,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+        $this->assertCount(0, $crawler->filter('li.entry'));
 
         $entry = new Entry($this->getLoggedInUser());
         $entry->setUrl($this->url);
@@ -748,13 +786,12 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->getEntityManager()->flush();
 
         $crawler = $client->submit($form, $data);
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
     }
 
     public function testFilterOnUnreadStatus()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $crawler = $client->request('GET', '/all/list');
@@ -767,55 +804,66 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(4, $crawler->filter('div[class=entry]'));
+        $this->assertCount(4, $crawler->filter('li.entry'));
 
         $entry = new Entry($this->getLoggedInUser());
         $entry->setUrl($this->url);
-        $entry->setArchived(false);
+        $entry->updateArchived(false);
         $this->getEntityManager()->persist($entry);
         $this->getEntityManager()->flush();
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('li.entry'));
     }
 
     public function testFilterOnCreationDate()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
+        $em = $this->getEntityManager();
+
+        $today = new \DateTimeImmutable();
+        $tomorrow = $today->add(new \DateInterval('P1D'));
+        $yesterday = $today->sub(new \DateInterval('P1D'));
+
+        $entry = new Entry($this->getLoggedInUser());
+        $entry->setUrl('http://0.0.0.0/testFilterOnCreationDate');
+        $entry->setCreatedAt($yesterday);
+        $em->persist($entry);
+        $em->flush();
+
         $crawler = $client->request('GET', '/unread/list');
 
         $form = $crawler->filter('button[id=submit-filter]')->form();
 
         $data = [
-            'entry_filter[createdAt][left_date]' => date('d/m/Y'),
-            'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')),
+            'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'),
+            'entry_filter[createdAt][right_date]' => $tomorrow->format('Y-m-d'),
         ];
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('li.entry'));
 
         $data = [
-            'entry_filter[createdAt][left_date]' => date('d/m/Y'),
-            'entry_filter[createdAt][right_date]' => date('d/m/Y'),
+            'entry_filter[createdAt][left_date]' => $today->format('Y-m-d'),
+            'entry_filter[createdAt][right_date]' => $today->format('Y-m-d'),
         ];
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('li.entry'));
 
         $data = [
-            'entry_filter[createdAt][left_date]' => '01/01/1970',
-            'entry_filter[createdAt][right_date]' => '01/01/1970',
+            'entry_filter[createdAt][left_date]' => '1970-01-01',
+            'entry_filter[createdAt][right_date]' => '1970-01-01',
         ];
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+        $this->assertCount(0, $crawler->filter('li.entry'));
     }
 
     public function testPaginationWithFilter()
@@ -850,7 +898,6 @@ class EntryControllerTest extends WallabagCoreTestCase
     public function testFilterOnDomainName()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $crawler = $client->request('GET', '/unread/list');
@@ -860,7 +907,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         ];
 
         $crawler = $client->submit($form, $data);
-        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('li.entry'));
 
         $crawler = $client->request('GET', '/unread/list');
         $form = $crawler->filter('button[id=submit-filter]')->form();
@@ -869,7 +916,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         ];
 
         $crawler = $client->submit($form, $data);
-        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('li.entry'));
 
         $form = $crawler->filter('button[id=submit-filter]')->form();
         $data = [
@@ -877,13 +924,12 @@ class EntryControllerTest extends WallabagCoreTestCase
         ];
 
         $crawler = $client->submit($form, $data);
-        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+        $this->assertCount(0, $crawler->filter('li.entry'));
     }
 
     public function testFilterOnStatus()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $crawler = $client->request('GET', '/unread/list');
@@ -892,20 +938,19 @@ class EntryControllerTest extends WallabagCoreTestCase
         $form['entry_filter[isStarred]']->untick();
 
         $crawler = $client->submit($form);
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
 
         $form = $crawler->filter('button[id=submit-filter]')->form();
         $form['entry_filter[isArchived]']->untick();
         $form['entry_filter[isStarred]']->tick();
 
         $crawler = $client->submit($form);
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
     }
 
     public function testFilterOnIsPublic()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $crawler = $client->request('GET', '/unread/list');
@@ -913,13 +958,12 @@ class EntryControllerTest extends WallabagCoreTestCase
         $form['entry_filter[isPublic]']->tick();
 
         $crawler = $client->submit($form);
-        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+        $this->assertCount(0, $crawler->filter('li.entry'));
     }
 
     public function testPreviewPictureFilter()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $crawler = $client->request('GET', '/unread/list');
@@ -927,13 +971,12 @@ class EntryControllerTest extends WallabagCoreTestCase
         $form['entry_filter[previewPicture]']->tick();
 
         $crawler = $client->submit($form);
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
     }
 
     public function testFilterOnLanguage()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $entry = new Entry($this->getLoggedInUser());
@@ -949,7 +992,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         ];
 
         $crawler = $client->submit($form, $data);
-        $this->assertCount(3, $crawler->filter('div[class=entry]'));
+        $this->assertCount(3, $crawler->filter('li.entry'));
 
         $form = $crawler->filter('button[id=submit-filter]')->form();
         $data = [
@@ -957,7 +1000,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         ];
 
         $crawler = $client->submit($form, $data);
-        $this->assertCount(2, $crawler->filter('div[class=entry]'));
+        $this->assertCount(2, $crawler->filter('li.entry'));
     }
 
     public function testShareEntryPublicly()
@@ -982,8 +1025,13 @@ class EntryControllerTest extends WallabagCoreTestCase
         $client->request('GET', '/share/' . $content->getId());
         $this->assertSame(302, $client->getResponse()->getStatusCode());
 
-        // follow link with uid
-        $crawler = $client->followRedirect();
+        $shareUrl = $client->getResponse()->getTargetUrl();
+
+        // use a new client to have a fresh empty session (instead of a logged one from the previous client)
+        $client->restart();
+
+        $client->request('GET', $shareUrl);
+
         $this->assertSame(200, $client->getResponse()->getStatusCode());
         $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
         $this->assertContains('public', $client->getResponse()->headers->get('cache-control'));
@@ -999,9 +1047,6 @@ class EntryControllerTest extends WallabagCoreTestCase
         $client->request('GET', '/share/' . $content->getUid());
         $this->assertSame(404, $client->getResponse()->getStatusCode());
 
-        $client->request('GET', '/view/' . $content->getId());
-        $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control'));
-
         // removing the share
         $client->request('GET', '/share/delete/' . $content->getId());
         $this->assertSame(302, $client->getResponse()->getStatusCode());
@@ -1017,7 +1062,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->logInAs('admin');
         $client = $this->getClient();
 
-        $url = self::An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE;
+        $url = self::AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE;
         $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
 
         $crawler = $client->request('GET', '/new');
@@ -1059,7 +1104,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->logInAs('admin');
         $client = $this->getClient();
 
-        $url = self::An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE;
+        $url = self::AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE;
         $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
 
         $crawler = $client->request('GET', '/new');
@@ -1137,11 +1182,10 @@ class EntryControllerTest extends WallabagCoreTestCase
     public function testFilterOnHttpStatus()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $entry = new Entry($this->getLoggedInUser());
-        $entry->setUrl('http://www.lemonde.fr/incorrect-url/');
+        $entry->setUrl('https://www.lemonde.fr/incorrect-url/');
         $entry->setHttpStatus(404);
         $this->getEntityManager()->persist($entry);
 
@@ -1156,7 +1200,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
 
         $entry = new Entry($this->getLoggedInUser());
         $entry->setUrl($this->url);
@@ -1179,7 +1223,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(2, $crawler->filter('div[class=entry]'));
+        $this->assertCount(2, $crawler->filter('li.entry'));
 
         $crawler = $client->request('GET', '/all/list');
         $form = $crawler->filter('button[id=submit-filter]')->form();
@@ -1190,13 +1234,12 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(8, $crawler->filter('div[class=entry]'));
+        $this->assertCount(8, $crawler->filter('li.entry'));
     }
 
     public function testSearch()
     {
         $this->logInAs('admin');
-        $this->useTheme('baggy');
         $client = $this->getClient();
 
         $entry = new Entry($this->getLoggedInUser());
@@ -1215,7 +1258,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(4, $crawler->filter('div[class=entry]'));
+        $this->assertCount(4, $crawler->filter('li.entry'));
 
         // Search on starred list
         $crawler = $client->request('GET', '/starred/list');
@@ -1234,7 +1277,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
 
         $crawler = $client->request('GET', '/archive/list');
 
@@ -1242,7 +1285,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $entry = new Entry($this->getLoggedInUser());
         $entry->setUrl('http://0.0.0.0/foo/baz/qux');
         $entry->setTitle('Le manège');
-        $entry->setArchived(true);
+        $entry->updateArchived(true);
         $this->getEntityManager()->persist($entry);
         $this->getEntityManager()->flush();
 
@@ -1253,7 +1296,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
         $client->request('GET', '/delete/' . $entry->getId());
 
         // test on list of all articles
@@ -1266,13 +1309,13 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+        $this->assertCount(0, $crawler->filter('li.entry'));
 
         // test url search on list of all articles
         $entry = new Entry($this->getLoggedInUser());
         $entry->setUrl('http://domain/qux');
         $entry->setTitle('Le manège');
-        $entry->setArchived(true);
+        $entry->updateArchived(true);
         $this->getEntityManager()->persist($entry);
         $this->getEntityManager()->flush();
 
@@ -1285,7 +1328,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
 
         // same as previous test but for case-sensitivity
         $crawler = $client->request('GET', '/all/list');
@@ -1297,7 +1340,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $crawler = $client->submit($form, $data);
 
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('li.entry'));
     }
 
     public function dataForLanguage()
@@ -1307,32 +1350,24 @@ class EntryControllerTest extends WallabagCoreTestCase
                 'https://www.pravda.ru/world/09-06-2017/1337283-qatar-0/',
                 'ru',
             ],
-            'fr-FR' => [
-                'https://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/',
-                'fr_FR',
+            'fr' => [
+                'https://fr.wikipedia.org/wiki/Wallabag',
+                'fr',
             ],
             'de' => [
-                'http://www.bild.de/politik/ausland/theresa-may/wahlbeben-grossbritannien-analyse-52108924.bild.html',
+                'https://www.bild.de/politik/ausland/theresa-may/wahlbeben-grossbritannien-analyse-52108924.bild.html',
                 'de',
             ],
             'it' => [
-                'http://www.ansa.it/sito/notizie/mondo/europa/2017/06/08/voto-gb-seggi-aperti-misure-sicurezza-rafforzate_0cb71f7f-e23b-4d5f-95ca-bc12296419f0.html',
+                'https://www.ansa.it/sito/notizie/mondo/europa/2017/06/08/voto-gb-seggi-aperti-misure-sicurezza-rafforzate_0cb71f7f-e23b-4d5f-95ca-bc12296419f0.html',
                 'it',
             ],
             'zh_CN' => [
                 'http://www.hao123.com/shequ?__noscript__-=1',
                 'zh_CN',
             ],
-            'de_AT' => [
-                'https://buy.garmin.com/de-AT/AT/catalog/product/compareResult.ep?compareProduct=112885&compareProduct=36728',
-                'de_AT',
-            ],
-            'ru_RU' => [
-                'http://netler.ru/ikt/windows-error-reporting.htm',
-                'ru_RU',
-            ],
             'pt_BR' => [
-                'http://precodoscombustiveis.com.br/postos/cidade/4121/pr/maringa',
+                'https://politica.estadao.com.br/noticias/eleicoes,campanha-catatonica,70002491983',
                 'pt_BR',
             ],
             'fucked_list_of_languages' => [
@@ -1340,7 +1375,7 @@ class EntryControllerTest extends WallabagCoreTestCase
                 null,
             ],
             'es-ES' => [
-                'https://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google/',
+                'https://www.20minutos.es/noticia/3360685/0/gobierno-sanchez-primero-historia-mas-mujeres-que-hombres/',
                 'es_ES',
             ],
         ];
@@ -1429,4 +1464,97 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $client->getContainer()->get('craue_config')->set('restricted_access', 0);
     }
+
+    public function testPostEntryWhenFetchFails()
+    {
+        $url = 'http://example.com/papers/email_tracking.pdf';
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $container = $client->getContainer();
+        $contentProxy = $this->getMockBuilder(ContentProxy::class)
+            ->disableOriginalConstructor()
+            ->setMethods(['updateEntry'])
+            ->getMock();
+        $contentProxy->expects($this->any())
+            ->method('updateEntry')
+            ->willThrowException(new \Exception('Test Fetch content fails'));
+
+        $crawler = $client->request('GET', '/new');
+
+        $this->assertSame(200, $client->getResponse()->getStatusCode());
+
+        $form = $crawler->filter('form[name=entry]')->form();
+
+        $data = [
+            'entry[url]' => $url,
+        ];
+
+        /**
+         * We generate a new client to be able to use Mock ContentProxy
+         * Also we reinject the cookie from the previous client to keep the
+         * session.
+         */
+        $cookie = $client->getCookieJar()->all();
+        $client = $this->getNewClient();
+        $client->getCookieJar()->set($cookie[0]);
+        $client->getContainer()->set('wallabag_core.content_proxy', $contentProxy);
+        $client->submit($form, $data);
+
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+
+        $content = $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagCoreBundle:Entry')
+            ->findByUrlAndUserId($url, $this->getLoggedInUserId());
+
+        $authors = $content->getPublishedBy();
+        $this->assertSame('email_tracking.pdf', $content->getTitle());
+        $this->assertSame('example.com', $content->getDomainName());
+    }
+
+    public function testEntryDeleteTagLink()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $em = $client->getContainer()->get('doctrine.orm.entity_manager');
+        $entry = $em->getRepository('WallabagCoreBundle:Entry')->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
+        $tag = $entry->getTags()[0];
+
+        $crawler = $client->request('GET', '/view/' . $entry->getId());
+
+        // As long as the deletion link of a tag is following
+        // a link to the tag view, we take the second one to retrieve
+        // the deletion link of the first tag
+        $link = $crawler->filter('body div#article div.tools ul.tags li.chip a')->extract('href')[1];
+
+        $this->assertSame(sprintf('/remove-tag/%s/%s', $entry->getId(), $tag->getId()), $link);
+    }
+
+    public function testRandom()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $client->request('GET', '/unread/random');
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Unread random');
+
+        $client->request('GET', '/starred/random');
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Starred random');
+
+        $client->request('GET', '/archive/random');
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Archive random');
+
+        $client->request('GET', '/untagged/random');
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Untagged random');
+
+        $client->request('GET', '/all/random');
+        $this->assertSame(302, $client->getResponse()->getStatusCode());
+        $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'All random');
+    }
 }