]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
Merge pull request #1417 from wallabag/v2-display-picture
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Tests / Controller / EntryControllerTest.php
index 24848eb2f15e0ff198bc57ab278749d89c635d12..77b57884679d0dbd0651ed37ce27ae9ba799908c 100644 (file)
@@ -209,7 +209,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneById(1);
+            ->findOneByIsStarred(false);
 
         $client->request('GET', '/delete/'.$content->getId());
 
@@ -241,7 +241,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertEquals(403, $client->getResponse()->getStatusCode());
     }
 
-    public function testFilterOnUnreadeView()
+    public function testFilterOnReadingTime()
     {
         $this->logInAs('admin');
         $client = $this->getClient();
@@ -252,11 +252,134 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $data = array(
             'entry_filter[readingTime][right_number]' => 11,
-            'entry_filter[readingTime][left_number]' => 11
+            'entry_filter[readingTime][left_number]' => 11,
+        );
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+    }
+
+    public function testFilterOnCreationDate()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/unread/list');
+
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+
+        $data = array(
+            'entry_filter[createdAt][left_date]' => date('d/m/Y'),
+            'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')),
+        );
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+
+        $data = array(
+            'entry_filter[createdAt][left_date]' => date('d/m/Y'),
+            'entry_filter[createdAt][right_date]' => date('d/m/Y'),
+        );
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(5, $crawler->filter('div[class=entry]'));
+
+        $data = array(
+            'entry_filter[createdAt][left_date]' => '01/01/1970',
+            'entry_filter[createdAt][right_date]' => '01/01/1970',
+        );
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+    }
+
+    public function testPaginationWithFilter()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+        $crawler = $client->request('GET', '/config');
+
+        $form = $crawler->filter('button[id=config_save]')->form();
+
+        $data = array(
+            'config[items_per_page]' => '1',
+        );
+
+        $client->submit($form, $data);
+
+        $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D=';
+
+        $crawler = $client->request('GET', 'unread/list'.$parameters);
+
+        $this->assertContains($parameters, $client->getResponse()->getContent());
+
+        // reset pagination
+        $crawler = $client->request('GET', '/config');
+        $form = $crawler->filter('button[id=config_save]')->form();
+        $data = array(
+            'config[items_per_page]' => '12',
+        );
+        $client->submit($form, $data);
+    }
+
+    public function testFilterOnDomainName()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/unread/list');
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+        $data = array(
+            'entry_filter[domainName]' => 'monde',
         );
 
         $crawler = $client->submit($form, $data);
+        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+        $data = array(
+            'entry_filter[domainName]' => 'wallabag',
+        );
+
+        $crawler = $client->submit($form, $data);
+        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+    }
 
+    public function testFilterOnStatus()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/unread/list');
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+        $form['entry_filter[isArchived]']->tick();
+        $form['entry_filter[isStarred]']->untick();
+
+        $crawler = $client->submit($form);
+        $this->assertCount(2, $crawler->filter('div[class=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(2, $crawler->filter('div[class=entry]'));
+    }
+
+    public function testPreviewPictureFilter()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/unread/list');
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+        $form['entry_filter[previewPicture]']->tick();
+
+        $crawler = $client->submit($form);
         $this->assertCount(1, $crawler->filter('div[class=entry]'));
     }
 }