You need to sign in to do that
Don't have an account?
Phuc Nguyen 18
Test class coverage help Visualforce page
Will someone help with a test class for this controller?
P
public with sharing class Pdf_Permit_Controller { public Permit__c permit {get; set;} public ApexPages.StandardController controller {get;set;} public String permitId {get;set;} public List<Permit_Fees__c> allfees; public Pdf_Permit_Controller(ApexPages.StandardController controller) { permitId = ApexPages.currentPage().getParameters().get('id');// controller.getId(); //System.debug(permitId); permit = (Permit__c)controller.getRecord(); permit = [Select ID,name, customer__c from Permit__c where id=:permitId LIMIT 1]; allfees = new List<Permit_Fees__c>(); Permit_Fees__c feelist = new Permit_Fees__c(); feelist.Permit__c = permit.Permit_Fees__c; allfees.add(feelist); } }thank you,
P
All Answers
Please try below one. Thanks
Hemant
I am getting an error while testing. 'System.QueryException: List has no rows for assignment to SObject'
Do I have to replicate this line of code: 'permit = [Select ID,name, customer__c from Permit__c where id=:permitId LIMIT 1];'
Cheers,
P
Please try below code it will not give you any error but your code not looks good. Can you please explain what functionality you are trying to achive here.
Thanks
Hemant
Trying to populate data on a visulaforce page from the 'Permit object'(Main) and 'Permit_Fees__c'(child) object. There are multiple Permit_Fees__c records.
Thanks,
P
I think whatever you are trying above is not fulfill your requirement. So you need to update your vf page.
The Controller is returning all of the fields and records for the visualforce page. Are you saying the controller is incorrect? If so please advise a better approach.
Thanks,
P
I have cleaned up the code and ighlighted the lines that donot have any coverage:
Any suggestions?
Thanks,
P
I finally got it to work. Thanks for your help.