I have a custom object which is a child to the Opportunity object. The custom object is viewed via visualforce page. Sometimes Users need to create payment records for the child object. This is achieved by calling a method on a controller extension. When pressed, the method will automatically create detail records using information in the custom object record.
I am trying to write a test class that will check the controller is working correctly and that the values copied over from the custom object are correct. I can't figure out how to call the method to create the payments. Can anyone help? Here is the test class:
@isTest
public class sipExt_Test {
public static testMethod void testSIPExtController() {
// Create Opportunity from test utilities class
List<Opportunity> OppList = testUtilities.createTestOpps(1);
// Create the SIP
bonus_calculator__c bc1 = new bonus_calculator__c(opportunity__c = OppList[0].Id);
insert bc1;
PageReference ref = new PageReference('/apex/SIP2?id=' + bc1.Id);
Test.setCurrentPage(ref);
// Create SIP standard controller, pass it the SIP Record
ApexPages.StandardController controller = new ApexPages.StandardController(bc1);
// Pass the Controller to the Extension
sipExt stdController = new sipExt(controller);
stdController.createPayments();
// Query for Payments fields
List <Bonus_Payments__c> bPayList = [SELECT Id FROM Bonus_Payments__c WHERE Bonus_Record__c = :bc1.Id];
system.debug(bPayList[0].id);
}
}
createPaymentsis the method you are talking about then you are calling it correctly. What is not working? – Keith C Dec 12 '14 at 10:43