Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions tests/lib/Share20/DefaultShareProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @author Roeland Jago Douma <rullzer@owncloud.com>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl>
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
Expand All @@ -20,7 +21,6 @@
*/
namespace Test\Share20;

use OC\Share20\Exception\ProviderException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\File;
use OCP\Files\Folder;
Expand Down Expand Up @@ -395,7 +395,8 @@ public function testDeleteSingleShare() {
$share = $this->createMock(IShare::class);
$share->method('getId')->willReturn($id);

$provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider')
/** @var DefaultShareProvider $provider */
$provider = $this->getMockBuilder(DefaultShareProvider::class)
->setConstructorArgs([
$this->dbConn,
$this->userManager,
Expand Down Expand Up @@ -484,7 +485,8 @@ public function testDeleteGroupShareWithUserGroupShares() {
$share->method('getId')->willReturn($id);
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);

$provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider')
/** @var DefaultShareProvider $provider */
$provider = $this->getMockBuilder(DefaultShareProvider::class)
->setConstructorArgs([
$this->dbConn,
$this->userManager,
Expand Down Expand Up @@ -599,7 +601,7 @@ public function testCreateUserShare() {
$share = new \OC\Share20\Share($this->rootFolder, $this->userManager);

$shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->WillReturn('shareOwner');
$shareOwner->method('getUID')->willReturn('shareOwner');

$path = $this->createMock(File::class);
$path->method('getId')->willReturn(100);
Expand Down Expand Up @@ -1158,26 +1160,26 @@ public function testGetSharedWithWithDeletedFile($shareType, $trashed) {
]);
$this->assertEquals(1, $qb->execute());

$file = $this->getMock('\OCP\Files\File');
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with($deletedFileId)->willReturn([$file]);

$groups = [];
foreach(range(0, 100) as $i) {
$group = $this->getMock('\OCP\IGroup');
$group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('group'.$i);
$groups[] = $group;
}

$group = $this->getMock('\OCP\IGroup');
$group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('sharedWith');
$groups[] = $group;

$user = $this->getMock('\OCP\IUser');
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('sharedWith');
$owner = $this->getMock('\OCP\IUser');
$owner = $this->createMock(IUser::class);
$owner->method('getUID')->willReturn('shareOwner');
$initiator = $this->getMock('\OCP\IUser');
$initiator = $this->createMock(IUser::class);
$initiator->method('getUID')->willReturn('sharedBy');

$this->userManager->method('get')->willReturnMap([
Expand Down Expand Up @@ -1230,6 +1232,7 @@ public function testGetSharesBy() {
$share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0);
$this->assertCount(1, $share);

/** @var IShare $share */
$share = $share[0];
$this->assertEquals($id, $share->getId());
$this->assertEquals('sharedWith', $share->getSharedWith());
Expand Down Expand Up @@ -1279,6 +1282,7 @@ public function testGetSharesNode() {
$share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0);
$this->assertCount(1, $share);

/** @var IShare $share */
$share = $share[0];
$this->assertEquals($id, $share->getId());
$this->assertEquals('sharedWith', $share->getSharedWith());
Expand Down Expand Up @@ -1328,6 +1332,7 @@ public function testGetSharesReshare() {
$shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0);
$this->assertCount(2, $shares);

/** @var IShare $share */
$share = $shares[0];
$this->assertEquals($id1, $share->getId());
$this->assertSame('sharedWith', $share->getSharedWith());
Expand Down