test(CardDav): name all search data cases accurately

Signed-off-by: Josh <josh.t.richards@gmail.com>
This commit is contained in:
Josh 2026-05-15 16:10:50 -04:00 committed by GitHub
parent 1e833cea34
commit 92cd85a28b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -768,6 +768,88 @@ class CardDavBackendTest extends TestCase {
$this->assertSame(count($expected), count($found));
}
public static function dataTestSearch(): array {
return [
'basic FN search' => [
'John',
['FN'],
[],
[
['uri0', 'John Doe'],
['uri1', 'John M. Doe'],
],
],
'partial FN match' => [
'M. Doe',
['FN'],
[],
[
['uri1', 'John M. Doe'],
],
],
'substring FN match' => [
'Do',
['FN'],
[],
[
['uri0', 'John Doe'],
['uri1', 'John M. Doe'],
],
],
'duplicate matches across FN and CLOUD return one result per card' => [
'John',
['FN', 'CLOUD'],
[],
[
['uri0', 'John Doe'],
['uri1', 'John M. Doe'],
],
],
'case-insensitive search' => [
'john',
['FN'],
[],
[
['uri0', 'John Doe'],
['uri1', 'John M. Doe'],
],
],
'limit 1 returns first matching card' => [
'john',
['FN'],
['limit' => 1],
[
['uri0', 'John Doe'],
],
],
'limit 1 with offset 1 returns second matching card' => [
'john',
['FN'],
['limit' => 1, 'offset' => 1],
[
['uri1', 'John M. Doe'],
],
],
'underscore is escaped by default in CLOUD search' => [
'_',
['CLOUD'],
[],
[
['uri2', 'find without options'],
],
],
'wildcards are honored when escape_like_param is false' => [
'%_%',
['CLOUD'],
['escape_like_param' => false],
[
['uri0', 'John Doe'],
['uri2', 'find without options'],
],
],
];
}
public static function dataTestSearch(): array {
return [
['John', ['FN'], [], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]],