You need to sign in to do that
Don't have an account?
First Controller
My first controller, can anyone help creating a test class for this?
public class deliverablesController {
// Constructor
public deliverablesController(ApexPages.StandardController controller) {
this.proj = (Professional_Services_Partner__c)controller.getSubject();
this.delivers = [ SELECT
d.Name,
d.Partner_Package__c, d.Price__c, d.Price_Override__c,
Professional_Services_Partner_Contract__c, d.Id, d.QTY__c
FROM
Professional_Services_Partner_Line_Items__c d
WHERE
d.Professional_Services_Partner_Contract__c = :proj.id ];
}
public pagereference insertmethod()
{
Professional_Services_Partner_Line_Items__c cc= new Professional_Services_Partner_Line_Items__c();
cc.Professional_Services_Partner_Contract__c = proj.id;
insert cc;
return null;
}
public Professional_Services_Partner_Line_Items__c[] getDeliverables() {
return this.delivers;
}
// Action Method called from page button
public pagereference saveChanges() {
upsert this.delivers;
pageRef.setRedirect(true);
return pageRef;
}
// Action Method called from page link
public pagereference newDeliverable() {
Professional_Services_Partner_Line_Items__c d = new Professional_Services_Partner_Line_Items__c();
d.Professional_Services_Partner_Contract__c =this.proj.id;
delivers.add( d );
getDeliverables();
return null;
}
public pagereference DeleteAccount()
{
// if for any reason we are missing the reference
if (SelectedAccountId == null)
{
return null;
}
// find the account record within the collection
Professional_Services_Partner_Line_Items__c tobeDeleted = null;
for(Professional_Services_Partner_Line_Items__c a : this.delivers)
if (a.Id == SelectedAccountId)
{
tobeDeleted = a;
break;
}
//if account record found delete it
if (tobeDeleted != null)
{
Delete tobeDeleted;
}
pageRef.setRedirect(true);
return pageRef;
}
// class variables
PageReference pageRef = new PageReference(ApexPages.currentPage().getUrl());
Professional_Services_Partner__c proj;
Professional_Services_Partner_Line_Items__c[] delivers;
public string SelectedAccountId { get; set; }
}
Best,
Brian
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_error_handling.htm
All Answers
Right now on a blank slate. I'm not sure if I need to call my methods directly for testing or how it works. Or if I can simply pull queries on my object, make sure something matches, insert a record in my object, check the details etc...
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_error_handling.htm