diff options
author | Julius Härtl <jus@bitgrid.net> | 2021-07-09 08:00:03 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2021-07-14 16:08:05 +0200 |
commit | 7179002600ccde6d6757c068c9388430ed71a2f1 (patch) | |
tree | 5b0fd29678ce392db2764923d5f6bb393435d596 /tests | |
parent | f43c2b45d8177e8c924b8f97f80c92164a3d5412 (diff) | |
download | nextcloud-server-7179002600ccde6d6757c068c9388430ed71a2f1.tar.gz nextcloud-server-7179002600ccde6d6757c068c9388430ed71a2f1.zip |
Allow to get a local cloud id without going through the contacts manager
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Collaboration/Collaborators/MailPluginTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Collaboration/Collaborators/RemotePluginTest.php | 3 | ||||
-rw-r--r-- | tests/lib/Federation/CloudIdManagerTest.php | 36 |
3 files changed, 31 insertions, 12 deletions
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php index 3128231a108..ad18666e0ae 100644 --- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php @@ -32,7 +32,9 @@ use OCP\Contacts\IManager; use OCP\Federation\ICloudIdManager; use OCP\IConfig; use OCP\IGroupManager; +use OCP\IURLGenerator; use OCP\IUser; +use OCP\IUserManager; use OCP\IUserSession; use OCP\Share\IShare; use Test\TestCase; @@ -70,7 +72,7 @@ class MailPluginTest extends TestCase { $this->groupManager = $this->createMock(IGroupManager::class); $this->knownUserService = $this->createMock(KnownUserService::class); $this->userSession = $this->createMock(IUserSession::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class)); $this->searchResult = new SearchResult(); } diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php index 981260a80dd..4072f3ecde1 100644 --- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php +++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php @@ -30,6 +30,7 @@ use OCP\Collaboration\Collaborators\SearchResultType; use OCP\Contacts\IManager; use OCP\Federation\ICloudIdManager; use OCP\IConfig; +use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; @@ -62,7 +63,7 @@ class RemotePluginTest extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->config = $this->createMock(IConfig::class); $this->contactsManager = $this->createMock(IManager::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class)); $this->searchResult = new SearchResult(); } diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php index dd68abf0ecb..92f8a5fa8dd 100644 --- a/tests/lib/Federation/CloudIdManagerTest.php +++ b/tests/lib/Federation/CloudIdManagerTest.php @@ -23,20 +23,29 @@ namespace Test\Federation; use OC\Federation\CloudIdManager; use OCP\Contacts\IManager; +use OCP\IURLGenerator; +use OCP\IUserManager; use Test\TestCase; class CloudIdManagerTest extends TestCase { /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */ protected $contactsManager; + /** @var IURLGenerator|\PHPUnit\Framework\MockObject\MockObject */ + private $urlGenerator; + /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ + private $userManager; /** @var CloudIdManager */ private $cloudIdManager; + protected function setUp(): void { parent::setUp(); $this->contactsManager = $this->createMock(IManager::class); + $this->urlGenerator = $this->createMock(IURLGenerator::class); + $this->userManager = $this->createMock(IUserManager::class); - $this->cloudIdManager = new CloudIdManager($this->contactsManager); + $this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->urlGenerator, $this->userManager); } public function cloudIdProvider() { @@ -104,6 +113,7 @@ class CloudIdManagerTest extends TestCase { return [ ['test', 'example.com', 'test@example.com'], ['test@example.com', 'example.com', 'test@example.com@example.com'], + ['test@example.com', null, 'test@example.com@example.com'], ]; } @@ -115,15 +125,21 @@ class CloudIdManagerTest extends TestCase { * @param string $id */ public function testGetCloudId($user, $remote, $id) { - $this->contactsManager->expects($this->any()) - ->method('search') - ->with($id, ['CLOUD']) - ->willReturn([ - [ - 'CLOUD' => [$id], - 'FN' => 'Ample Ex', - ] - ]); + if ($remote !== null) { + $this->contactsManager->expects($this->any()) + ->method('search') + ->with($id, ['CLOUD']) + ->willReturn([ + [ + 'CLOUD' => [$id], + 'FN' => 'Ample Ex', + ] + ]); + } else { + $this->urlGenerator->expects(self::once()) + ->method('getAbsoluteUrl') + ->willReturn('https://example.com'); + } $cloudId = $this->cloudIdManager->getCloudId($user, $remote); |