2012-07-26 01:08:18 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2020-04-08 23:24:54 +03:00
|
|
|
* ownCloud
|
|
|
|
*
|
|
|
|
* @author Michael Gapczynski
|
|
|
|
* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2012-07-26 01:08:18 +04:00
|
|
|
|
2016-05-19 10:15:10 +03:00
|
|
|
namespace Test\Share;
|
2020-04-09 12:48:10 +03:00
|
|
|
|
2016-11-03 01:26:49 +03:00
|
|
|
use OC\Share\Share;
|
2016-11-04 15:07:16 +03:00
|
|
|
use OCP\IGroup;
|
|
|
|
use OCP\IGroupManager;
|
|
|
|
use OCP\IUser;
|
2016-11-03 01:26:49 +03:00
|
|
|
use OCP\IUserManager;
|
2016-05-19 10:15:10 +03:00
|
|
|
|
2015-11-03 03:52:41 +03:00
|
|
|
/**
|
|
|
|
* Class Test_Share
|
|
|
|
*
|
|
|
|
* @group DB
|
|
|
|
*/
|
2016-05-20 16:38:20 +03:00
|
|
|
class ShareTest extends \Test\TestCase {
|
2012-07-26 01:08:18 +04:00
|
|
|
protected $itemType;
|
2016-11-04 15:07:16 +03:00
|
|
|
|
|
|
|
/** @var IUser */
|
2012-07-26 01:08:18 +04:00
|
|
|
protected $user1;
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IUser */
|
2012-07-26 01:08:18 +04:00
|
|
|
protected $user2;
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IUser */
|
2014-01-21 15:07:08 +04:00
|
|
|
protected $user3;
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IUser */
|
2014-01-21 15:07:08 +04:00
|
|
|
protected $user4;
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IUser */
|
2015-01-19 16:39:00 +03:00
|
|
|
protected $user5;
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IUser */
|
2015-01-19 16:39:00 +03:00
|
|
|
protected $user6;
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IUser */
|
|
|
|
protected $groupAndUser_user;
|
|
|
|
|
|
|
|
/** @var IGroup */
|
2012-07-26 01:08:18 +04:00
|
|
|
protected $group1;
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IGroup */
|
2012-07-26 01:08:18 +04:00
|
|
|
protected $group2;
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IGroup */
|
|
|
|
protected $groupAndUser_group;
|
|
|
|
|
2013-02-26 22:31:15 +04:00
|
|
|
protected $resharing;
|
2013-09-13 01:37:43 +04:00
|
|
|
protected $dateInFuture;
|
|
|
|
protected $dateInPast;
|
2013-09-05 04:27:29 +04:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
/** @var IGroupManager */
|
|
|
|
protected $groupManager;
|
|
|
|
/** @var IUserManager */
|
|
|
|
protected $userManager;
|
|
|
|
|
2019-11-21 18:40:38 +03:00
|
|
|
protected function setUp(): void {
|
2014-11-18 13:08:01 +03:00
|
|
|
parent::setUp();
|
2014-11-11 01:30:38 +03:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$this->groupManager = \OC::$server->getGroupManager();
|
|
|
|
$this->userManager = \OC::$server->getUserManager();
|
|
|
|
|
|
|
|
$this->userManager->clearBackends();
|
|
|
|
$this->userManager->registerBackend(new \Test\Util\User\Dummy());
|
|
|
|
|
|
|
|
$this->user1 = $this->userManager->createUser($this->getUniqueID('user1_'), 'pass');
|
|
|
|
$this->user2 = $this->userManager->createUser($this->getUniqueID('user2_'), 'pass');
|
|
|
|
$this->user3 = $this->userManager->createUser($this->getUniqueID('user3_'), 'pass');
|
|
|
|
$this->user4 = $this->userManager->createUser($this->getUniqueID('user4_'), 'pass');
|
|
|
|
$this->user5 = $this->userManager->createUser($this->getUniqueID('user5_'), 'pass');
|
|
|
|
$this->user6 = $this->userManager->createUser($this->getUniqueID('user6_'), 'pass');
|
|
|
|
$groupAndUserId = $this->getUniqueID('groupAndUser_');
|
|
|
|
$this->groupAndUser_user = $this->userManager->createUser($groupAndUserId, 'pass');
|
|
|
|
\OC_User::setUserId($this->user1->getUID());
|
|
|
|
|
|
|
|
$this->groupManager->clearBackends();
|
|
|
|
$this->groupManager->addBackend(new \Test\Util\Group\Dummy());
|
|
|
|
$this->group1 = $this->groupManager->createGroup($this->getUniqueID('group1_'));
|
|
|
|
$this->group2 = $this->groupManager->createGroup($this->getUniqueID('group2_'));
|
|
|
|
$this->groupAndUser_group = $this->groupManager->createGroup($groupAndUserId);
|
|
|
|
|
|
|
|
$this->group1->addUser($this->user1);
|
|
|
|
$this->group1->addUser($this->user2);
|
|
|
|
$this->group1->addUser($this->user3);
|
|
|
|
$this->group2->addUser($this->user2);
|
|
|
|
$this->group2->addUser($this->user4);
|
|
|
|
$this->groupAndUser_group->addUser($this->user2);
|
|
|
|
$this->groupAndUser_group->addUser($this->user3);
|
|
|
|
|
2017-08-15 11:34:27 +03:00
|
|
|
\OC\Share\Share::registerBackend('test', 'Test\Share\Backend');
|
2016-05-19 10:15:10 +03:00
|
|
|
\OC_Hook::clear('OCP\\Share');
|
|
|
|
\OC::registerShareHooks();
|
2018-01-17 23:10:40 +03:00
|
|
|
$this->resharing = \OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_resharing', 'yes');
|
2018-01-17 23:14:09 +03:00
|
|
|
\OC::$server->getConfig()->setAppValue('core', 'shareapi_allow_resharing', 'yes');
|
2013-09-13 01:37:43 +04:00
|
|
|
|
|
|
|
// 20 Minutes in the past, 20 minutes in the future.
|
|
|
|
$now = time();
|
|
|
|
$dateFormat = 'Y-m-d H:i:s';
|
|
|
|
$this->dateInPast = date($dateFormat, $now - 20 * 60);
|
|
|
|
$this->dateInFuture = date($dateFormat, $now + 20 * 60);
|
2012-07-26 01:08:18 +04:00
|
|
|
}
|
|
|
|
|
2019-11-21 18:40:38 +03:00
|
|
|
protected function tearDown(): void {
|
2016-05-19 11:11:42 +03:00
|
|
|
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?');
|
2020-03-26 11:30:18 +03:00
|
|
|
$query->execute(['test']);
|
2018-01-17 23:14:09 +03:00
|
|
|
\OC::$server->getConfig()->setAppValue('core', 'shareapi_allow_resharing', $this->resharing);
|
2014-11-11 01:30:38 +03:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$this->user1->delete();
|
|
|
|
$this->user2->delete();
|
|
|
|
$this->user3->delete();
|
|
|
|
$this->user4->delete();
|
|
|
|
$this->user5->delete();
|
|
|
|
$this->user6->delete();
|
|
|
|
$this->groupAndUser_user->delete();
|
2015-01-19 16:39:00 +03:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$this->group1->delete();
|
|
|
|
$this->group2->delete();
|
|
|
|
$this->groupAndUser_group->delete();
|
2015-01-19 16:39:00 +03:00
|
|
|
|
2015-03-27 17:54:29 +03:00
|
|
|
$this->logout();
|
2014-11-18 13:08:01 +03:00
|
|
|
parent::tearDown();
|
2012-07-26 01:08:18 +04:00
|
|
|
}
|
|
|
|
|
2014-11-10 15:08:45 +03:00
|
|
|
public function testGetItemSharedWithUser() {
|
2016-11-04 15:07:16 +03:00
|
|
|
\OC_User::setUserId($this->user1->getUID());
|
2014-11-10 15:08:45 +03:00
|
|
|
|
|
|
|
//add dummy values to the share table
|
|
|
|
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
|
|
|
|
.' `item_type`, `item_source`, `item_target`, `share_type`,'
|
|
|
|
.' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), $this->user1->getUID()];
|
2014-11-10 15:08:45 +03:00
|
|
|
$query->execute($args);
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), $this->user1->getUID()];
|
2014-11-10 15:08:45 +03:00
|
|
|
$query->execute($args);
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user2->getUID()];
|
2014-11-10 15:08:45 +03:00
|
|
|
$query->execute($args);
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user4->getUID()];
|
2014-11-10 15:08:45 +03:00
|
|
|
$query->execute($args);
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user6->getUID(), $this->user4->getUID()];
|
2015-01-19 16:39:00 +03:00
|
|
|
$query->execute($args);
|
2014-11-10 15:08:45 +03:00
|
|
|
|
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$result1 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user2->getUID(), $this->user1->getUID());
|
2014-11-10 15:08:45 +03:00
|
|
|
$this->assertSame(1, count($result1));
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result1, ['target1']);
|
2014-11-10 15:08:45 +03:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$result2 = \OCP\Share::getItemSharedWithUser('test', 99, null, $this->user1->getUID());
|
2014-11-10 15:08:45 +03:00
|
|
|
$this->assertSame(2, count($result2));
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result2, ['target1', 'target2']);
|
2014-11-10 15:08:45 +03:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$result3 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user3->getUID());
|
2014-11-10 15:08:45 +03:00
|
|
|
$this->assertSame(2, count($result3));
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result3, ['target3', 'target4']);
|
2014-11-10 15:08:45 +03:00
|
|
|
|
|
|
|
$result4 = \OCP\Share::getItemSharedWithUser('test', 99, null, null);
|
2015-01-19 16:39:00 +03:00
|
|
|
$this->assertSame(5, count($result4)); // 5 because target4 appears twice
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result4, ['target1', 'target2', 'target3', 'target4']);
|
2015-01-19 16:39:00 +03:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$result6 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user6->getUID(), null);
|
2015-01-19 16:39:00 +03:00
|
|
|
$this->assertSame(1, count($result6));
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result6, ['target4']);
|
2014-11-10 15:08:45 +03:00
|
|
|
}
|
|
|
|
|
2015-01-16 20:11:13 +03:00
|
|
|
public function testGetItemSharedWithUserFromGroupShare() {
|
2016-11-04 15:07:16 +03:00
|
|
|
\OC_User::setUserId($this->user1->getUID());
|
2015-01-16 20:11:13 +03:00
|
|
|
|
|
|
|
//add dummy values to the share table
|
|
|
|
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
|
|
|
|
.' `item_type`, `item_source`, `item_target`, `share_type`,'
|
|
|
|
.' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()];
|
2015-01-16 20:11:13 +03:00
|
|
|
$query->execute($args);
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()];
|
2015-01-16 20:11:13 +03:00
|
|
|
$query->execute($args);
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()];
|
2015-01-16 20:11:13 +03:00
|
|
|
$query->execute($args);
|
2020-03-26 11:30:18 +03:00
|
|
|
$args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()];
|
2015-01-16 20:11:13 +03:00
|
|
|
$query->execute($args);
|
|
|
|
|
|
|
|
// user2 is in group1 and group2
|
2016-11-04 15:07:16 +03:00
|
|
|
$result1 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user2->getUID(), $this->user1->getUID());
|
2015-01-16 20:11:13 +03:00
|
|
|
$this->assertSame(2, count($result1));
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result1, ['target1', 'target2']);
|
2015-01-16 20:11:13 +03:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$result2 = \OCP\Share::getItemSharedWithUser('test', 99, null, $this->user1->getUID());
|
2015-01-16 20:11:13 +03:00
|
|
|
$this->assertSame(2, count($result2));
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result2, ['target1', 'target2']);
|
2015-01-16 20:11:13 +03:00
|
|
|
|
|
|
|
// user3 is in group1 and group2
|
2016-11-04 15:07:16 +03:00
|
|
|
$result3 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user3->getUID());
|
2015-01-16 20:11:13 +03:00
|
|
|
$this->assertSame(3, count($result3));
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result3, ['target1', 'target3', 'target4']);
|
2015-01-16 20:11:13 +03:00
|
|
|
|
|
|
|
$result4 = \OCP\Share::getItemSharedWithUser('test', 99, null, null);
|
|
|
|
$this->assertSame(4, count($result4));
|
2020-03-26 11:30:18 +03:00
|
|
|
$this->verifyResult($result4, ['target1', 'target2', 'target3', 'target4']);
|
2015-01-19 16:39:00 +03:00
|
|
|
|
2016-11-04 15:07:16 +03:00
|
|
|
$result6 = \OCP\Share::getItemSharedWithUser('test', 99, $this->user6->getUID(), null);
|
2015-01-19 16:39:00 +03:00
|
|
|
$this->assertSame(0, count($result6));
|
2015-01-16 20:11:13 +03:00
|
|
|
}
|
|
|
|
|
2014-11-10 15:08:45 +03:00
|
|
|
public function verifyResult($result, $expected) {
|
|
|
|
foreach ($result as $r) {
|
|
|
|
if (in_array($r['item_target'], $expected)) {
|
|
|
|
$key = array_search($r['item_target'], $expected);
|
|
|
|
unset($expected[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->assertEmpty($expected, 'did not found all expected values');
|
|
|
|
}
|
|
|
|
|
2014-12-04 21:51:04 +03:00
|
|
|
/**
|
|
|
|
* @dataProvider urls
|
2016-11-04 15:07:16 +03:00
|
|
|
* @param string $url
|
|
|
|
* @param string $expectedResult
|
2014-12-04 21:51:04 +03:00
|
|
|
*/
|
2020-04-10 17:51:06 +03:00
|
|
|
public function testRemoveProtocolFromUrl($url, $expectedResult) {
|
2014-12-04 21:51:04 +03:00
|
|
|
$share = new \OC\Share\Share();
|
2020-03-26 11:30:18 +03:00
|
|
|
$result = self::invokePrivate($share, 'removeProtocolFromUrl', [$url]);
|
2014-12-04 21:51:04 +03:00
|
|
|
$this->assertSame($expectedResult, $result);
|
|
|
|
}
|
|
|
|
|
2020-04-10 17:51:06 +03:00
|
|
|
public function urls() {
|
2020-03-26 11:30:18 +03:00
|
|
|
return [
|
|
|
|
['http://owncloud.org', 'owncloud.org'],
|
|
|
|
['https://owncloud.org', 'owncloud.org'],
|
|
|
|
['owncloud.org', 'owncloud.org'],
|
|
|
|
];
|
2014-12-04 21:51:04 +03:00
|
|
|
}
|
|
|
|
|
2014-08-01 18:24:19 +04:00
|
|
|
/**
|
|
|
|
* @dataProvider dataProviderTestGroupItems
|
2015-04-27 23:07:35 +03:00
|
|
|
* @param array $ungrouped
|
|
|
|
* @param array $grouped
|
2014-08-01 18:24:19 +04:00
|
|
|
*/
|
2020-04-10 17:51:06 +03:00
|
|
|
public function testGroupItems($ungrouped, $grouped) {
|
2014-08-01 18:24:19 +04:00
|
|
|
$result = DummyShareClass::groupItemsTest($ungrouped);
|
2014-01-21 15:07:08 +04:00
|
|
|
|
2014-08-01 18:24:19 +04:00
|
|
|
$this->compareArrays($grouped, $result);
|
|
|
|
}
|
|
|
|
|
2020-04-10 17:51:06 +03:00
|
|
|
public function compareArrays($result, $expectedResult) {
|
2014-08-01 18:24:19 +04:00
|
|
|
foreach ($expectedResult as $key => $value) {
|
|
|
|
if (is_array($value)) {
|
|
|
|
$this->compareArrays($result[$key], $value);
|
|
|
|
} else {
|
|
|
|
$this->assertSame($value, $result[$key]);
|
|
|
|
}
|
2014-01-21 15:07:08 +04:00
|
|
|
}
|
2014-08-01 18:24:19 +04:00
|
|
|
}
|
|
|
|
|
2020-04-10 17:51:06 +03:00
|
|
|
public function dataProviderTestGroupItems() {
|
2020-03-26 11:30:18 +03:00
|
|
|
return [
|
2014-08-01 18:24:19 +04:00
|
|
|
// one array with one share
|
2020-03-26 11:30:18 +03:00
|
|
|
[
|
|
|
|
[ // input
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_ALL, 'item_target' => 't1']],
|
|
|
|
[ // expected result
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_ALL, 'item_target' => 't1']]],
|
2014-08-01 18:24:19 +04:00
|
|
|
// two shares both point to the same source
|
2020-03-26 11:30:18 +03:00
|
|
|
[
|
|
|
|
[ // input
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'],
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'],
|
2020-04-09 10:22:29 +03:00
|
|
|
],
|
2020-03-26 11:30:18 +03:00
|
|
|
[ // expected result
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1',
|
|
|
|
'grouped' => [
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'],
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'],
|
2020-04-09 10:22:29 +03:00
|
|
|
]
|
|
|
|
],
|
|
|
|
]
|
|
|
|
],
|
2014-08-01 18:24:19 +04:00
|
|
|
// two shares both point to the same source but with different targets
|
2020-03-26 11:30:18 +03:00
|
|
|
[
|
|
|
|
[ // input
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'],
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't2'],
|
2020-04-09 10:22:29 +03:00
|
|
|
],
|
2020-03-26 11:30:18 +03:00
|
|
|
[ // expected result
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'],
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't2'],
|
2020-04-09 10:22:29 +03:00
|
|
|
]
|
|
|
|
],
|
2014-08-01 18:24:19 +04:00
|
|
|
// three shares two point to the same source
|
2020-03-26 11:30:18 +03:00
|
|
|
[
|
|
|
|
[ // input
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'],
|
|
|
|
['item_source' => 2, 'permissions' => \OCP\Constants::PERMISSION_CREATE, 'item_target' => 't2'],
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'],
|
2020-04-09 10:22:29 +03:00
|
|
|
],
|
2020-03-26 11:30:18 +03:00
|
|
|
[ // expected result
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1',
|
|
|
|
'grouped' => [
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_READ, 'item_target' => 't1'],
|
|
|
|
['item_source' => 1, 'permissions' => \OCP\Constants::PERMISSION_UPDATE, 'item_target' => 't1'],
|
2020-04-09 10:22:29 +03:00
|
|
|
]
|
|
|
|
],
|
2020-03-26 11:30:18 +03:00
|
|
|
['item_source' => 2, 'permissions' => \OCP\Constants::PERMISSION_CREATE, 'item_target' => 't2'],
|
2020-04-09 10:22:29 +03:00
|
|
|
]
|
|
|
|
],
|
2020-03-26 11:30:18 +03:00
|
|
|
];
|
2014-08-01 18:24:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DummyShareClass extends \OC\Share\Share {
|
|
|
|
public static function groupItemsTest($items) {
|
|
|
|
return parent::groupItems($items, 'test');
|
2014-01-21 15:07:08 +04:00
|
|
|
}
|
2012-07-26 01:08:18 +04:00
|
|
|
}
|
2015-02-09 15:12:34 +03:00
|
|
|
|
|
|
|
class DummyHookListener {
|
2020-04-10 17:48:31 +03:00
|
|
|
public static $shareType = null;
|
2015-02-09 15:12:34 +03:00
|
|
|
|
|
|
|
public static function listen($params) {
|
|
|
|
self::$shareType = $params['shareType'];
|
|
|
|
}
|
|
|
|
}
|