]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
Changed default database name
[github/wallabag/wallabag.git] / tests / Wallabag / CoreBundle / Controller / EntryControllerTest.php
index d26a56f8a9fac6384872482c4bb15b274b3b3545..116e5f323bbfa330154fc8b42efb8e1abe59f23f 100644 (file)
@@ -8,8 +8,24 @@ use Wallabag\CoreBundle\Entity\Entry;
 
 class EntryControllerTest extends WallabagCoreTestCase
 {
+    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';
 
+    /**
+     * @after
+     *
+     * Ensure download_images_enabled is disabled after each script
+     */
+    public function tearDownImagesEnabled()
+    {
+        if ($this->downloadImagesEnabled) {
+            $client = static::createClient();
+            $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
+
+            $this->downloadImagesEnabled = false;
+        }
+    }
+
     public function testLogin()
     {
         $client = $this->getClient();
@@ -142,6 +158,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertContains('Google', $content->getTitle());
         $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
         $this->assertEquals('Morgane Tual', $author[0]);
+        $this->assertArrayHasKey('x-varnish1', $content->getHeaders());
     }
 
     public function testPostWithMultipleAuthors()
@@ -270,7 +287,7 @@ class EntryControllerTest extends WallabagCoreTestCase
             ->findOneByUrl($url);
         $tags = $entry->getTags();
 
-        $this->assertCount(1, $tags);
+        $this->assertCount(2, $tags);
         $this->assertEquals('wallabag', $tags[0]->getLabel());
 
         $em->remove($entry);
@@ -299,8 +316,8 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $tags = $entry->getTags();
 
-        $this->assertCount(1, $tags);
-        $this->assertEquals('wallabag', $tags[0]->getLabel());
+        $this->assertCount(2, $tags);
+        $this->assertEquals('wallabag', $tags[1]->getLabel());
 
         $em->remove($entry);
         $em->flush();
@@ -626,6 +643,26 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertCount(1, $crawler->filter('div[class=entry]'));
     }
 
+    public function testFilterOnReadingTimeWithNegativeValue()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/unread/list');
+
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+
+        $data = [
+            'entry_filter[readingTime][right_number]' => -22,
+            'entry_filter[readingTime][left_number]' => -22,
+        ];
+
+        $crawler = $client->submit($form, $data);
+
+        // forcing negative value results in no entry displayed
+        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+    }
+
     public function testFilterOnReadingTimeOnlyUpper()
     {
         $this->logInAs('admin');
@@ -884,6 +921,7 @@ class EntryControllerTest extends WallabagCoreTestCase
 
     public function testNewEntryWithDownloadImagesEnabled()
     {
+        $this->downloadImagesEnabled = true;
         $this->logInAs('admin');
         $client = $this->getClient();
 
@@ -914,7 +952,8 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
         $this->assertEquals($url, $entry->getUrl());
         $this->assertContains('Perpignan', $entry->getTitle());
-        $this->assertContains('/d9bc0fcd.jpeg', $entry->getContent());
+        // instead of checking for the filename (which might change) check that the image is now local
+        $this->assertContains('http://v2.wallabag.org/assets/images/', $entry->getContent());
 
         $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
     }
@@ -924,6 +963,7 @@ class EntryControllerTest extends WallabagCoreTestCase
      */
     public function testRemoveEntryWithDownloadImagesEnabled()
     {
+        $this->downloadImagesEnabled = true;
         $this->logInAs('admin');
         $client = $this->getClient();