Skip to main content

@isTest

private class TestCtrTurnoverEntryCmp {

@isTest

static void testTurnoverEntry(){

UserRole portalRole = [Select Id From UserRole Where PortalType = 'None' Limit 1];

Profile profile1 = [Select Id from Profile where name = 'System Administrator'];

User newUser = new User(

UserRoleId = portalRole.Id,

ProfileId = profile1.id,

Username = 'test@managemall.com',

email = 'test@managemall.com',

emailencodingkey = 'UTF-8',

localesidkey = 'en_US',

languagelocalekey = 'en_US',

timezonesidkey = 'America/Los_Angeles',

alias ='nuser',

lastname ='sahin'

);

insert newUser;

system.runAs(newUser)

{

System.debug('Current User: ' + UserInfo.getUserName());

Account acc = new Account(Name = 'portalAccount', OwnerId = newUser.Id);

insert acc;

Contact con = new Contact (

AccountId = acc.id,

LastName = 'portalContact'

);

insert con;

User user2 = [SELECT AccountId FROM User WHERE Username =:

UserInfo.getUserName()];

System.debug('user1: ' + user1.AccountId); // this return null

Test.startTest();

......

Test.stopTest();

}

}

}

 
3 answers
0/9000