summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Douma <rullzer@users.noreply.github.com>2016-04-12 09:46:25 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-12 09:46:25 +0200
commit495a964ca2e5384f6e6a97a4c9cab73a02928634 (patch)
tree6389fd51c66801b80cd58282b92dd261f0789078 /tests
parent4ddf9f98f1189192acfeb5ba9046a4bc0b52dbe5 (diff)
downloadnextcloud-server-495a964ca2e5384f6e6a97a4c9cab73a02928634.tar.gz
nextcloud-server-495a964ca2e5384f6e6a97a4c9cab73a02928634.zip
Migrate post_groupDelete hook to share manager (#23841)
The hook now calls the share manager that will call the responsible shareProvider to do the proper cleanup. * Unit tests added Again nothing should change it is just to cleanup old code
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share20/defaultshareprovidertest.php94
1 files changed, 94 insertions, 0 deletions
diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php
index d8b594519b6..6acc81ccee5 100644
--- a/tests/lib/share20/defaultshareprovidertest.php
+++ b/tests/lib/share20/defaultshareprovidertest.php
@@ -1999,4 +1999,98 @@ class DefaultShareProviderTest extends \Test\TestCase {
$cursor->closeCursor();
$this->assertCount($groupShareDeleted ? 0 : 1, $data);
}
+
+ public function dataGroupDeleted() {
+ return [
+ [
+ [
+ 'type' => \OCP\Share::SHARE_TYPE_USER,
+ 'recipient' => 'user',
+ 'children' => []
+ ], 'group', false
+ ],
+ [
+ [
+ 'type' => \OCP\Share::SHARE_TYPE_USER,
+ 'recipient' => 'user',
+ 'children' => []
+ ], 'user', false
+ ],
+ [
+ [
+ 'type' => \OCP\Share::SHARE_TYPE_LINK,
+ 'recipient' => 'user',
+ 'children' => []
+ ], 'group', false
+ ],
+ [
+ [
+ 'type' => \OCP\Share::SHARE_TYPE_GROUP,
+ 'recipient' => 'group1',
+ 'children' => [
+ 'foo',
+ 'bar'
+ ]
+ ], 'group2', false
+ ],
+ [
+ [
+ 'type' => \OCP\Share::SHARE_TYPE_GROUP,
+ 'recipient' => 'group1',
+ 'children' => [
+ 'foo',
+ 'bar'
+ ]
+ ], 'group1', true
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider dataGroupDeleted
+ *
+ * @param $shares
+ * @param $groupToDelete
+ * @param $shouldBeDeleted
+ */
+ public function testGroupDeleted($shares, $groupToDelete, $shouldBeDeleted) {
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->insert('share')
+ ->setValue('share_type', $qb->createNamedParameter($shares['type']))
+ ->setValue('uid_owner', $qb->createNamedParameter('owner'))
+ ->setValue('uid_initiator', $qb->createNamedParameter('initiator'))
+ ->setValue('share_with', $qb->createNamedParameter($shares['recipient']))
+ ->setValue('item_type', $qb->createNamedParameter('file'))
+ ->setValue('item_source', $qb->createNamedParameter(42))
+ ->setValue('file_source', $qb->createNamedParameter(42))
+ ->execute();
+ $ids = [$qb->getLastInsertId()];
+
+ foreach ($shares['children'] as $child) {
+ $qb = $this->dbConn->getQueryBuilder();
+ $qb->insert('share')
+ ->setValue('share_type', $qb->createNamedParameter(2))
+ ->setValue('uid_owner', $qb->createNamedParameter('owner'))
+ ->setValue('uid_initiator', $qb->createNamedParameter('initiator'))
+ ->setValue('share_with', $qb->createNamedParameter($child))
+ ->setValue('item_type', $qb->createNamedParameter('file'))
+ ->setValue('item_source', $qb->createNamedParameter(42))
+ ->setValue('file_source', $qb->createNamedParameter(42))
+ ->setValue('parent', $qb->createNamedParameter($ids[0]))
+ ->execute();
+ $ids[] = $qb->getLastInsertId();
+ }
+
+ $this->provider->groupDeleted($groupToDelete);
+
+ $qb = $this->dbConn->getQueryBuilder();
+ $cursor = $qb->select('*')
+ ->from('share')
+ ->where($qb->expr()->in('id', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)))
+ ->execute();
+ $data = $cursor->fetchAll();
+ $cursor->closeCursor();
+
+ $this->assertCount($shouldBeDeleted ? 0 : count($ids), $data);
+ }
}