Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search by term: extend to entries url #2832

Merged
merged 1 commit into from Feb 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Wallabag/CoreBundle/Repository/EntryRepository.php
Expand Up @@ -106,8 +106,9 @@ public function getBuilderForSearchByUser($userId, $term, $currentRoute)
$qb->andWhere('e.isArchived = true');
}

// We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive
$qb
->andWhere('e.content LIKE :term OR e.title LIKE :term')->setParameter('term', '%'.$term.'%')
->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%'.$term.'%')
->leftJoin('e.tags', 't')
->groupBy('e.id');

Expand Down
24 changes: 24 additions & 0 deletions tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
Expand Up @@ -1093,5 +1093,29 @@ public function testSearch()
$crawler = $client->submit($form, $data);

$this->assertCount(0, $crawler->filter('div[class=entry]'));

// test url search on list of all articles
$crawler = $client->request('GET', '/all/list');

$form = $crawler->filter('form[name=search]')->form();
$data = [
'search_entry[term]' => 'domain', // the search will match an entry with 'domain' in its url
];

$crawler = $client->submit($form, $data);

$this->assertCount(1, $crawler->filter('div[class=entry]'));

// same as previous test but for case-sensitivity
$crawler = $client->request('GET', '/all/list');

$form = $crawler->filter('form[name=search]')->form();
$data = [
'search_entry[term]' => 'doMain', // the search will match an entry with 'domain' in its url
];

$crawler = $client->submit($form, $data);

$this->assertCount(1, $crawler->filter('div[class=entry]'));
}
}