aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2025-04-10 09:20:27 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2025-04-10 09:40:00 +0000
commit8e21c5fcdf0d01ddd714140e74dd901a998527c0 (patch)
treec091fe189d0bc8552338f804eadb0d69c42d6283
parent94fd2be634e7e64b96a65a44dd3c23c545fa2ec6 (diff)
downloadnextcloud-server-backport/52085/stable31.tar.gz
nextcloud-server-backport/52085/stable31.zip
fix(federation): Fix returning "no display name" after cache resultbackport/52085/stable31
Signed-off-by: Joas Schilling <coding@schilljs.com> [skip ci]
-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 13e6b111864..49aac87f4f3 100644
--- a/tests/lib/Federation/CloudIdManagerTest.php
+++ b/tests/lib/Federation/CloudIdManagerTest.php
@@ -48,6 +48,34 @@ class CloudIdManagerTest extends TestCase {
);
}
+ 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'],