@@ -56,6 +56,34 @@ protected function setUp(): void {
5656 $ this ->overwriteService (ICloudIdManager::class, $ this ->cloudIdManager );
5757 }
5858
59+ public function dataGetDisplayNameFromContact (): array {
60+ return [
61+ ['test1@example.tld ' , 'test ' , 'test ' ],
62+ ['test2@example.tld ' , null , null ],
63+ ['test3@example.tld ' , 'test3@example ' , 'test3@example ' ],
64+ ['test4@example.tld ' , 'test4@example.tld ' , null ],
65+ ];
66+ }
67+
68+ /**
69+ * @dataProvider dataGetDisplayNameFromContact
70+ */
71+ public function testGetDisplayNameFromContact (string $ cloudId , ?string $ displayName , ?string $ expected ): void {
72+ $ returnedContact = [
73+ 'CLOUD ' => [$ cloudId ],
74+ 'FN ' => $ expected ,
75+ ];
76+ if ($ displayName === null ) {
77+ unset($ returnedContact ['FN ' ]);
78+ }
79+ $ this ->contactsManager ->method ('search ' )
80+ ->with ($ cloudId , ['CLOUD ' ])
81+ ->willReturn ([$ returnedContact ]);
82+
83+ $ this ->assertEquals ($ expected , $ this ->cloudIdManager ->getDisplayNameFromContact ($ cloudId ));
84+ $ this ->assertEquals ($ expected , $ this ->cloudIdManager ->getDisplayNameFromContact ($ cloudId ));
85+ }
86+
5987 public function cloudIdProvider (): array {
6088 return [
6189 ['test@example.com ' , 'test ' , 'example.com ' , 'test@example.com ' ],
0 commit comments