Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @isTest
- private class TestRunAs {
- public static testMethod void testRunAs() {
- // Setup test data
- // This code runs as the system user
- Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
- User u = new User(Alias = 'standt', Email='standarduser@testorg.com',
- EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
- LocaleSidKey='en_US', ProfileId = p.Id,
- TimeZoneSidKey='America/Los_Angeles', UserName='standarduser@testorg.com');
- System.runAs(u) {
- Opportunity opp = new Opportunity();
- // put required field
- insert opp;
- OpportunityTeamMember otm = new OpportunityTeamMember (OpportunityId = opp.id,UserId = u.id,TeamMemberRole = role);
- insert otm;
- }
- }
- }
Add Comment
Please, Sign In to add comment