aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-06-17 18:09:59 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-06-17 18:09:59 +0200
commitde6bb33d999d78df501420ae89a3793d90ef48c9 (patch)
tree5676dc647f0530ccd3f80beda25de77559a0d1b8 /tests
parent7f6a891110e7107c9056d8f5444bae62c57d89b7 (diff)
downloadnextcloud-server-de6bb33d999d78df501420ae89a3793d90ef48c9.tar.gz
nextcloud-server-de6bb33d999d78df501420ae89a3793d90ef48c9.zip
fix(tests): Fix tests with new LazyUser usage in DefaultShareProvider
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php30
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 72ef83331e9..e138f2f576b 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -38,31 +38,31 @@ class DefaultShareProviderTest extends \Test\TestCase {
/** @var IDBConnection */
protected $dbConn;
- /** @var IUserManager | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var IUserManager | MockObject */
protected $userManager;
- /** @var IGroupManager | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var IGroupManager | MockObject */
protected $groupManager;
- /** @var IRootFolder | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var IRootFolder | MockObject */
protected $rootFolder;
/** @var DefaultShareProvider */
protected $provider;
- /** @var \PHPUnit\Framework\MockObject\MockObject|IMailer */
+ /** @var MockObject|IMailer */
protected $mailer;
/** @var IFactory|MockObject */
protected $l10nFactory;
- /** @var \PHPUnit\Framework\MockObject\MockObject|IL10N */
+ /** @var MockObject|IL10N */
protected $l10n;
- /** @var \PHPUnit\Framework\MockObject\MockObject|Defaults */
+ /** @var MockObject|Defaults */
protected $defaults;
- /** @var \PHPUnit\Framework\MockObject\MockObject|IURLGenerator */
+ /** @var MockObject|IURLGenerator */
protected $urlGenerator;
/** @var ITimeFactory|MockObject */
@@ -1035,7 +1035,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $owner],
['sharedBy', $initiator],
]);
- $this->groupManager->method('getUserGroupIds')->with($user)->willReturn($groups);
+ $this->groupManager
+ ->method('getUserGroupIds')
+ ->willReturnCallback(fn (IUser $user) => ($user->getUID() === 'sharedWith' ? $groups : []));
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
@@ -1123,7 +1125,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $owner],
['sharedBy', $initiator],
]);
- $this->groupManager->method('getUserGroupIds')->with($user)->willReturn($groups);
+ $this->groupManager
+ ->method('getUserGroupIds')
+ ->willReturnCallback(fn (IUser $user) => ($user->getUID() === 'user' ? $groups : []));
$file = $this->createMock(File::class);
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
@@ -1206,7 +1210,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
['user1', $user1],
]);
- $this->groupManager->method('getUserGroupIds')->with($user0)->willReturn(['group0']);
+ $this->groupManager
+ ->method('getUserGroupIds')
+ ->willReturnCallback(fn (IUser $user) => ($user->getUID() === 'user0' ? ['group0'] : []));
$node = $this->createMock(Folder::class);
$node->method('getId')->willReturn($fileId2);
@@ -1283,7 +1289,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $owner],
['sharedBy', $initiator],
]);
- $this->groupManager->method('getUserGroupIds')->with($user)->willReturn($groups);
+ $this->groupManager
+ ->method('getUserGroupIds')
+ ->willReturnCallback(fn (IUser $user) => ($user->getUID() === 'sharedWith' ? $groups : []));
$share = $this->provider->getSharedWith('sharedWith', $shareType, null, 1, 0);
$this->assertCount(0, $share);