From 32f455c1317bf536aea63147d2c5074ae7425d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 18 Nov 2016 17:36:19 +0100 Subject: Added tests --- .../CoreBundle/Controller/EntryControllerTest.php | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 09cf01b8..b248b178 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -1018,4 +1018,71 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(7, $crawler->filter('div[class=entry]')); } + + public function testSearch() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + // Search on unread list + $crawler = $client->request('GET', '/unread/list'); + + $form = $crawler->filter('form[name=search]')->form(); + $data = [ + 'search_entry[term]' => 'title', + ]; + + $crawler = $client->submit($form, $data); + + $this->assertCount(4, $crawler->filter('div[class=entry]')); + + // Search on starred list + $crawler = $client->request('GET', '/starred/list'); + + $form = $crawler->filter('form[name=search]')->form(); + $data = [ + 'search_entry[term]' => 'title', + ]; + + $crawler = $client->submit($form, $data); + + $this->assertCount(1, $crawler->filter('div[class=entry]')); + + // Added new article to test on archive list + $crawler = $client->request('GET', '/new'); + $form = $crawler->filter('form[name=entry]')->form(); + $data = [ + 'entry[url]' => $this->url, + ]; + $client->submit($form, $data); + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); + $client->request('GET', '/archive/'.$content->getId()); + + $crawler = $client->request('GET', '/archive/list'); + + $form = $crawler->filter('form[name=search]')->form(); + $data = [ + 'search_entry[term]' => 'manège', + ]; + + $crawler = $client->submit($form, $data); + + $this->assertCount(1, $crawler->filter('div[class=entry]')); + $client->request('GET', '/delete/'.$content->getId()); + + // test on list of all articles + $crawler = $client->request('GET', '/all/list'); + + $form = $crawler->filter('form[name=search]')->form(); + $data = [ + 'search_entry[term]' => 'pocket', + ]; + + $crawler = $client->submit($form, $data); + + $this->assertCount(0, $crawler->filter('div[class=entry]')); + } } -- cgit v1.2.3 From 995c204428dd6be04d2bff1d5e17f3e95268f44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 18 Nov 2016 19:21:31 +0100 Subject: Added shortcut --- tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index b248b178..952e8957 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -1034,7 +1034,7 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->submit($form, $data); - $this->assertCount(4, $crawler->filter('div[class=entry]')); + $this->assertCount(5, $crawler->filter('div[class=entry]')); // Search on starred list $crawler = $client->request('GET', '/starred/list'); @@ -1078,7 +1078,7 @@ class EntryControllerTest extends WallabagCoreTestCase $form = $crawler->filter('form[name=search]')->form(); $data = [ - 'search_entry[term]' => 'pocket', + 'search_entry[term]' => 'wxcvbnqsdf', // a string not available in the database ]; $crawler = $client->submit($form, $data); -- cgit v1.2.3