I am still new to Apex testing and am trying to build a test class on the following, but keep running into the error message “Constructor not defined: [MyNewCaseListController].(ApexPages.StandardController)” It is coming from the 16th line in the test class. Any ideas what I am doing wrong?
public with sharing class MyNewCaseListController {
public MyNewCaseListController(ApexPages.StandardSetController ctrl){
string filter = ApexPages.currentPage().getParameters().get('filterId');
ctrl.setPageSize(50);
List<System.SelectOption> listViews = ctrl.getListViewOptions();
if (filter != null) {
ctrl.setFilterId(filter);
}
else {
for(System.SelectOption listView : listViews)
{
if (listView.getLabel() == 'Recently Viewed Cases')
ctrl.setFilterId(listView.getValue());
}
}
}
@isTest public without sharing class MyNewCaseListControllerTest {
@isTest public static void TestMyNewCaseListController(){
Case ca = new Case();
String i = Datetime.now().format('yyyy-MM-dd');
ca.Subject = 'Test Subject - Field Test ' + i;
ca.Description = 'Test Description - Field Test ' + i;
ca.Origin = 'Web Email';
ca.Type = 'Other';
insert ca;
string filterId = ca.Id;
Test.startTest();
ApexPages.currentPage().getParameters().put('filterId',ca.id);
MyNewCaseListController controller = new MyNewCaseListController(new ApexPages.StandardController(ca));
string filter = ApexPages.currentPage().getParameters().get('filterId');
controller.setPageSize(50);
List<System.SelectOption> listViews = ctrl.getListViewOptions();
// Set Filter Id if passed in parameter
if (filter != null) {
ctrl.setFilterId(filter);
}
else {
for(System.SelectOption listView : listViews)
{
if (listView.getLabel() == 'Recently Viewed Cases')
ctrl.setFilterId(listView.getValue());
}
}
}