]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
CS
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Tests / Controller / EntryControllerTest.php
index 24848eb2f15e0ff198bc57ab278749d89c635d12..86a19f616e351490be7e640ada6233e79d8afdf9 100644 (file)
@@ -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,83 @@ 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(4, $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());
+    }
+
+    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]'));
+    }
 }