You need to sign in to do that
Don't have an account?
Test Get Options Method - by Profile
Can anyone assist with the test code for the following controller extension method? It returns a default set of options and then additional options based on profile. Any assistance would be appreciated.
//getOptions Method
public List<SelectOption> getOptions(){
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('','--select--'));
options.add(new SelectOption('Next','Next RC'));
options.add(new SelectOption('Previous','Previous RC'));
options.add(new SelectOption('getProperty','Assign Property Contact'));
options.add(new SelectOption('getCorporate','Assign Corporate Contact'));
IF(InEditProfileTest =='000e50000000pnH3' || InEditProfileTest =='00e50000000pnCc' ){
options.add(new SelectOption('Close','Close AM Case'));
}
Else IF(InEditProfileTest =='00e50000000pnCmAAI'){
options.add(new SelectOption('ExceptionON','Owner Exception ON'));
options.add(new SelectOption('ExceptionOFF','Owner Exception OFF'));
options.add(new SelectOption('Refresh','Refresh Case'));
}
Else If(InEditProfileTest=='00e30000000gvVd' || InEditProfileTest =='00e50000000pl2e'){
options.add(new SelectOption('ExceptionON','Owner Exception ON'));
options.add(new SelectOption('ExceptionOFF','Owner Exception OFF'));
options.add(new SelectOption('Refresh','Refresh Case'));
options.add(new SelectOption('Complete','Auto Complete'));
options.add(new SelectOption('Cancel','Cancel'));
options.add(new SelectOption('Clear Cancel','Clear Cancel'));
options.add(new SelectOption('ResetAll','Reset'));
options.add(new SelectOption('Terminate','Terminate'));
options.add(new SelectOption('Delete','Delete'));
}
return options;
}
In your test method...
1. use seealldata = true
2. query the profiles that you wanted to test (all the profiles in the if conditions)
3. create users with different profiles from step 2
4. use system.runas to test with different users
this way you can cover the complete code coverage..
follow this link for more info..
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_example.htm#second_user