You need to sign in to do that
Don't have an account?
Enry
Error: Constructor not defined: [ApexPages.StandardController].<Constructor>()
I got this error when i save my test class:
Error: Compile Error: Constructor not defined: [ApexPages.StandardController].<Constructor>()
CLASS:
public class ContentVersionAlt { private List<ContentVersion> ContentVersions; public string host{get;set;} public ContentVersionAlt(ApexPages.StandardController controller) { host=URL.getSalesforceBaseUrl().toExternalForm(); } public List<ContentVersion> getContentVersions() { ContentVersions= [Select c.id ,c.Software_Download__c,c.title,c.description,c.FileType From ContentVersion c where c.Software_Download__c=:System.currentPagereference().getParameters().get('id')]; return ContentVersions; } }
TEST CLASS:
@istest private class ContentVersionAltTest { static testMethod void ContentVersionsTest(){ PageReference pageRef = Page.SoftwareDownloadFiles; Test.setCurrentPageReference(pageRef); ApexPages.StandardController sc = new ApexPages.standardController(); //create an instance of the controller ContentVersionAlt myPageCon = new ContentVersionAlt(sc); myPageCon.getContentVersions(); ContentVersion testContentInsert =new ContentVersion(); testContentInsert.ContentURL='http://www.google.com/'; testContentInsert.Title ='Google.com'; insert testContentInsert; ContentVersion testContent = [SELECT ContentDocumentId FROM ContentVersion where Id = :testContentInsert.Id]; ContentWorkspace testWorkspace = [SELECT Id FROM ContentWorkspace WHERE Name='Opportunity Documents ']; ContentWorkspaceDoc newWorkspaceDoc =new ContentWorkspaceDoc(); newWorkspaceDoc.ContentWorkspaceId = testWorkspace.Id; newWorkspaceDoc.ContentDocumentId = testContent.ContentDocumentId; insert newWorkspaceDoc; update testContent; } }
How can i solve this?
Thanks in advantage for any advice.
Standard controllers don't have a no-argument constructor - they need an instance of an object to manage, so this line
will fail.
What is the type of sobject the standard controller is managing (i.e. what is the value of the standardController attribute on the page)?
All Answers
Standard controllers don't have a no-argument constructor - they need an instance of an object to manage, so this line
will fail.
What is the type of sobject the standard controller is managing (i.e. what is the value of the standardController attribute on the page)?
Thanks a lot Bob:
Can you help me to remove it sir.
public String name {set;get;}
public Integer age {set;get;}
public Decimal salary {set;get;}
public Decimal exp {set;get;}
public PageReference submit(){
** PageReference p=new PageReference('/apex/Result');//Error:Constructor not defined: [PageReference].<Constructor>(String)
return p;
}
public void cancel(){
name=null;
age=null;
salary=null;
exp=null;
}
}
Getting error at line:9
why?