Fix User profile picture when performing the search
Hey guys! Anyway we can look into this also. I think it would be nice to have this in NC 25.
Currently in NC 25

Everything seems to work now since i added the line $avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]); that @nickvergessen suggested
Hi all, any updates on this on being in NC 25 ?
@andyxheli CI is unhappy:
There was 1 failure:
- Tests\Contacts\ContactsMenu\ContactsStoreTest::testGetContactsWithoutBinaryImage Failed asserting that '' is null.
/drone/src/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php:166
that test needs adjustements apparently
Thank you! @blizzz
@Pytal Do you have any suggestions on what needs to be done on ?
There was 1 failure:
Tests\Contacts\ContactsMenu\ContactsStoreTest::testGetContactsWithoutBinaryImage Failed asserting that '' is null. /drone/src/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php:166
This looks to be from the return value of linkToRouteAbsolute() so would say that urlGenerator needs to be mocked, @blizzz might know more here though?
Actually the test was ensuring(!) that avatar is null. Now it is not anymore as every time an avatar url is being created. The mock would at least return an empty string, and not null. testGetContactsWithoutAvatarURI does not fail however? A bit confusing when your not totally in the logic, it feels a bit that the tests were out of touch with the changes of the ContactsStore.
Best probably to do as @Pytal suggested: mock url generator to return a dummy url and expect this.
Something like this
diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
index aa609aedbb9..dfdd67fbb23 100644
--- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
@@ -140,6 +140,10 @@ class ContactsStoreTest extends TestCase {
public function testGetContactsWithoutBinaryImage() {
/** @var IUser|MockObject $user */
$user = $this->createMock(IUser::class);
+ $this->urlGenerator->expects($this->any())
+ ->method('linkToRouteAbsolute')
+ ->with('core.avatar.getAvatar', $this->anything())
+ ->willReturn('https://urlToNcAvatar.test');
$this->contactsManager->expects($this->once())
->method('search')
->with($this->equalTo(''), $this->equalTo(['FN', 'EMAIL']))
@@ -163,7 +167,7 @@ class ContactsStoreTest extends TestCase {
$entries = $this->contactsStore->getContacts($user, '');
$this->assertCount(2, $entries);
- $this->assertNull($entries[1]->getAvatar());
+ $this->assertSame('https://urlToNcAvatar.test', $entries[1]->getAvatar());
}
public function testGetContactsWithoutAvatarURI() {
(didn't run tests against it)
Thanks @blizzz I created a pull request for the changes that you suggested for the test
https://github.com/nextcloud/server/pull/34386
@andyxheli could you add them as commit to this PR?
@blizzz All done :)
/backport to stable25
@blizzz thank you! Can we also backpo this to NC 24 ?
/backport to stable24
This seemingly broke avatars of vcf-contacts.
See https://github.com/nextcloud/server/pull/36735
@szaimen would this also fix https://github.com/nextcloud/server/issues/34503 ? under See https://github.com/nextcloud/server/pull/36735
@szaimen would this also fix #34503 ?
No.
Okay, thanks. Just checking so we did have duplicate issues.

