X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FTests%2FController%2FEntryControllerTest.php;h=5f0a6076388535821460c9c5eb83f0561c11d032;hb=e1779760999f676cb7a74a201bc2a389959702d4;hp=0bd18c4421a3d75766208d6151a3028df9e2ca7b;hpb=925d8ab316127be8dc0cea2515cfc1d419b1d5e8;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 0bd18c44..5f0a6076 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -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,7 +252,7 @@ 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); @@ -260,11 +260,38 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(1, $crawler->filter('div[class=entry]')); } - public function testPaginationWithFilter() + 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]' => '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(); @@ -280,5 +307,57 @@ class EntryControllerTest extends WallabagCoreTestCase $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(1, $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(1, $crawler->filter('div[class=entry]')); } }