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
XIOXIO 

HELP with Test Class Error: Constructor not defined: [ApexPages.StandardSetController].<Constructor>.......

Hello,

I'm getting the error below.

Error: Compile Error: Constructor not defined: [ApexPages.StandardSetController].<Constructor>(Login_Information_Object__c) at line 22 column 46

for the Test Class below. The Test Class is for a Visualforce Page controller. Any assistance is greatly appreciated.
 
@isTest
public class VFTSIAITSplashPageController_UT {

    
    static testMethod void myTest() {
        Login_Information_Object__c lio=new Login_Information_Object__c();
       
        lio.LIO_Content__c='test';
        lio.LIO_End_Date__c=Date.today() + 30;
        lio.LIO_Start_Date__c=Date.today() + 1;
        lio.Show_On_Login__c=TRUE;
        lio.Subject__c='testing';
        insert lio;   
        
        PageReference pageRef1 = Page.TSIAInformationSplashPage;
        Test.setCurrentPage(pageRef1);
        pageRef1.getParameters().put('id',lio.Id);

        ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lio);
        VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController (sc);
        
        testlio.save();    
 
        
        
    }
}

 
Best Answer chosen by XIO
Om PrakashOm Prakash
Thanks for sharing code of class.
In class, default constructor is defined,
So in test class, Comment or remove this line:
ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lio);

Now bellow changes: 
VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController();

 

All Answers

Om PrakashOm Prakash
Try this:

(lstLio is added in code)
@isTest
public class VFTSIAITSplashPageController_UT {

    
    static testMethod void myTest() {
        List<Login_Information_Object__c> lstLio = new List<Login_Information_Object__c>();

        Login_Information_Object__c lio=new Login_Information_Object__c();
       
        lio.LIO_Content__c='test';
        lio.LIO_End_Date__c=Date.today() + 30;
        lio.LIO_Start_Date__c=Date.today() + 1;
        lio.Show_On_Login__c=TRUE;
        lio.Subject__c='testing';
        lstLio.add(lio);
        insert lstLio;   
        
        PageReference pageRef1 = Page.TSIAInformationSplashPage;
        Test.setCurrentPage(pageRef1);
        pageRef1.getParameters().put('id',lio.Id);

        ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lstLio);
        VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController (sc);
        
        testlio.save();    
 
        
        
    }
}


 
XIOXIO
Thank you for the quick repy Om!

Unfortunately, I'm getting the same error :(
 
@isTest
public class VFTSIAITSplashPageController_UT {

    
    static testMethod void myTest() {
        List<Login_Information_Object__c> lstLio = new List<Login_Information_Object__c>();

        Login_Information_Object__c lio=new Login_Information_Object__c();
       
        lio.LIO_Content__c='test';
        lio.LIO_End_Date__c=Date.today() + 30;
        lio.LIO_Start_Date__c=Date.today() + 1;
        lio.Show_On_Login__c=TRUE;
        lio.Subject__c='testing';
        lstLio.add(lio);

        insert lstLio;   
        
        PageReference pageRef1 = Page.TSIAInformationSplashPage;
        Test.setCurrentPage(pageRef1);
        pageRef1.getParameters().put('id',lio.Id);

        ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lstLio);
        VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController (sc);
        
        testlio.save();    
 
        
        
    }
}

 
Om PrakashOm Prakash
Please check, same line error or error in next line ? If error in next line then need to check in extension class, are you using standardSetController or StandardController?
XIOXIO
Thank you, Om. Where would I use the StandardSetController or StandardController on the extension class below?
 
public with sharing class VFTSIAITSplashPageController {

    public String MyParameter = ApexPages.currentPage().getParameters().get('retURL');
    
    Map<String, String> UrlParameterMap = ApexPages.currentPage().getParameters();
    
    
         System.PageReference pageReference = new System.PageReference('/' + MyParameter);
    Map<String,String> parameters = pageReference.getParameters();
    
    String sfRetURL = parameters.get('retURL'); 
    
     
    


// public String varRetURL = ApexPages.currentPage().getParameters().get('retURL');


    public PageReference FinishLoginFlowStartUrl() {
       
   //    String redirectURL = '/apex/TSIA_Information_Splash_Page?retURL=' + sfStartUrl;
        return Auth.SessionManagement.finishLoginFlow(sfRetURL);
    }


    
public list<Login_Information_Object__c> lista {get;set;}
    
    public VFTSIAITSplashPageController(){
        lista = new list< Login_Information_Object__c >();
        lista = [select id, Subject__c, LIO_Content__c from Login_Information_Object__c  WHERE Show_On_Login__c = true  LIMIT 10];  
  
      
  
    }
  
   
 public PageReference autoRun() {
 
 String theId = ApexPages.currentPage().getParameters().get('id');
 
         if(lista.isEmpty() || lista == null){ 
         return Auth.SessionManagement.finishLoginFlow(sfRetURL);
        }
    return null;    
 
 }

    
    
}

 
Om PrakashOm Prakash
Thanks for sharing code of class.
In class, default constructor is defined,
So in test class, Comment or remove this line:
ApexPages.StandardSetController sc = new ApexPages.StandardSetController(lio);

Now bellow changes: 
VFTSIAITSplashPageController testlio = new VFTSIAITSplashPageController();

 
This was selected as the best answer
XIOXIO
Perfect! Thank you for your help Om, it is very much appreciated!!
Om PrakashOm Prakash
Hope it was fixed!
XIOXIO
It was, thank you for your help!!