Guest User

Untitled

a guest
Apr 19th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. @isTest
  2. private class TestRunAs {
  3. public static testMethod void testRunAs() {
  4. // Setup test data
  5. // This code runs as the system user
  6. Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
  7. User u = new User(Alias = 'standt', Email='standarduser@testorg.com',
  8. EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
  9. LocaleSidKey='en_US', ProfileId = p.Id,
  10. TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@testorg.com');
  11.  
  12. System.runAs(u) {
  13. Opportunity opp = new Opportunity();
  14. // put required field
  15. insert opp;
  16.  
  17. OpportunityTeamMember otm = new OpportunityTeamMember (OpportunityId = opp.id,UserId = u.id,TeamMemberRole = role);
  18. insert otm;
  19.  
  20. }
  21. }
  22. }
Add Comment
Please, Sign In to add comment