function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ido Greenbaum 10Ido Greenbaum 10 

User Profile picture - 'FullPhotoUrl' : help with tests

Hi, 

I came up with an Apex Class to extract the User Profile Picture, to be used in a VisualForce Email Templat : 
 
public class UserProfilePicture {
    public String profileImageUrl { get; set; }
    List<user> lstuser;
  
    
    public UserProfilePicture () {
         lstuser = [select FullPhotoUrl from User where Id =: UserInfo.getUserId()];
         profileImageUrl=lstuser[0].FullPhotoUrl; 
    }
}



Can anyone please assist with a test for this class? 

Thank you, 
Ido. 
Best Answer chosen by Ido Greenbaum 10
NagendraNagendra (Salesforce Developers) 
Hi Ido,

You really just need to test if the URL is populated, something like this:
@isTest static void test() {
    UserProfilePicture upp = new UserProfilePicture();
    System.assert(upp.profileImageUrl <> null);
}
Please mark this post as solved if it's resolved so that it gets removed form the unanswered queue and becomes a proper solution for others who are really in need of it.

Regards,
Nagendra.P
 

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Ido,

You really just need to test if the URL is populated, something like this:
@isTest static void test() {
    UserProfilePicture upp = new UserProfilePicture();
    System.assert(upp.profileImageUrl <> null);
}
Please mark this post as solved if it's resolved so that it gets removed form the unanswered queue and becomes a proper solution for others who are really in need of it.

Regards,
Nagendra.P
 
This was selected as the best answer
Ido Greenbaum 10Ido Greenbaum 10
Thank you Nagendra.