'financial_type_id',
];
- $event = $objects['event'] ?? NULL;
+ $eventID = $objects['event']->id ?? NULL;
$paymentProcessorId = '';
if (isset($objects['paymentProcessor'])) {
$contributionParams = array_merge([
'contribution_status_id' => $completedContributionStatusID,
- 'source' => self::getRecurringContributionDescription($contribution, $event),
+ 'source' => self::getRecurringContributionDescription($contribution, $eventID),
], array_intersect_key($input, array_fill_keys($inputContributionWhiteList, 1)
));
* Get the description (source field) for the recurring contribution.
*
* @param CRM_Contribute_BAO_Contribution $contribution
- * @param CRM_Event_DAO_Event|null $event
+ * @param int|null $eventID
*
* @return string
* @throws \CiviCRM_API3_Exception
*/
- protected static function getRecurringContributionDescription($contribution, $event) {
+ protected static function getRecurringContributionDescription($contribution, $eventID) {
if (!empty($contribution->source)) {
return $contribution->source;
}
]);
return ts('Online Contribution') . ': ' . $contributionPageTitle;
}
- elseif ($event) {
- return ts('Online Event Registration') . ': ' . $event->title;
+ elseif ($eventID) {
+ return ts('Online Event Registration') . ': ' . CRM_Event_PseudoConstant::event($eventID);
}
elseif (!empty($contribution->contribution_recur_id)) {
return 'recurring contribution';
$mut = new CiviMailUtils($this, TRUE);
$mut->clearMessages();
$this->_individualId = $this->createLoggedInUser();
+ // Unset source to test whether one is generated if not set already on the contribution.
+ unset($this->_params['source']);
$contributionID = $this->createPendingParticipantContribution();
$this->createJoinedProfile(['entity_id' => $this->_ids['event']['test'], 'entity_table' => 'civicrm_event']);
$this->createJoinedProfile(['entity_id' => $this->_ids['event']['test'], 'entity_table' => 'civicrm_event', 'weight' => 2], ['name' => 'post_1', 'title' => 'title_post_2', 'frontend_title' => 'public 2']);
$this->createJoinedProfile(['entity_id' => $this->_ids['event']['test'], 'entity_table' => 'civicrm_event', 'weight' => 3], ['name' => 'post_2', 'title' => 'title_post_3', 'frontend_title' => 'public 3']);
$this->eliminateUFGroupOne();
- $this->callAPISuccess('contribution', 'completetransaction', [
- 'id' => $contributionID,
- ]
- );
+ $this->callAPISuccess('contribution', 'completetransaction', ['id' => $contributionID]);
+ $contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $contributionID, 'return' => ['contribution_source']]);
+ $this->assertEquals('Online Event Registration: Annual CiviCRM meet', $contribution['contribution_source']);
$participantStatus = $this->callAPISuccessGetValue('participant', [
'id' => $this->_ids['participant'],
'return' => 'participant_status_id',