diff options
author | Arne Hamann <kontakt+github@arne.email> | 2018-01-18 15:08:24 +0530 |
---|---|---|
committer | Arne Hamann <kontakt+github@arne.email> | 2019-05-28 10:01:56 +0200 |
commit | 2c5ebac458f899af190d2ef7bf8702624e700049 (patch) | |
tree | 31540390a12c3f423279db1566b5da3ef6429299 /apps/dav/tests/unit/CardDAV/CardDavBackendTest.php | |
parent | 633a1981428a1b94626ea6447c9ee305162c01dd (diff) | |
download | nextcloud-server-2c5ebac458f899af190d2ef7bf8702624e700049.tar.gz nextcloud-server-2c5ebac458f899af190d2ef7bf8702624e700049.zip |
Allow to search for real pattern in contacts
Added an option escape_like_param to allow wildcards
Signed-off-by: Arne Hamann <kontakt+github@arne.email>
Diffstat (limited to 'apps/dav/tests/unit/CardDAV/CardDavBackendTest.php')
-rw-r--r-- | apps/dav/tests/unit/CardDAV/CardDavBackendTest.php | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index 86c85a972e3..531f50e96c2 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -642,22 +642,27 @@ class CardDavBackendTest extends TestCase { * * @param string $pattern * @param array $properties + * @param array $options * @param array $expected */ - public function testSearch($pattern, $properties, $expected) { + public function testSearch($pattern, $properties, $options, $expected) { /** @var VCard $vCards */ $vCards = []; $vCards[0] = new VCard(); $vCards[0]->add(new Text($vCards[0], 'UID', 'uid')); $vCards[0]->add(new Text($vCards[0], 'FN', 'John Doe')); - $vCards[0]->add(new Text($vCards[0], 'CLOUD', 'john@owncloud.org')); + $vCards[0]->add(new Text($vCards[0], 'CLOUD', 'john@nextcloud.com')); $vCards[1] = new VCard(); $vCards[1]->add(new Text($vCards[1], 'UID', 'uid')); $vCards[1]->add(new Text($vCards[1], 'FN', 'John M. Doe')); + $vCards[2] = new VCard(); + $vCards[2]->add(new Text($vCards[2], 'UID', 'uid')); + $vCards[2]->add(new Text($vCards[2], 'FN', 'find without options')); + $vCards[2]->add(new Text($vCards[2], 'CLOUD', 'peter_pan@nextcloud.com')); $vCardIds = []; $query = $this->db->getQueryBuilder(); - for($i=0; $i<2; $i++) { + for($i=0; $i < 3; $i++) { $query->insert($this->dbCardsTable) ->values( [ @@ -690,7 +695,7 @@ class CardDavBackendTest extends TestCase { 'addressbookid' => $query->createNamedParameter(0), 'cardid' => $query->createNamedParameter($vCardIds[0]), 'name' => $query->createNamedParameter('CLOUD'), - 'value' => $query->createNamedParameter('John@owncloud.org'), + 'value' => $query->createNamedParameter('John@nextcloud.com'), 'preferred' => $query->createNamedParameter(0) ] ); @@ -706,8 +711,30 @@ class CardDavBackendTest extends TestCase { ] ); $query->execute(); + $query->insert($this->dbCardsPropertiesTable) + ->values( + [ + 'addressbookid' => $query->createNamedParameter(0), + 'cardid' => $query->createNamedParameter($vCardIds[2]), + 'name' => $query->createNamedParameter('FN'), + 'value' => $query->createNamedParameter('find without options'), + 'preferred' => $query->createNamedParameter(0) + ] + ); + $query->execute(); + $query->insert($this->dbCardsPropertiesTable) + ->values( + [ + 'addressbookid' => $query->createNamedParameter(0), + 'cardid' => $query->createNamedParameter($vCardIds[2]), + 'name' => $query->createNamedParameter('CLOUD'), + 'value' => $query->createNamedParameter('peter_pan@nextcloud.com'), + 'preferred' => $query->createNamedParameter(0) + ] + ); + $query->execute(); - $result = $this->backend->search(0, $pattern, $properties); + $result = $this->backend->search(0, $pattern, $properties, $options); // check result $this->assertSame(count($expected), count($result)); @@ -726,11 +753,13 @@ class CardDavBackendTest extends TestCase { public function dataTestSearch() { return [ - ['John', ['FN'], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]], - ['M. Doe', ['FN'], [['uri1', 'John M. Doe']]], - ['Do', ['FN'], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]], - 'check if duplicates are handled correctly' => ['John', ['FN', 'CLOUD'], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]], - 'case insensitive' => ['john', ['FN'], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]] + ['John', ['FN'], [], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]], + ['M. Doe', ['FN'], [], [['uri1', 'John M. Doe']]], + ['Do', ['FN'], [], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]], + 'check if duplicates are handled correctly' => ['John', ['FN', 'CLOUD'], [], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]], + 'case insensitive' => ['john', ['FN'], [], [['uri0', 'John Doe'], ['uri1', 'John M. Doe']]], + 'find "_" escaped' => ['_', ['CLOUD'], [], [['uri2', 'find without options']]], + 'find not empty ClOUD' => ['%_%', ['CLOUD'], ['escape_like_param'=>false], [['uri0', 'John Doe'], ['uri2', 'find without options']]], ]; } |