aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2016-11-19 20:42:27 +0100
committerGitHub <noreply@github.com>2016-11-19 20:42:27 +0100
commit6f85bed294d6dd9f2dd9c945544074cbde38e191 (patch)
tree1ac2c526e54ddaf1678184f93d4e10a7a015349c /tests
parent27dce581caba158a8ffffa5bc30648a21f47da12 (diff)
parent995c204428dd6be04d2bff1d5e17f3e95268f44d (diff)
downloadwallabag-6f85bed294d6dd9f2dd9c945544074cbde38e191.tar.gz
wallabag-6f85bed294d6dd9f2dd9c945544074cbde38e191.tar.zst
wallabag-6f85bed294d6dd9f2dd9c945544074cbde38e191.zip
Merge pull request #2543 from wallabag/search-engine
Added a simple search engine
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 09cf01b8..952e8957 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -1018,4 +1018,71 @@ class EntryControllerTest extends WallabagCoreTestCase
1018 1018
1019 $this->assertCount(7, $crawler->filter('div[class=entry]')); 1019 $this->assertCount(7, $crawler->filter('div[class=entry]'));
1020 } 1020 }
1021
1022 public function testSearch()
1023 {
1024 $this->logInAs('admin');
1025 $client = $this->getClient();
1026
1027 // Search on unread list
1028 $crawler = $client->request('GET', '/unread/list');
1029
1030 $form = $crawler->filter('form[name=search]')->form();
1031 $data = [
1032 'search_entry[term]' => 'title',
1033 ];
1034
1035 $crawler = $client->submit($form, $data);
1036
1037 $this->assertCount(5, $crawler->filter('div[class=entry]'));
1038
1039 // Search on starred list
1040 $crawler = $client->request('GET', '/starred/list');
1041
1042 $form = $crawler->filter('form[name=search]')->form();
1043 $data = [
1044 'search_entry[term]' => 'title',
1045 ];
1046
1047 $crawler = $client->submit($form, $data);
1048
1049 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1050
1051 // Added new article to test on archive list
1052 $crawler = $client->request('GET', '/new');
1053 $form = $crawler->filter('form[name=entry]')->form();
1054 $data = [
1055 'entry[url]' => $this->url,
1056 ];
1057 $client->submit($form, $data);
1058 $content = $client->getContainer()
1059 ->get('doctrine.orm.entity_manager')
1060 ->getRepository('WallabagCoreBundle:Entry')
1061 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
1062 $client->request('GET', '/archive/'.$content->getId());
1063
1064 $crawler = $client->request('GET', '/archive/list');
1065
1066 $form = $crawler->filter('form[name=search]')->form();
1067 $data = [
1068 'search_entry[term]' => 'manège',
1069 ];
1070
1071 $crawler = $client->submit($form, $data);
1072
1073 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1074 $client->request('GET', '/delete/'.$content->getId());
1075
1076 // test on list of all articles
1077 $crawler = $client->request('GET', '/all/list');
1078
1079 $form = $crawler->filter('form[name=search]')->form();
1080 $data = [
1081 'search_entry[term]' => 'wxcvbnqsdf', // a string not available in the database
1082 ];
1083
1084 $crawler = $client->submit($form, $data);
1085
1086 $this->assertCount(0, $crawler->filter('div[class=entry]'));
1087 }
1021} 1088}