diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-07-19 18:03:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-19 18:03:37 +0200 |
commit | a085a88205ccf833c347c1b0a5021ca2ee8db484 (patch) | |
tree | ec1389dea6c027f3c90513576cad579ba0c37892 /apps/dav/tests | |
parent | c00d6f4eac9075e651fbef791f4e7c7157cad709 (diff) | |
parent | 2c5ebac458f899af190d2ef7bf8702624e700049 (diff) | |
download | nextcloud-server-a085a88205ccf833c347c1b0a5021ca2ee8db484.tar.gz nextcloud-server-a085a88205ccf833c347c1b0a5021ca2ee8db484.zip |
Merge pull request #14954 from tacruc/searchPatterns
Allow to search for real pattern in contacts
Diffstat (limited to 'apps/dav/tests')
-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']]], ]; } |