summaryrefslogtreecommitdiffstats
path: root/tests/lib/Federation
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2020-11-16 17:56:44 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2020-11-24 11:30:11 +0100
commit16a78f535a3b607864e0d151de13b0f161520f5c (patch)
treea9024ddbfa76b51e123177628e17ccb840821880 /tests/lib/Federation
parent6d3d6fb81a9b52700f77463fb3fa9084b03132f5 (diff)
downloadnextcloud-server-16a78f535a3b607864e0d151de13b0f161520f5c.tar.gz
nextcloud-server-16a78f535a3b607864e0d151de13b0f161520f5c.zip
set the display name of federated sharees from addressbook
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests/lib/Federation')
-rw-r--r--tests/lib/Federation/CloudIdManagerTest.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php
index 224acadbde4..dd68abf0ecb 100644
--- a/tests/lib/Federation/CloudIdManagerTest.php
+++ b/tests/lib/Federation/CloudIdManagerTest.php
@@ -22,15 +22,21 @@
namespace Test\Federation;
use OC\Federation\CloudIdManager;
+use OCP\Contacts\IManager;
use Test\TestCase;
class CloudIdManagerTest extends TestCase {
+ /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
+ protected $contactsManager;
/** @var CloudIdManager */
private $cloudIdManager;
protected function setUp(): void {
parent::setUp();
- $this->cloudIdManager = new CloudIdManager();
+
+ $this->contactsManager = $this->createMock(IManager::class);
+
+ $this->cloudIdManager = new CloudIdManager($this->contactsManager);
}
public function cloudIdProvider() {
@@ -51,11 +57,24 @@ class CloudIdManagerTest extends TestCase {
* @param string $remote
*/
public function testResolveCloudId($cloudId, $user, $remote, $cleanId) {
+ $displayName = 'Ample Ex';
+
+ $this->contactsManager->expects($this->any())
+ ->method('search')
+ ->with($cleanId, ['CLOUD'])
+ ->willReturn([
+ [
+ 'CLOUD' => [$cleanId],
+ 'FN' => 'Ample Ex',
+ ]
+ ]);
+
$cloudId = $this->cloudIdManager->resolveCloudId($cloudId);
$this->assertEquals($user, $cloudId->getUser());
$this->assertEquals($remote, $cloudId->getRemote());
$this->assertEquals($cleanId, $cloudId->getId());
+ $this->assertEquals($displayName . '@' . $remote, $cloudId->getDisplayId());
}
public function invalidCloudIdProvider() {
@@ -75,6 +94,9 @@ class CloudIdManagerTest extends TestCase {
public function testInvalidCloudId($cloudId) {
$this->expectException(\InvalidArgumentException::class);
+ $this->contactsManager->expects($this->never())
+ ->method('search');
+
$this->cloudIdManager->resolveCloudId($cloudId);
}
@@ -93,6 +115,16 @@ 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',
+ ]
+ ]);
+
$cloudId = $this->cloudIdManager->getCloudId($user, $remote);
$this->assertEquals($id, $cloudId->getId());