summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-26 18:19:14 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-27 12:10:06 +0100
commitc7abad65eaed44f0075c679d97934a9810666d45 (patch)
treee764f2ee2a190b7f60d1bf9e55907b52c91c22d9 /apps/dav
parent8f4ab55b4b5b57c2f46a9313c94f9f857a0fbaf7 (diff)
downloadnextcloud-server-c7abad65eaed44f0075c679d97934a9810666d45.tar.gz
nextcloud-server-c7abad65eaed44f0075c679d97934a9810666d45.zip
Fix sql to get shared addressbooks including unit tests
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/migration/addressbookadapter.php2
-rw-r--r--apps/dav/tests/unit/migration/addressbookadaptertest.php16
2 files changed, 17 insertions, 1 deletions
diff --git a/apps/dav/lib/migration/addressbookadapter.php b/apps/dav/lib/migration/addressbookadapter.php
index a86790d1f2a..ef7b00188fb 100644
--- a/apps/dav/lib/migration/addressbookadapter.php
+++ b/apps/dav/lib/migration/addressbookadapter.php
@@ -75,7 +75,7 @@ class AddressBookAdapter {
*/
public function getShares($addressBookId) {
$query = $this->dbConnection->getQueryBuilder();
- $shares = $query->select()->from('share')
+ $shares = $query->select('*')->from('share')
->where($query->expr()->eq('item_source', $query->createNamedParameter($addressBookId)))
->andWhere($query->expr()->eq('item_type', $query->expr()->literal('addressbook')))
->andWhere($query->expr()->in('share_type', [ $query->expr()->literal(0), $query->expr()->literal(1)]))
diff --git a/apps/dav/tests/unit/migration/addressbookadaptertest.php b/apps/dav/tests/unit/migration/addressbookadaptertest.php
index c011fcd13ff..e6e57049a93 100644
--- a/apps/dav/tests/unit/migration/addressbookadaptertest.php
+++ b/apps/dav/tests/unit/migration/addressbookadaptertest.php
@@ -91,6 +91,17 @@ class AddressbookAdapterTest extends TestCase {
'lastmodified' => $builder->createNamedParameter('112233'),
])
->execute();
+ $builder = $this->db->getQueryBuilder();
+ $builder->insert('share')
+ ->values([
+ 'share_type' => $builder->createNamedParameter(1),
+ 'share_with' => $builder->createNamedParameter('user01'),
+ 'uid_owner' => $builder->createNamedParameter('user02'),
+ 'item_type' => $builder->createNamedParameter('addressbook'),
+ 'item_source' => $builder->createNamedParameter(6666),
+ 'item_target' => $builder->createNamedParameter('Contacts (user02)'),
+ ])
+ ->execute();
// test the adapter
$this->adapter->foreachBook('test-user-666', function($row) {
@@ -108,6 +119,11 @@ class AddressbookAdapterTest extends TestCase {
});
$this->assertArrayHasKey('id', $this->cards[0]);
$this->assertEquals(6666, $this->cards[0]['addressbookid']);
+
+ // test getShares
+ $shares = $this->adapter->getShares(6666);
+ $this->assertEquals(1, count($shares));
+
}
}