diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2017-02-19 21:52:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-19 21:52:35 +0100 |
commit | bba94d74585e465f541e20c8aba2e95695435cc4 (patch) | |
tree | 0738a9498415b0da1eafd170bf24fb0819033224 | |
parent | 2b8f274b8a1e46ff37fd11dd99abeef2cd455d5b (diff) | |
parent | eac09b48b08f5cbc0d219da000026c38a265583a (diff) | |
download | wallabag-bba94d74585e465f541e20c8aba2e95695435cc4.tar.gz wallabag-bba94d74585e465f541e20c8aba2e95695435cc4.tar.zst wallabag-bba94d74585e465f541e20c8aba2e95695435cc4.zip |
Merge pull request #2832 from Kdecherf/search-domain
Search by term: extend to entries url
-rw-r--r-- | src/Wallabag/CoreBundle/Repository/EntryRepository.php | 3 | ||||
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 24 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index b9532fa2..4071301d 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php | |||
@@ -106,8 +106,9 @@ class EntryRepository extends EntityRepository | |||
106 | $qb->andWhere('e.isArchived = true'); | 106 | $qb->andWhere('e.isArchived = true'); |
107 | } | 107 | } |
108 | 108 | ||
109 | // We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive | ||
109 | $qb | 110 | $qb |
110 | ->andWhere('e.content LIKE :term OR e.title LIKE :term')->setParameter('term', '%'.$term.'%') | 111 | ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%'.$term.'%') |
111 | ->leftJoin('e.tags', 't') | 112 | ->leftJoin('e.tags', 't') |
112 | ->groupBy('e.id'); | 113 | ->groupBy('e.id'); |
113 | 114 | ||
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 06ed2db6..3eb6d47f 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -1093,5 +1093,29 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
1093 | $crawler = $client->submit($form, $data); | 1093 | $crawler = $client->submit($form, $data); |
1094 | 1094 | ||
1095 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | 1095 | $this->assertCount(0, $crawler->filter('div[class=entry]')); |
1096 | |||
1097 | // test url search on list of all articles | ||
1098 | $crawler = $client->request('GET', '/all/list'); | ||
1099 | |||
1100 | $form = $crawler->filter('form[name=search]')->form(); | ||
1101 | $data = [ | ||
1102 | 'search_entry[term]' => 'domain', // the search will match an entry with 'domain' in its url | ||
1103 | ]; | ||
1104 | |||
1105 | $crawler = $client->submit($form, $data); | ||
1106 | |||
1107 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | ||
1108 | |||
1109 | // same as previous test but for case-sensitivity | ||
1110 | $crawler = $client->request('GET', '/all/list'); | ||
1111 | |||
1112 | $form = $crawler->filter('form[name=search]')->form(); | ||
1113 | $data = [ | ||
1114 | 'search_entry[term]' => 'doMain', // the search will match an entry with 'domain' in its url | ||
1115 | ]; | ||
1116 | |||
1117 | $crawler = $client->submit($form, $data); | ||
1118 | |||
1119 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | ||
1096 | } | 1120 | } |
1097 | } | 1121 | } |