Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-07-09 09:00:03 +0300
committerJulius Härtl <jus@bitgrid.net>2021-07-14 17:08:05 +0300
commit7179002600ccde6d6757c068c9388430ed71a2f1 (patch)
tree5b0fd29678ce392db2764923d5f6bb393435d596 /tests/lib/Federation
parentf43c2b45d8177e8c924b8f97f80c92164a3d5412 (diff)
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/lib/Federation')
-rw-r--r--tests/lib/Federation/CloudIdManagerTest.php36
1 files changed, 26 insertions, 10 deletions
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);