function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Thaier IssaThaier Issa 

Apex Test Class Error: Method does not exist or incorrect signature: void setCurrentPage(System.PageReference) from the type requnl_class_test

I am getting this error when trying to save my test, here is my test code
 
@istest (seeAllData = True) private class requnl_class_test  {

@isTest static void requnl_class_test () {
	Patient_Details__c client = new Patient_Details__c(
		Patient_name__c='Donkey Kong',
		Email_Address__c='tom@tom.com',
		Phone_number3__c='2012012233'
		);
	insert client;
	Patient_chart__c chart= new Patient_chart__c (
		RESTORE_Client__c=client.Id,
		name='sard'
		);
	insert chart;
	 
	ApexPages.currentPage().getParameters().put('id',chart.id);
	ApexPages.StandardController stdController = new ApexPages.StandardController(chart);
	
    requnl_class consext  = new requnl_class(stdController);

	PageReference pageRef = Page.Request_Unlock;

setCurrentPage(pageRef);

}
}

And here is my class code 
public without sharing class requnl_class
{
   private ApexPages.StandardController standardController;
   public String recId {get; set;}

 
    public requnl_class(ApexPages.StandardController standardController)
    {
    recId=ApexPages.CurrentPage().getparameters().get('id');
        this.standardController = standardController;
        
    }
  

public PageReference send() {

Messaging.singleEmailmessage email = new Messaging.singleEmailmessage();

patient_chart__c PatientId = [SELECT Id FROM patient_chart__c WHERE ID =:recid Limit 1]; 

List<string>sendTo = new List<String>();

sendTo.add('support@restorehair.com'); 

email.setToAddresses(sendTo);

email.setSubject('Please unlock this patient chart.'); 

email.setHtmlBody('Please unlock cs28.salesforce.com/'+PatientId.Id);

Messaging.sendEmailResult[] r = Messaging.sendEmail(new Messaging.singleEmailmessage[] {email});

        return null;
    }
}

Any help would be appreciated :)
 
Best Answer chosen by Thaier Issa
ApuroopApuroop
Hey, can you try changing the line 23 in your test class as below,
Test.setCurrentPage(pageRef);

All Answers

ApuroopApuroop
Hey, can you try changing the line 23 in your test class as below,
Test.setCurrentPage(pageRef);
This was selected as the best answer
Sunil RathoreSunil Rathore
Hi Thaier,

Please refer to the below code:
@istest (seeAllData = True) 
private class requnl_class_test  {
    public static testMethod void requnl_class_test () {
	  Patient_Details__c client = new Patient_Details__c(
		Patient_name__c='Donkey Kong',
		Email_Address__c='tom@tom.com',
		Phone_number3__c='2012012233'
	   );
	insert client;
	Patient_chart__c chart= new Patient_chart__c (
		RESTORE_Client__c=client.Id,
		name='sard'
		);
	insert chart;
	 
	ApexPages.currentPage().getParameters().put('id',chart.id);
	ApexPages.StandardController stdController = new ApexPages.StandardController(chart);
	
    requnl_class consext  = new requnl_class(stdController);

	PageReference pageRef = Page.Request_Unlock;

	Test.setCurrentPage(pageRef);
   }
}
 Hope this will solve your problem. If does then mark it the best answer so it can also help others.

Many Thanks,
Sunil Rathore