You need to sign in to do that
Don't have an account?

Constructor Not Defined error in test class
I am trying to instantiate my controller in my test class but I had to do the controller class slightly differently then others that I've done in the past and so I can't figure out how to get it define in the test class.
My controllerclass says this for the page controller
private Id demoId;
private ApexPages.StandardController controller;
public DemoContactEntryExtension(ApexPages.StandardController controller) {
this.controller = controller;
// get the id of the demo
demoId = controller.getId();
my test class says this:
//Create Test Data
Account a=new Account(Name='Test Account');
insert a;
Contact c = new Contact(FirstName='John',LastName='Doe', AccountID=a.id);
insert c;
Opportunity o = new Opportunity(Name='Test Opportunity',closedate=system.today(), stagename='Confirmed Teaching/Class Schedule',Probability=0.95, accountID=a.id);
insert o;
OpportunityContactRole ocr = new OpportunityContactRole (Opportunityid = o.id, Contactid=c.id, role='Decision Maker', isPrimary=True) ;
insert ocr;
Demo__c demo = new Demo__c (Primary_Opportunity__c=o.id, Name='Test Demo');
insert demo;
Demo_Opportunity__c doc = new Demo_Opportunity__c (Opportunity__c=o.id, Demo__c=demo.id);
insert doc;
Demo_Contact__c dcc = new Demo_Contact__c (Contact__c=c.id, demo__c=demo.id);
insert dcc;
////////////////////////////////////////
// test DemoContactEntry
////////////////////////////////////////
// load the page
PageReference pageRef = Page.Demo_Contact_Entry;
pageRef.getParameters().put('Id',dcc.demo__c);
Test.setCurrentPageReference(pageRef);
// load the extension
DemoContactEntryExtension dCEE = new DemoContactEntryExtension(new ApexPages.StandardController(dcc.demo__c));
If anyone knows how I can change this to instantiate the controller that would be great.
Thanks,
Amanda
Hi,
DemoContactEntryExtension dCEE = new DemoContactEntryExtension(new ApexPages.StandardController(dcc.demo__c));
Replace above line with below.
DemoContactEntryExtension dCEE = new DemoContactEntryExtension(new ApexPages.StandardController(dcc));
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator
My Blog:- http://mrjavascript.blogspot.in/