+ Start a Discussion
Nishad BashaNishad Basha 

restricted user test cases examples in salesforce?

How to write the restricted user test cases i nsalesforce .please give me the example of above scenario.
RAM AnisettiRAM Anisetti
Hi Basha,
you can use user restriction by below sample code....

public class sampletestclass{
static testmethod void testmethod1()
    // create a new test user
    Profile p = [SELECT Id FROM profile WHERE Name = 'System Administrator' LIMIT 1];

    User testUser = new User(LastName = 'user 1', 
                             Username = 'user.1@sfdc.com', 
                             Email = 'usersf@gmail..com', 
                             Alias = 'test', 
                             TimeZoneSidKey = 'GMT', 
                             LocaleSidKey = 'en_GB', 
                             EmailEncodingKey = 'ISO-8859-1', 
                             ProfileId = p.Id, 
                             LanguageLocaleKey = 'en_US');     

            .....Do Some Testing...

    ..... assert the results are correct .....