Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. @isTest
  2. public class CommunityController_TEST {
  3. @isTest
  4. private static void testContactUser() {
  5. //You'll need to use an actual Profile name in your org
  6. Id p = [select id from profile where name='Customer Community User'].id;
  7.  
  8. Account ac = new Account(name ='Test Community One') ;
  9. insert ac;
  10.  
  11. Contact con = new Contact(LastName ='testCon',AccountId = ac.Id);
  12. insert con;
  13.  
  14. User user = new User(alias = 'test123', email='test123@noemail.com',
  15. emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
  16. localesidkey='en_US', profileid = p, country='United States',IsActive =true,
  17. ContactId = con.Id,
  18. timezonesidkey='America/Los_Angeles', username='tester@noemail.com');
  19.  
  20. insert user;
  21. system.runAs(user) {
  22. User testUser = CommunityController.getLoggedInUser();
  23. system.assertequals(testUser.Id, user.Id);
  24. system.assertequals(testUser.Contact.AccountId, ac.Id);
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement