Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @isTest
- public class CommunityController_TEST {
- @isTest
- private static void testContactUser() {
- //You'll need to use an actual Profile name in your org
- Id p = [select id from profile where name='Customer Community User'].id;
- Account ac = new Account(name ='Test Community One') ;
- insert ac;
- Contact con = new Contact(LastName ='testCon',AccountId = ac.Id);
- insert con;
- User user = new User(alias = 'test123', email='test123@noemail.com',
- emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
- localesidkey='en_US', profileid = p, country='United States',IsActive =true,
- ContactId = con.Id,
- timezonesidkey='America/Los_Angeles', username='tester@noemail.com');
- insert user;
- system.runAs(user) {
- User testUser = CommunityController.getLoggedInUser();
- system.assertequals(testUser.Id, user.Id);
- system.assertequals(testUser.Contact.AccountId, ac.Id);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement