Cleanup test case

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Thomas Müller 2016-10-04 12:58:11 +02:00 committed by Roeland Jago Douma
parent 1f0bc6936e
commit 2806a4bca7
No known key found for this signature in database
GPG Key ID: 1E152838F164D13B
1 changed files with 15 additions and 10 deletions

View File

@ -20,7 +20,7 @@
*/ */
namespace Test\Share20; namespace Test\Share20;
use OC\Share20\Exception\ProviderException; use OC\Authentication\Token\DefaultTokenMapper;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\File; use OCP\Files\File;
use OCP\Files\Folder; use OCP\Files\Folder;
@ -395,7 +395,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->createMock(IShare::class); $share = $this->createMock(IShare::class);
$share->method('getId')->willReturn($id); $share->method('getId')->willReturn($id);
$provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider') /** @var DefaultShareProvider $provider */
$provider = $this->getMockBuilder(DefaultShareProvider::class)
->setConstructorArgs([ ->setConstructorArgs([
$this->dbConn, $this->dbConn,
$this->userManager, $this->userManager,
@ -484,7 +485,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share->method('getId')->willReturn($id); $share->method('getId')->willReturn($id);
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
$provider = $this->getMockBuilder('OC\Share20\DefaultShareProvider') /** @var DefaultTokenMapper $provider */
$provider = $this->getMockBuilder(DefaultShareProvider::class)
->setConstructorArgs([ ->setConstructorArgs([
$this->dbConn, $this->dbConn,
$this->userManager, $this->userManager,
@ -599,7 +601,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = new \OC\Share20\Share($this->rootFolder, $this->userManager); $share = new \OC\Share20\Share($this->rootFolder, $this->userManager);
$shareOwner = $this->createMock(IUser::class); $shareOwner = $this->createMock(IUser::class);
$shareOwner->method('getUID')->WillReturn('shareOwner'); $shareOwner->method('getUID')->willReturn('shareOwner');
$path = $this->createMock(File::class); $path = $this->createMock(File::class);
$path->method('getId')->willReturn(100); $path->method('getId')->willReturn(100);
@ -1158,26 +1160,26 @@ class DefaultShareProviderTest extends \Test\TestCase {
]); ]);
$this->assertEquals(1, $qb->execute()); $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('getUserFolder')->with('shareOwner')->will($this->returnSelf());
$this->rootFolder->method('getById')->with($deletedFileId)->willReturn([$file]); $this->rootFolder->method('getById')->with($deletedFileId)->willReturn([$file]);
$groups = []; $groups = [];
foreach(range(0, 100) as $i) { foreach(range(0, 100) as $i) {
$group = $this->getMock('\OCP\IGroup'); $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('group'.$i); $group->method('getGID')->willReturn('group'.$i);
$groups[] = $group; $groups[] = $group;
} }
$group = $this->getMock('\OCP\IGroup'); $group = $this->createMock(IGroup::class);
$group->method('getGID')->willReturn('sharedWith'); $group->method('getGID')->willReturn('sharedWith');
$groups[] = $group; $groups[] = $group;
$user = $this->getMock('\OCP\IUser'); $user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('sharedWith'); $user->method('getUID')->willReturn('sharedWith');
$owner = $this->getMock('\OCP\IUser'); $owner = $this->createMock(IUser::class);
$owner->method('getUID')->willReturn('shareOwner'); $owner->method('getUID')->willReturn('shareOwner');
$initiator = $this->getMock('\OCP\IUser'); $initiator = $this->createMock(IUser::class);
$initiator->method('getUID')->willReturn('sharedBy'); $initiator->method('getUID')->willReturn('sharedBy');
$this->userManager->method('get')->willReturnMap([ $this->userManager->method('get')->willReturnMap([
@ -1230,6 +1232,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0); $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0);
$this->assertCount(1, $share); $this->assertCount(1, $share);
/** @var IShare $share */
$share = $share[0]; $share = $share[0];
$this->assertEquals($id, $share->getId()); $this->assertEquals($id, $share->getId());
$this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('sharedWith', $share->getSharedWith());
@ -1279,6 +1282,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0); $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0);
$this->assertCount(1, $share); $this->assertCount(1, $share);
/** @var IShare $share */
$share = $share[0]; $share = $share[0];
$this->assertEquals($id, $share->getId()); $this->assertEquals($id, $share->getId());
$this->assertEquals('sharedWith', $share->getSharedWith()); $this->assertEquals('sharedWith', $share->getSharedWith());
@ -1328,6 +1332,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0); $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0);
$this->assertCount(2, $shares); $this->assertCount(2, $shares);
/** @var IShare $share */
$share = $shares[0]; $share = $shares[0];
$this->assertEquals($id1, $share->getId()); $this->assertEquals($id1, $share->getId());
$this->assertSame('sharedWith', $share->getSharedWith()); $this->assertSame('sharedWith', $share->getSharedWith());