I am stuck trying to figure out how to test the following Class:
This Class is loaded when a user clicks on a Case detail link and I have an override on View for the Case Object which loads a VF page that then executes the CaseDetailRedirectCode() method below. The method routes the user to the correct case detail page based on their profile.
I have a Test Class so far that creates an Account, Contact and a Community user under said Contact and a new Case owned by said Account and Contact. This is most likely not complicated but I am at a loss on where to go from here.
public class CaseDetailRedirect {
public Id RecordId { get; set; }
public CaseDetailRedirect(ApexPages.StandardController stdController) {
RecordId = stdController.getId();
}
public pagereference CaseDetailRedirectCode() {
Profile p = [Select Name from Profile where Id =:userinfo.getProfileid()];
String pname = p.name;
//check if Profile Name is the Support Community Profile
if (pname.equals('Support Community Login user')) {
return new PageReference('/CaseDetail?id=' + RecordId);
} else {
return new PageReference('/' + RecordId + '?nooverride=1');
}
}
}