/** * Wrapper for unit testing the post process submit function. * * (If we expose through api we can get default additions 'for free'). * * @param array $params * @param int $action * @param string|null $creditCardMode * * @throws \CiviCRM_API3_Exception */ public function testSubmit($params, $action, $creditCardMode = NULL) { $defaults = array('soft_credit_contact_id' => array(), 'receipt_date' => '', 'receipt_date_time' => '', 'cancel_date' => '', 'cancel_date_time' => '', 'hidden_Premium' => 1); $this->_bltID = 5; if (!empty($params['id'])) { $existingContribution = civicrm_api3('contribution', 'getsingle', array('id' => $params['id'])); $this->_id = $params['id']; } else { $existingContribution = array(); } $this->_defaults['contribution_status_id'] = CRM_Utils_Array::value('contribution_status_id', $existingContribution); $this->_defaults['total_amount'] = CRM_Utils_Array::value('total_amount', $existingContribution); if ($creditCardMode) { $this->_mode = $creditCardMode; } // Required because processCreditCard calls set method on this. $_SERVER['REQUEST_METHOD'] = 'GET'; $this->controller = new CRM_Core_Controller(); CRM_Contribute_Form_AdditionalInfo::buildPremium($this); $this->_fields = array(); $this->submit(array_merge($defaults, $params), $action, CRM_Utils_Array::value('pledge_payment_id', $params)); }