mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Case insensitive search in contacts - fixes #813, owncloud/mail#197
This commit is contained in:
parent
bd807389ca
commit
9a1b5f31a2
@ -123,7 +123,7 @@ SQL;
|
||||
foreach ($searchProperties as $property) {
|
||||
$params[] = $property;
|
||||
$params[] = '%' . $pattern . '%';
|
||||
$query .= '(`name` = ? AND `value` LIKE ?) OR ';
|
||||
$query .= '(`name` = ? AND `value` ILIKE ?) OR ';
|
||||
}
|
||||
$query = substr($query, 0, strlen($query) - 4);
|
||||
$query .= ')';
|
||||
|
@ -58,7 +58,7 @@ class AddressBookProviderTest extends TestCase {
|
||||
$card->add('FN', 'Jan Janssens');
|
||||
$id = $this->ab->addChild($card);
|
||||
Utils\Properties::updateIndex($id, $card);
|
||||
$this->ab->deleteChild($id);
|
||||
$this->contactIds[] = $id;
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
@ -69,13 +69,25 @@ class AddressBookProviderTest extends TestCase {
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testSearch() {
|
||||
$result = $this->provider->search('',array('FN'), array());
|
||||
/**
|
||||
* @dataProvider providesSearchData
|
||||
*/
|
||||
public function testSearch($expected, $pattern) {
|
||||
$result = $this->provider->search($pattern, ['FN'], array());
|
||||
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertEquals('Max Mustermann', $result[0]['FN']);
|
||||
$this->assertEquals(count($expected), count($result));
|
||||
$result = array_map(function($c){
|
||||
return $c['FN'];
|
||||
}, $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function providesSearchData() {
|
||||
return [
|
||||
'empty pattern' => [['Max Mustermann', 'Jan Janssens'], ''],
|
||||
'case insensitive' => [['Max Mustermann'], 'max'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user