aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2025-04-10 09:20:27 +0200
committerJoas Schilling <coding@schilljs.com>2025-04-10 09:20:27 +0200
commitd8744f84e8ab224e0beb1714dbce37f912350e29 (patch)
treebca8068af34fc3f0f18aa760d1ed86280082cb16 /tests
parente94fe91cd1e1d152c6126f3304890ca767ba908a (diff)
downloadnextcloud-server-d8744f84e8ab224e0beb1714dbce37f912350e29.tar.gz
nextcloud-server-d8744f84e8ab224e0beb1714dbce37f912350e29.zip
fix(federation): Fix returning "no display name" after cache resultbugfix/noid/fix-cached-return-of-display-name
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Federation/CloudIdManagerTest.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php
index 14daef27142..1775c18a5e9 100644
--- a/tests/lib/Federation/CloudIdManagerTest.php
+++ b/tests/lib/Federation/CloudIdManagerTest.php
@@ -56,6 +56,34 @@ class CloudIdManagerTest extends TestCase {
$this->overwriteService(ICloudIdManager::class, $this->cloudIdManager);
}
+ public function dataGetDisplayNameFromContact(): array {
+ return [
+ ['test1@example.tld', 'test', 'test'],
+ ['test2@example.tld', null, null],
+ ['test3@example.tld', 'test3@example', 'test3@example'],
+ ['test4@example.tld', 'test4@example.tld', null],
+ ];
+ }
+
+ /**
+ * @dataProvider dataGetDisplayNameFromContact
+ */
+ public function testGetDisplayNameFromContact(string $cloudId, ?string $displayName, ?string $expected): void {
+ $returnedContact = [
+ 'CLOUD' => [$cloudId],
+ 'FN' => $expected,
+ ];
+ if ($displayName === null) {
+ unset($returnedContact['FN']);
+ }
+ $this->contactsManager->method('search')
+ ->with($cloudId, ['CLOUD'])
+ ->willReturn([$returnedContact]);
+
+ $this->assertEquals($expected, $this->cloudIdManager->getDisplayNameFromContact($cloudId));
+ $this->assertEquals($expected, $this->cloudIdManager->getDisplayNameFromContact($cloudId));
+ }
+
public function cloudIdProvider(): array {
return [
['test@example.com', 'test', 'example.com', 'test@example.com'],