Id PlanId = ApexPages.currentPage().getParameters().get('id');
plan = [SELECT OwnerId FROM My_Plan__c WHERE Id = :PlanId];
userId = plan.OwnerId;
@isTest(SeeAllData=true)
Private class PersonalDashBoardTest {
@isTest static void TestPersonalDashBoard() {
PersonalDashTestData.createAccountWithOpps();
PersonalDashTestData.createGoals();
My_Plan__c plan = new My_Plan__c();
plan.Name = 'test 123';
insert(plan);
Test.startTest();
//Use the PageReference Apex class to instantiate a page
// PageReference pageRef = Page.AccountDashBoardPage; // name of the page goes here
//In this case, the Visualforce page named 'success' is the starting point of this test method.
// Test.setCurrentPage(pageRef);
//Instantiate and construct the controller class.
ApexPages.StandardController MyPlan = new ApexPages.StandardController(plan);
PersonalDashBoardClass controller = new PersonalDashBoardClass(MyPlan);
controller.getAccountSummary60();
controller.getAccountSummary90();
controller.getAcct60Total();
controller.getAcct90Total();
controller.getOpp60Total();
controller.getOpp90Total();
test.stopTest();
}
}
Fixed it by adding the first line
Apexpages.currentPage().getParameters().put('Id', plan.Id);
ApexPages.StandardController MyPlan = new ApexPages.StandardController(plan);
PersonalDashBoardClass controller = new PersonalDashBoardClass(MyPlan);