diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2020-11-24 17:23:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-24 17:23:37 +0100 |
commit | 5d03b5c5ddbc8df4f8f64c02dba69679bdd0d4bf (patch) | |
tree | f66350829227a3f748c7141343faeb96d7e5a8a2 /tests/lib/Federation/CloudIdManagerTest.php | |
parent | 6156a49f6ed258da2e4949f16d331959af537adb (diff) | |
parent | 16a78f535a3b607864e0d151de13b0f161520f5c (diff) | |
download | nextcloud-server-5d03b5c5ddbc8df4f8f64c02dba69679bdd0d4bf.tar.gz nextcloud-server-5d03b5c5ddbc8df4f8f64c02dba69679bdd0d4bf.zip |
Merge pull request #24162 from nextcloud/fix/noid/fedshares-displaynamez
set the display name of federated sharees from addressbook
Diffstat (limited to 'tests/lib/Federation/CloudIdManagerTest.php')
-rw-r--r-- | tests/lib/Federation/CloudIdManagerTest.php | 34 |
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()); |